Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull vfs updates from Al Viro:
"Assorted stuff; the biggest pile here is Christoph's ACL series. Plus
assorted cleanups and fixes all over the place...

There will be another pile later this week"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (43 commits)
__dentry_path() fixes
vfs: Remove second variable named error in __dentry_path
vfs: Is mounted should be testing mnt_ns for NULL or error.
Fix race when checking i_size on direct i/o read
hfsplus: remove can_set_xattr
nfsd: use get_acl and ->set_acl
fs: remove generic_acl
nfs: use generic posix ACL infrastructure for v3 Posix ACLs
gfs2: use generic posix ACL infrastructure
jfs: use generic posix ACL infrastructure
xfs: use generic posix ACL infrastructure
reiserfs: use generic posix ACL infrastructure
ocfs2: use generic posix ACL infrastructure
jffs2: use generic posix ACL infrastructure
hfsplus: use generic posix ACL infrastructure
f2fs: use generic posix ACL infrastructure
ext2/3/4: use generic posix ACL infrastructure
btrfs: use generic posix ACL infrastructure
fs: make posix_acl_create more useful
fs: make posix_acl_chmod more useful
...

+1555 -3863
+1 -1
arch/blackfin/kernel/setup.c
··· 17 17 #ifdef CONFIG_MTD_UCLINUX 18 18 #include <linux/mtd/map.h> 19 19 #include <linux/ext2_fs.h> 20 - #include <linux/cramfs_fs.h> 20 + #include <uapi/linux/cramfs_fs.h> 21 21 #include <linux/romfs_fs.h> 22 22 #endif 23 23
-2
arch/cris/arch-v32/drivers/axisflashmap.c
··· 24 24 #include <linux/mtd/mtdram.h> 25 25 #include <linux/mtd/partitions.h> 26 26 27 - #include <linux/cramfs_fs.h> 28 - 29 27 #include <asm/axisflashmap.h> 30 28 #include <asm/mmu.h> 31 29
+2 -2
fs/9p/acl.c
··· 156 156 return -EOPNOTSUPP; 157 157 acl = v9fs_get_cached_acl(inode, ACL_TYPE_ACCESS); 158 158 if (acl) { 159 - retval = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode); 159 + retval = __posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode); 160 160 if (retval) 161 161 return retval; 162 162 set_cached_acl(inode, ACL_TYPE_ACCESS, acl); ··· 200 200 if (acl) { 201 201 if (S_ISDIR(mode)) 202 202 *dpacl = posix_acl_dup(acl); 203 - retval = posix_acl_create(&acl, GFP_NOFS, &mode); 203 + retval = __posix_acl_create(&acl, GFP_NOFS, &mode); 204 204 if (retval < 0) 205 205 return retval; 206 206 if (retval > 0)
+1 -5
fs/Kconfig
··· 68 68 source "fs/autofs4/Kconfig" 69 69 source "fs/fuse/Kconfig" 70 70 71 - config GENERIC_ACL 72 - bool 73 - select FS_POSIX_ACL 74 - 75 71 menu "Caches" 76 72 77 73 source "fs/fscache/Kconfig" ··· 115 119 bool "Tmpfs POSIX Access Control Lists" 116 120 depends on TMPFS 117 121 select TMPFS_XATTR 118 - select GENERIC_ACL 122 + select FS_POSIX_ACL 119 123 help 120 124 POSIX Access Control Lists (ACLs) support additional access rights 121 125 for users and groups beyond the standard owner/group/world scheme,
+1 -2
fs/Makefile
··· 42 42 obj-$(CONFIG_BINFMT_FLAT) += binfmt_flat.o 43 43 44 44 obj-$(CONFIG_FS_MBCACHE) += mbcache.o 45 - obj-$(CONFIG_FS_POSIX_ACL) += posix_acl.o xattr_acl.o 45 + obj-$(CONFIG_FS_POSIX_ACL) += posix_acl.o 46 46 obj-$(CONFIG_NFS_COMMON) += nfs_common/ 47 - obj-$(CONFIG_GENERIC_ACL) += generic_acl.o 48 47 obj-$(CONFIG_COREDUMP) += coredump.o 49 48 obj-$(CONFIG_SYSCTL) += drop_caches.o 50 49
+25 -32
fs/affs/super.c
··· 49 49 pr_debug("AFFS: put_super()\n"); 50 50 51 51 cancel_delayed_work_sync(&sbi->sb_work); 52 - kfree(sbi->s_prefix); 53 - affs_free_bitmap(sb); 54 - affs_brelse(sbi->s_root_bh); 55 - kfree(sbi); 56 - sb->s_fs_info = NULL; 57 52 } 58 53 59 54 static int ··· 311 316 unsigned long mount_flags; 312 317 int tmp_flags; /* fix remount prototype... */ 313 318 u8 sig[4]; 314 - int ret = -EINVAL; 319 + int ret; 315 320 316 321 save_mount_options(sb, data); 317 322 ··· 407 412 if (!silent) 408 413 printk(KERN_ERR "AFFS: No valid root block on device %s\n", 409 414 sb->s_id); 410 - goto out_error; 415 + return -EINVAL; 411 416 412 417 /* N.B. after this point bh must be released */ 413 418 got_root: 419 + /* Keep super block in cache */ 420 + sbi->s_root_bh = root_bh; 414 421 root_block = sbi->s_root_block; 415 422 416 423 /* Find out which kind of FS we have */ 417 424 boot_bh = sb_bread(sb, 0); 418 425 if (!boot_bh) { 419 426 printk(KERN_ERR "AFFS: Cannot read boot block\n"); 420 - goto out_error; 427 + return -EINVAL; 421 428 } 422 429 memcpy(sig, boot_bh->b_data, 4); 423 430 brelse(boot_bh); ··· 468 471 default: 469 472 printk(KERN_ERR "AFFS: Unknown filesystem on device %s: %08X\n", 470 473 sb->s_id, chksum); 471 - goto out_error; 474 + return -EINVAL; 472 475 } 473 476 474 477 if (mount_flags & SF_VERBOSE) { ··· 485 488 if (sbi->s_flags & SF_OFS) 486 489 sbi->s_data_blksize -= 24; 487 490 488 - /* Keep super block in cache */ 489 - sbi->s_root_bh = root_bh; 490 - /* N.B. after this point s_root_bh must be released */ 491 - 492 491 tmp_flags = sb->s_flags; 493 - if (affs_init_bitmap(sb, &tmp_flags)) 494 - goto out_error; 492 + ret = affs_init_bitmap(sb, &tmp_flags); 493 + if (ret) 494 + return ret; 495 495 sb->s_flags = tmp_flags; 496 496 497 497 /* set up enough so that it can read an inode */ 498 498 499 499 root_inode = affs_iget(sb, root_block); 500 - if (IS_ERR(root_inode)) { 501 - ret = PTR_ERR(root_inode); 502 - goto out_error; 503 - } 500 + if (IS_ERR(root_inode)) 501 + return PTR_ERR(root_inode); 504 502 505 503 if (AFFS_SB(sb)->s_flags & SF_INTL) 506 504 sb->s_d_op = &affs_intl_dentry_operations; ··· 505 513 sb->s_root = d_make_root(root_inode); 506 514 if (!sb->s_root) { 507 515 printk(KERN_ERR "AFFS: Get root inode failed\n"); 508 - goto out_error; 516 + return -ENOMEM; 509 517 } 510 518 511 519 pr_debug("AFFS: s_flags=%lX\n",sb->s_flags); 512 520 return 0; 513 - 514 - /* 515 - * Begin the cascaded cleanup ... 516 - */ 517 - out_error: 518 - kfree(sbi->s_bitmap); 519 - affs_brelse(root_bh); 520 - kfree(sbi->s_prefix); 521 - kfree(sbi); 522 - sb->s_fs_info = NULL; 523 - return ret; 524 521 } 525 522 526 523 static int ··· 596 615 return mount_bdev(fs_type, flags, dev_name, data, affs_fill_super); 597 616 } 598 617 618 + static void affs_kill_sb(struct super_block *sb) 619 + { 620 + struct affs_sb_info *sbi = AFFS_SB(sb); 621 + kill_block_super(sb); 622 + if (sbi) { 623 + affs_free_bitmap(sb); 624 + affs_brelse(sbi->s_root_bh); 625 + kfree(sbi->s_prefix); 626 + kfree(sbi); 627 + } 628 + } 629 + 599 630 static struct file_system_type affs_fs_type = { 600 631 .owner = THIS_MODULE, 601 632 .name = "affs", 602 633 .mount = affs_mount, 603 - .kill_sb = kill_block_super, 634 + .kill_sb = affs_kill_sb, 604 635 .fs_flags = FS_REQUIRES_DEV, 605 636 }; 606 637 MODULE_ALIAS_FS("affs");
-1
fs/afs/internal.h
··· 195 195 struct list_head link; /* main cell list link */ 196 196 struct key *anonymous_key; /* anonymous user key for this cell */ 197 197 struct list_head proc_link; /* /proc cell list link */ 198 - struct proc_dir_entry *proc_dir; /* /proc dir for this cell */ 199 198 #ifdef CONFIG_AFS_FSCACHE 200 199 struct fscache_cookie *cache; /* caching cookie */ 201 200 #endif
+22 -100
fs/afs/proc.c
··· 41 41 .write = afs_proc_cells_write, 42 42 .llseek = seq_lseek, 43 43 .release = seq_release, 44 - .owner = THIS_MODULE, 45 44 }; 46 45 47 - static int afs_proc_rootcell_open(struct inode *inode, struct file *file); 48 - static int afs_proc_rootcell_release(struct inode *inode, struct file *file); 49 46 static ssize_t afs_proc_rootcell_read(struct file *file, char __user *buf, 50 47 size_t size, loff_t *_pos); 51 48 static ssize_t afs_proc_rootcell_write(struct file *file, ··· 50 53 size_t size, loff_t *_pos); 51 54 52 55 static const struct file_operations afs_proc_rootcell_fops = { 53 - .open = afs_proc_rootcell_open, 54 56 .read = afs_proc_rootcell_read, 55 57 .write = afs_proc_rootcell_write, 56 58 .llseek = no_llseek, 57 - .release = afs_proc_rootcell_release, 58 - .owner = THIS_MODULE, 59 59 }; 60 60 61 61 static int afs_proc_cell_volumes_open(struct inode *inode, struct file *file); 62 - static int afs_proc_cell_volumes_release(struct inode *inode, 63 - struct file *file); 64 62 static void *afs_proc_cell_volumes_start(struct seq_file *p, loff_t *pos); 65 63 static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v, 66 64 loff_t *pos); ··· 73 81 .open = afs_proc_cell_volumes_open, 74 82 .read = seq_read, 75 83 .llseek = seq_lseek, 76 - .release = afs_proc_cell_volumes_release, 77 - .owner = THIS_MODULE, 84 + .release = seq_release, 78 85 }; 79 86 80 87 static int afs_proc_cell_vlservers_open(struct inode *inode, 81 88 struct file *file); 82 - static int afs_proc_cell_vlservers_release(struct inode *inode, 83 - struct file *file); 84 89 static void *afs_proc_cell_vlservers_start(struct seq_file *p, loff_t *pos); 85 90 static void *afs_proc_cell_vlservers_next(struct seq_file *p, void *v, 86 91 loff_t *pos); ··· 95 106 .open = afs_proc_cell_vlservers_open, 96 107 .read = seq_read, 97 108 .llseek = seq_lseek, 98 - .release = afs_proc_cell_vlservers_release, 99 - .owner = THIS_MODULE, 109 + .release = seq_release, 100 110 }; 101 111 102 112 static int afs_proc_cell_servers_open(struct inode *inode, struct file *file); 103 - static int afs_proc_cell_servers_release(struct inode *inode, 104 - struct file *file); 105 113 static void *afs_proc_cell_servers_start(struct seq_file *p, loff_t *pos); 106 114 static void *afs_proc_cell_servers_next(struct seq_file *p, void *v, 107 115 loff_t *pos); ··· 116 130 .open = afs_proc_cell_servers_open, 117 131 .read = seq_read, 118 132 .llseek = seq_lseek, 119 - .release = afs_proc_cell_servers_release, 120 - .owner = THIS_MODULE, 133 + .release = seq_release, 121 134 }; 122 135 123 136 /* ··· 124 139 */ 125 140 int afs_proc_init(void) 126 141 { 127 - struct proc_dir_entry *p; 128 - 129 142 _enter(""); 130 143 131 144 proc_afs = proc_mkdir("fs/afs", NULL); 132 145 if (!proc_afs) 133 146 goto error_dir; 134 147 135 - p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops); 136 - if (!p) 137 - goto error_cells; 138 - 139 - p = proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops); 140 - if (!p) 141 - goto error_rootcell; 148 + if (!proc_create("cells", 0, proc_afs, &afs_proc_cells_fops) || 149 + !proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops)) 150 + goto error_tree; 142 151 143 152 _leave(" = 0"); 144 153 return 0; 145 154 146 - error_rootcell: 147 - remove_proc_entry("cells", proc_afs); 148 - error_cells: 149 - remove_proc_entry("fs/afs", NULL); 155 + error_tree: 156 + remove_proc_subtree("fs/afs", NULL); 150 157 error_dir: 151 158 _leave(" = -ENOMEM"); 152 159 return -ENOMEM; ··· 149 172 */ 150 173 void afs_proc_cleanup(void) 151 174 { 152 - remove_proc_entry("rootcell", proc_afs); 153 - remove_proc_entry("cells", proc_afs); 154 - remove_proc_entry("fs/afs", NULL); 175 + remove_proc_subtree("fs/afs", NULL); 155 176 } 156 177 157 178 /* ··· 294 319 goto done; 295 320 } 296 321 297 - /* 298 - * Stubs for /proc/fs/afs/rootcell 299 - */ 300 - static int afs_proc_rootcell_open(struct inode *inode, struct file *file) 301 - { 302 - return 0; 303 - } 304 - 305 - static int afs_proc_rootcell_release(struct inode *inode, struct file *file) 306 - { 307 - return 0; 308 - } 309 - 310 322 static ssize_t afs_proc_rootcell_read(struct file *file, char __user *buf, 311 323 size_t size, loff_t *_pos) 312 324 { ··· 349 387 */ 350 388 int afs_proc_cell_setup(struct afs_cell *cell) 351 389 { 352 - struct proc_dir_entry *p; 390 + struct proc_dir_entry *dir; 353 391 354 392 _enter("%p{%s}", cell, cell->name); 355 393 356 - cell->proc_dir = proc_mkdir(cell->name, proc_afs); 357 - if (!cell->proc_dir) 394 + dir = proc_mkdir(cell->name, proc_afs); 395 + if (!dir) 358 396 goto error_dir; 359 397 360 - p = proc_create_data("servers", 0, cell->proc_dir, 361 - &afs_proc_cell_servers_fops, cell); 362 - if (!p) 363 - goto error_servers; 364 - 365 - p = proc_create_data("vlservers", 0, cell->proc_dir, 366 - &afs_proc_cell_vlservers_fops, cell); 367 - if (!p) 368 - goto error_vlservers; 369 - 370 - p = proc_create_data("volumes", 0, cell->proc_dir, 371 - &afs_proc_cell_volumes_fops, cell); 372 - if (!p) 373 - goto error_volumes; 398 + if (!proc_create_data("servers", 0, dir, 399 + &afs_proc_cell_servers_fops, cell) || 400 + !proc_create_data("vlservers", 0, dir, 401 + &afs_proc_cell_vlservers_fops, cell) || 402 + !proc_create_data("volumes", 0, dir, 403 + &afs_proc_cell_volumes_fops, cell)) 404 + goto error_tree; 374 405 375 406 _leave(" = 0"); 376 407 return 0; 377 408 378 - error_volumes: 379 - remove_proc_entry("vlservers", cell->proc_dir); 380 - error_vlservers: 381 - remove_proc_entry("servers", cell->proc_dir); 382 - error_servers: 383 - remove_proc_entry(cell->name, proc_afs); 409 + error_tree: 410 + remove_proc_subtree(cell->name, proc_afs); 384 411 error_dir: 385 412 _leave(" = -ENOMEM"); 386 413 return -ENOMEM; ··· 382 431 { 383 432 _enter(""); 384 433 385 - remove_proc_entry("volumes", cell->proc_dir); 386 - remove_proc_entry("vlservers", cell->proc_dir); 387 - remove_proc_entry("servers", cell->proc_dir); 388 - remove_proc_entry(cell->name, proc_afs); 434 + remove_proc_subtree(cell->name, proc_afs); 389 435 390 436 _leave(""); 391 437 } ··· 408 460 m->private = cell; 409 461 410 462 return 0; 411 - } 412 - 413 - /* 414 - * close the file and release the ref to the cell 415 - */ 416 - static int afs_proc_cell_volumes_release(struct inode *inode, struct file *file) 417 - { 418 - return seq_release(inode, file); 419 463 } 420 464 421 465 /* ··· 509 569 } 510 570 511 571 /* 512 - * close the file and release the ref to the cell 513 - */ 514 - static int afs_proc_cell_vlservers_release(struct inode *inode, 515 - struct file *file) 516 - { 517 - return seq_release(inode, file); 518 - } 519 - 520 - /* 521 572 * set up the iterator to start reading from the cells list and return the 522 573 * first item 523 574 */ ··· 601 670 m = file->private_data; 602 671 m->private = cell; 603 672 return 0; 604 - } 605 - 606 - /* 607 - * close the file and release the ref to the cell 608 - */ 609 - static int afs_proc_cell_servers_release(struct inode *inode, 610 - struct file *file) 611 - { 612 - return seq_release(inode, file); 613 673 } 614 674 615 675 /*
+2 -2
fs/befs/linuxvfs.c
··· 324 324 befs_debug(sb, "---> befs_read_inode() " "inode = %lu", ino); 325 325 326 326 inode = iget_locked(sb, ino); 327 - if (IS_ERR(inode)) 328 - return inode; 327 + if (!inode) 328 + return ERR_PTR(-ENOMEM); 329 329 if (!(inode->i_state & I_NEW)) 330 330 return inode; 331 331
+21 -127
fs/btrfs/acl.c
··· 35 35 char *value = NULL; 36 36 struct posix_acl *acl; 37 37 38 - if (!IS_POSIXACL(inode)) 39 - return NULL; 40 - 41 - acl = get_cached_acl(inode, type); 42 - if (acl != ACL_NOT_CACHED) 43 - return acl; 44 - 45 38 switch (type) { 46 39 case ACL_TYPE_ACCESS: 47 40 name = POSIX_ACL_XATTR_ACCESS; ··· 69 76 return acl; 70 77 } 71 78 72 - static int btrfs_xattr_acl_get(struct dentry *dentry, const char *name, 73 - void *value, size_t size, int type) 74 - { 75 - struct posix_acl *acl; 76 - int ret = 0; 77 - 78 - if (!IS_POSIXACL(dentry->d_inode)) 79 - return -EOPNOTSUPP; 80 - 81 - acl = btrfs_get_acl(dentry->d_inode, type); 82 - 83 - if (IS_ERR(acl)) 84 - return PTR_ERR(acl); 85 - if (acl == NULL) 86 - return -ENODATA; 87 - ret = posix_acl_to_xattr(&init_user_ns, acl, value, size); 88 - posix_acl_release(acl); 89 - 90 - return ret; 91 - } 92 - 93 79 /* 94 80 * Needs to be called with fs_mutex held 95 81 */ 96 - static int btrfs_set_acl(struct btrfs_trans_handle *trans, 82 + static int __btrfs_set_acl(struct btrfs_trans_handle *trans, 97 83 struct inode *inode, struct posix_acl *acl, int type) 98 84 { 99 85 int ret, size = 0; ··· 130 158 return ret; 131 159 } 132 160 133 - static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name, 134 - const void *value, size_t size, int flags, int type) 161 + int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) 135 162 { 136 - int ret; 137 - struct posix_acl *acl = NULL; 138 - 139 - if (!inode_owner_or_capable(dentry->d_inode)) 140 - return -EPERM; 141 - 142 - if (!IS_POSIXACL(dentry->d_inode)) 143 - return -EOPNOTSUPP; 144 - 145 - if (value) { 146 - acl = posix_acl_from_xattr(&init_user_ns, value, size); 147 - if (IS_ERR(acl)) 148 - return PTR_ERR(acl); 149 - 150 - if (acl) { 151 - ret = posix_acl_valid(acl); 152 - if (ret) 153 - goto out; 154 - } 155 - } 156 - 157 - ret = btrfs_set_acl(NULL, dentry->d_inode, acl, type); 158 - out: 159 - posix_acl_release(acl); 160 - 161 - return ret; 163 + return __btrfs_set_acl(NULL, inode, acl, type); 162 164 } 163 165 164 166 /* ··· 143 197 int btrfs_init_acl(struct btrfs_trans_handle *trans, 144 198 struct inode *inode, struct inode *dir) 145 199 { 146 - struct posix_acl *acl = NULL; 200 + struct posix_acl *default_acl, *acl; 147 201 int ret = 0; 148 202 149 203 /* this happens with subvols */ 150 204 if (!dir) 151 205 return 0; 152 206 153 - if (!S_ISLNK(inode->i_mode)) { 154 - if (IS_POSIXACL(dir)) { 155 - acl = btrfs_get_acl(dir, ACL_TYPE_DEFAULT); 156 - if (IS_ERR(acl)) 157 - return PTR_ERR(acl); 158 - } 159 - 160 - if (!acl) 161 - inode->i_mode &= ~current_umask(); 162 - } 163 - 164 - if (IS_POSIXACL(dir) && acl) { 165 - if (S_ISDIR(inode->i_mode)) { 166 - ret = btrfs_set_acl(trans, inode, acl, 167 - ACL_TYPE_DEFAULT); 168 - if (ret) 169 - goto failed; 170 - } 171 - ret = posix_acl_create(&acl, GFP_NOFS, &inode->i_mode); 172 - if (ret < 0) 173 - return ret; 174 - 175 - if (ret > 0) { 176 - /* we need an acl */ 177 - ret = btrfs_set_acl(trans, inode, acl, ACL_TYPE_ACCESS); 178 - } else if (ret < 0) { 179 - cache_no_acl(inode); 180 - } 181 - } else { 182 - cache_no_acl(inode); 183 - } 184 - failed: 185 - posix_acl_release(acl); 186 - 187 - return ret; 188 - } 189 - 190 - int btrfs_acl_chmod(struct inode *inode) 191 - { 192 - struct posix_acl *acl; 193 - int ret = 0; 194 - 195 - if (S_ISLNK(inode->i_mode)) 196 - return -EOPNOTSUPP; 197 - 198 - if (!IS_POSIXACL(inode)) 199 - return 0; 200 - 201 - acl = btrfs_get_acl(inode, ACL_TYPE_ACCESS); 202 - if (IS_ERR_OR_NULL(acl)) 203 - return PTR_ERR(acl); 204 - 205 - ret = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode); 207 + ret = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl); 206 208 if (ret) 207 209 return ret; 208 - ret = btrfs_set_acl(NULL, inode, acl, ACL_TYPE_ACCESS); 209 - posix_acl_release(acl); 210 + 211 + if (default_acl) { 212 + ret = __btrfs_set_acl(trans, inode, default_acl, 213 + ACL_TYPE_DEFAULT); 214 + posix_acl_release(default_acl); 215 + } 216 + 217 + if (acl) { 218 + if (!ret) 219 + ret = __btrfs_set_acl(trans, inode, acl, 220 + ACL_TYPE_ACCESS); 221 + posix_acl_release(acl); 222 + } 223 + 224 + if (!default_acl && !acl) 225 + cache_no_acl(inode); 210 226 return ret; 211 227 } 212 - 213 - const struct xattr_handler btrfs_xattr_acl_default_handler = { 214 - .prefix = POSIX_ACL_XATTR_DEFAULT, 215 - .flags = ACL_TYPE_DEFAULT, 216 - .get = btrfs_xattr_acl_get, 217 - .set = btrfs_xattr_acl_set, 218 - }; 219 - 220 - const struct xattr_handler btrfs_xattr_acl_access_handler = { 221 - .prefix = POSIX_ACL_XATTR_ACCESS, 222 - .flags = ACL_TYPE_ACCESS, 223 - .get = btrfs_xattr_acl_get, 224 - .set = btrfs_xattr_acl_set, 225 - };
+2 -5
fs/btrfs/ctree.h
··· 3899 3899 /* acl.c */ 3900 3900 #ifdef CONFIG_BTRFS_FS_POSIX_ACL 3901 3901 struct posix_acl *btrfs_get_acl(struct inode *inode, int type); 3902 + int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type); 3902 3903 int btrfs_init_acl(struct btrfs_trans_handle *trans, 3903 3904 struct inode *inode, struct inode *dir); 3904 - int btrfs_acl_chmod(struct inode *inode); 3905 3905 #else 3906 3906 #define btrfs_get_acl NULL 3907 + #define btrfs_set_acl NULL 3907 3908 static inline int btrfs_init_acl(struct btrfs_trans_handle *trans, 3908 3909 struct inode *inode, struct inode *dir) 3909 - { 3910 - return 0; 3911 - } 3912 - static inline int btrfs_acl_chmod(struct inode *inode) 3913 3910 { 3914 3911 return 0; 3915 3912 }
+5 -2
fs/btrfs/inode.c
··· 4468 4468 err = btrfs_dirty_inode(inode); 4469 4469 4470 4470 if (!err && attr->ia_valid & ATTR_MODE) 4471 - err = btrfs_acl_chmod(inode); 4471 + err = posix_acl_chmod(inode, inode->i_mode); 4472 4472 } 4473 4473 4474 4474 return err; ··· 8653 8653 .removexattr = btrfs_removexattr, 8654 8654 .permission = btrfs_permission, 8655 8655 .get_acl = btrfs_get_acl, 8656 + .set_acl = btrfs_set_acl, 8656 8657 .update_time = btrfs_update_time, 8657 8658 }; 8658 8659 static const struct inode_operations btrfs_dir_ro_inode_operations = { 8659 8660 .lookup = btrfs_lookup, 8660 8661 .permission = btrfs_permission, 8661 8662 .get_acl = btrfs_get_acl, 8663 + .set_acl = btrfs_set_acl, 8662 8664 .update_time = btrfs_update_time, 8663 8665 }; 8664 8666 ··· 8730 8728 .permission = btrfs_permission, 8731 8729 .fiemap = btrfs_fiemap, 8732 8730 .get_acl = btrfs_get_acl, 8731 + .set_acl = btrfs_set_acl, 8733 8732 .update_time = btrfs_update_time, 8734 8733 }; 8735 8734 static const struct inode_operations btrfs_special_inode_operations = { ··· 8742 8739 .listxattr = btrfs_listxattr, 8743 8740 .removexattr = btrfs_removexattr, 8744 8741 .get_acl = btrfs_get_acl, 8742 + .set_acl = btrfs_set_acl, 8745 8743 .update_time = btrfs_update_time, 8746 8744 }; 8747 8745 static const struct inode_operations btrfs_symlink_inode_operations = { ··· 8756 8752 .getxattr = btrfs_getxattr, 8757 8753 .listxattr = btrfs_listxattr, 8758 8754 .removexattr = btrfs_removexattr, 8759 - .get_acl = btrfs_get_acl, 8760 8755 .update_time = btrfs_update_time, 8761 8756 }; 8762 8757
+24 -46
fs/btrfs/ioctl.c
··· 2686 2686 #define BTRFS_MAX_DEDUPE_LEN (16 * 1024 * 1024) 2687 2687 2688 2688 static long btrfs_ioctl_file_extent_same(struct file *file, 2689 - void __user *argp) 2689 + struct btrfs_ioctl_same_args __user *argp) 2690 2690 { 2691 - struct btrfs_ioctl_same_args tmp; 2692 2691 struct btrfs_ioctl_same_args *same; 2693 2692 struct btrfs_ioctl_same_extent_info *info; 2694 - struct inode *src = file->f_dentry->d_inode; 2695 - struct file *dst_file = NULL; 2696 - struct inode *dst; 2693 + struct inode *src = file_inode(file); 2697 2694 u64 off; 2698 2695 u64 len; 2699 2696 int i; ··· 2698 2701 unsigned long size; 2699 2702 u64 bs = BTRFS_I(src)->root->fs_info->sb->s_blocksize; 2700 2703 bool is_admin = capable(CAP_SYS_ADMIN); 2704 + u16 count; 2701 2705 2702 2706 if (!(file->f_mode & FMODE_READ)) 2703 2707 return -EINVAL; ··· 2707 2709 if (ret) 2708 2710 return ret; 2709 2711 2710 - if (copy_from_user(&tmp, 2711 - (struct btrfs_ioctl_same_args __user *)argp, 2712 - sizeof(tmp))) { 2712 + if (get_user(count, &argp->dest_count)) { 2713 2713 ret = -EFAULT; 2714 2714 goto out; 2715 2715 } 2716 2716 2717 - size = sizeof(tmp) + 2718 - tmp.dest_count * sizeof(struct btrfs_ioctl_same_extent_info); 2717 + size = offsetof(struct btrfs_ioctl_same_args __user, info[count]); 2719 2718 2720 - same = memdup_user((struct btrfs_ioctl_same_args __user *)argp, size); 2719 + same = memdup_user(argp, size); 2721 2720 2722 2721 if (IS_ERR(same)) { 2723 2722 ret = PTR_ERR(same); ··· 2751 2756 goto out; 2752 2757 2753 2758 /* pre-format output fields to sane values */ 2754 - for (i = 0; i < same->dest_count; i++) { 2759 + for (i = 0; i < count; i++) { 2755 2760 same->info[i].bytes_deduped = 0ULL; 2756 2761 same->info[i].status = 0; 2757 2762 } 2758 2763 2759 - ret = 0; 2760 - for (i = 0; i < same->dest_count; i++) { 2761 - info = &same->info[i]; 2762 - 2763 - dst_file = fget(info->fd); 2764 - if (!dst_file) { 2764 + for (i = 0, info = same->info; i < count; i++, info++) { 2765 + struct inode *dst; 2766 + struct fd dst_file = fdget(info->fd); 2767 + if (!dst_file.file) { 2765 2768 info->status = -EBADF; 2766 - goto next; 2769 + continue; 2767 2770 } 2771 + dst = file_inode(dst_file.file); 2768 2772 2769 - if (!(is_admin || (dst_file->f_mode & FMODE_WRITE))) { 2773 + if (!(is_admin || (dst_file.file->f_mode & FMODE_WRITE))) { 2770 2774 info->status = -EINVAL; 2771 - goto next; 2772 - } 2773 - 2774 - info->status = -EXDEV; 2775 - if (file->f_path.mnt != dst_file->f_path.mnt) 2776 - goto next; 2777 - 2778 - dst = dst_file->f_dentry->d_inode; 2779 - if (src->i_sb != dst->i_sb) 2780 - goto next; 2781 - 2782 - if (S_ISDIR(dst->i_mode)) { 2775 + } else if (file->f_path.mnt != dst_file.file->f_path.mnt) { 2776 + info->status = -EXDEV; 2777 + } else if (S_ISDIR(dst->i_mode)) { 2783 2778 info->status = -EISDIR; 2784 - goto next; 2785 - } 2786 - 2787 - if (!S_ISREG(dst->i_mode)) { 2779 + } else if (!S_ISREG(dst->i_mode)) { 2788 2780 info->status = -EACCES; 2789 - goto next; 2781 + } else { 2782 + info->status = btrfs_extent_same(src, off, len, dst, 2783 + info->logical_offset); 2784 + if (info->status == 0) 2785 + info->bytes_deduped += len; 2790 2786 } 2791 - 2792 - info->status = btrfs_extent_same(src, off, len, dst, 2793 - info->logical_offset); 2794 - if (info->status == 0) 2795 - info->bytes_deduped += len; 2796 - 2797 - next: 2798 - if (dst_file) 2799 - fput(dst_file); 2787 + fdput(dst_file); 2800 2788 } 2801 2789 2802 2790 ret = copy_to_user(argp, same, size);
+3 -2
fs/btrfs/xattr.c
··· 22 22 #include <linux/rwsem.h> 23 23 #include <linux/xattr.h> 24 24 #include <linux/security.h> 25 + #include <linux/posix_acl_xattr.h> 25 26 #include "ctree.h" 26 27 #include "btrfs_inode.h" 27 28 #include "transaction.h" ··· 314 313 */ 315 314 const struct xattr_handler *btrfs_xattr_handlers[] = { 316 315 #ifdef CONFIG_BTRFS_FS_POSIX_ACL 317 - &btrfs_xattr_acl_access_handler, 318 - &btrfs_xattr_acl_default_handler, 316 + &posix_acl_access_xattr_handler, 317 + &posix_acl_default_xattr_handler, 319 318 #endif 320 319 NULL, 321 320 };
-2
fs/btrfs/xattr.h
··· 21 21 22 22 #include <linux/xattr.h> 23 23 24 - extern const struct xattr_handler btrfs_xattr_acl_access_handler; 25 - extern const struct xattr_handler btrfs_xattr_acl_default_handler; 26 24 extern const struct xattr_handler *btrfs_xattr_handlers[]; 27 25 28 26 extern ssize_t __btrfs_getxattr(struct inode *inode, const char *name,
+31 -19
fs/cramfs/inode.c
··· 17 17 #include <linux/init.h> 18 18 #include <linux/string.h> 19 19 #include <linux/blkdev.h> 20 - #include <linux/cramfs_fs.h> 21 20 #include <linux/slab.h> 22 - #include <linux/cramfs_fs_sb.h> 23 21 #include <linux/vfs.h> 24 22 #include <linux/mutex.h> 25 - 23 + #include <uapi/linux/cramfs_fs.h> 26 24 #include <asm/uaccess.h> 25 + 26 + #include "internal.h" 27 + 28 + /* 29 + * cramfs super-block data in memory 30 + */ 31 + struct cramfs_sb_info { 32 + unsigned long magic; 33 + unsigned long size; 34 + unsigned long blocks; 35 + unsigned long files; 36 + unsigned long flags; 37 + }; 38 + 39 + static inline struct cramfs_sb_info *CRAMFS_SB(struct super_block *sb) 40 + { 41 + return sb->s_fs_info; 42 + } 27 43 28 44 static const struct super_operations cramfs_ops; 29 45 static const struct inode_operations cramfs_dir_inode_operations; ··· 235 219 return read_buffers[buffer] + offset; 236 220 } 237 221 238 - static void cramfs_put_super(struct super_block *sb) 222 + static void cramfs_kill_sb(struct super_block *sb) 239 223 { 240 - kfree(sb->s_fs_info); 241 - sb->s_fs_info = NULL; 224 + struct cramfs_sb_info *sbi = CRAMFS_SB(sb); 225 + kill_block_super(sb); 226 + kfree(sbi); 242 227 } 243 228 244 229 static int cramfs_remount(struct super_block *sb, int *flags, char *data) ··· 278 261 if (super.magic == CRAMFS_MAGIC_WEND) { 279 262 if (!silent) 280 263 printk(KERN_ERR "cramfs: wrong endianness\n"); 281 - goto out; 264 + return -EINVAL; 282 265 } 283 266 284 267 /* check at 512 byte offset */ ··· 290 273 printk(KERN_ERR "cramfs: wrong endianness\n"); 291 274 else if (!silent) 292 275 printk(KERN_ERR "cramfs: wrong magic\n"); 293 - goto out; 276 + return -EINVAL; 294 277 } 295 278 } 296 279 297 280 /* get feature flags first */ 298 281 if (super.flags & ~CRAMFS_SUPPORTED_FLAGS) { 299 282 printk(KERN_ERR "cramfs: unsupported filesystem features\n"); 300 - goto out; 283 + return -EINVAL; 301 284 } 302 285 303 286 /* Check that the root inode is in a sane state */ 304 287 if (!S_ISDIR(super.root.mode)) { 305 288 printk(KERN_ERR "cramfs: root is not a directory\n"); 306 - goto out; 289 + return -EINVAL; 307 290 } 308 291 /* correct strange, hard-coded permissions of mkcramfs */ 309 292 super.root.mode |= (S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); ··· 327 310 (root_offset != 512 + sizeof(struct cramfs_super)))) 328 311 { 329 312 printk(KERN_ERR "cramfs: bad root offset %lu\n", root_offset); 330 - goto out; 313 + return -EINVAL; 331 314 } 332 315 333 316 /* Set it all up.. */ 334 317 sb->s_op = &cramfs_ops; 335 318 root = get_cramfs_inode(sb, &super.root, 0); 336 319 if (IS_ERR(root)) 337 - goto out; 320 + return PTR_ERR(root); 338 321 sb->s_root = d_make_root(root); 339 322 if (!sb->s_root) 340 - goto out; 323 + return -ENOMEM; 341 324 return 0; 342 - out: 343 - kfree(sbi); 344 - sb->s_fs_info = NULL; 345 - return -EINVAL; 346 325 } 347 326 348 327 static int cramfs_statfs(struct dentry *dentry, struct kstatfs *buf) ··· 563 550 }; 564 551 565 552 static const struct super_operations cramfs_ops = { 566 - .put_super = cramfs_put_super, 567 553 .remount_fs = cramfs_remount, 568 554 .statfs = cramfs_statfs, 569 555 }; ··· 577 565 .owner = THIS_MODULE, 578 566 .name = "cramfs", 579 567 .mount = cramfs_mount, 580 - .kill_sb = kill_block_super, 568 + .kill_sb = cramfs_kill_sb, 581 569 .fs_flags = FS_REQUIRES_DEV, 582 570 }; 583 571 MODULE_ALIAS_FS("cramfs");
+1 -1
fs/cramfs/uncompress.c
··· 19 19 #include <linux/errno.h> 20 20 #include <linux/vmalloc.h> 21 21 #include <linux/zlib.h> 22 - #include <linux/cramfs_fs.h> 22 + #include "internal.h" 23 23 24 24 static z_stream stream; 25 25 static int initialized;
+6 -4
fs/dcache.c
··· 3116 3116 /* 3117 3117 * Write full pathname from the root of the filesystem into the buffer. 3118 3118 */ 3119 - static char *__dentry_path(struct dentry *dentry, char *buf, int buflen) 3119 + static char *__dentry_path(struct dentry *d, char *buf, int buflen) 3120 3120 { 3121 + struct dentry *dentry; 3121 3122 char *end, *retval; 3122 3123 int len, seq = 0; 3123 3124 int error = 0; 3124 3125 3126 + if (buflen < 2) 3127 + goto Elong; 3128 + 3125 3129 rcu_read_lock(); 3126 3130 restart: 3131 + dentry = d; 3127 3132 end = buf + buflen; 3128 3133 len = buflen; 3129 3134 prepend(&end, &len, "\0", 1); 3130 - if (buflen < 1) 3131 - goto Elong; 3132 3135 /* Get '/' right */ 3133 3136 retval = end-1; 3134 3137 *retval = '/'; 3135 3138 read_seqbegin_or_lock(&rename_lock, &seq); 3136 3139 while (!IS_ROOT(dentry)) { 3137 3140 struct dentry *parent = dentry->d_parent; 3138 - int error; 3139 3141 3140 3142 prefetch(parent); 3141 3143 error = prepend_name(&end, &len, &dentry->d_name);
+13 -16
fs/ecryptfs/inode.c
··· 659 659 return rc; 660 660 } 661 661 662 - static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf, 663 - size_t *bufsiz) 662 + static char *ecryptfs_readlink_lower(struct dentry *dentry, size_t *bufsiz) 664 663 { 665 664 struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry); 666 665 char *lower_buf; 666 + char *buf; 667 667 mm_segment_t old_fs; 668 668 int rc; 669 669 670 670 lower_buf = kmalloc(PATH_MAX, GFP_KERNEL); 671 - if (!lower_buf) { 672 - rc = -ENOMEM; 673 - goto out; 674 - } 671 + if (!lower_buf) 672 + return ERR_PTR(-ENOMEM); 675 673 old_fs = get_fs(); 676 674 set_fs(get_ds()); 677 675 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry, ··· 678 680 set_fs(old_fs); 679 681 if (rc < 0) 680 682 goto out; 681 - rc = ecryptfs_decode_and_decrypt_filename(buf, bufsiz, dentry->d_sb, 683 + rc = ecryptfs_decode_and_decrypt_filename(&buf, bufsiz, dentry->d_sb, 682 684 lower_buf, rc); 683 685 out: 684 686 kfree(lower_buf); 685 - return rc; 687 + return rc ? ERR_PTR(rc) : buf; 686 688 } 687 689 688 690 static void *ecryptfs_follow_link(struct dentry *dentry, struct nameidata *nd) 689 691 { 690 - char *buf; 691 - size_t len = PATH_MAX; 692 - int rc; 693 - 694 - rc = ecryptfs_readlink_lower(dentry, &buf, &len); 695 - if (rc) 692 + size_t len; 693 + char *buf = ecryptfs_readlink_lower(dentry, &len); 694 + if (IS_ERR(buf)) 696 695 goto out; 697 696 fsstack_copy_attr_atime(dentry->d_inode, 698 697 ecryptfs_dentry_to_lower(dentry)->d_inode); ··· 998 1003 char *target; 999 1004 size_t targetsiz; 1000 1005 1001 - rc = ecryptfs_readlink_lower(dentry, &target, &targetsiz); 1002 - if (!rc) { 1006 + target = ecryptfs_readlink_lower(dentry, &targetsiz); 1007 + if (!IS_ERR(target)) { 1003 1008 kfree(target); 1004 1009 stat->size = targetsiz; 1010 + } else { 1011 + rc = PTR_ERR(target); 1005 1012 } 1006 1013 } 1007 1014 return rc;
+15 -24
fs/efs/super.c
··· 26 26 return mount_bdev(fs_type, flags, dev_name, data, efs_fill_super); 27 27 } 28 28 29 + static void efs_kill_sb(struct super_block *s) 30 + { 31 + struct efs_sb_info *sbi = SUPER_INFO(s); 32 + kill_block_super(s); 33 + kfree(sbi); 34 + } 35 + 29 36 static struct file_system_type efs_fs_type = { 30 37 .owner = THIS_MODULE, 31 38 .name = "efs", 32 39 .mount = efs_mount, 33 - .kill_sb = kill_block_super, 40 + .kill_sb = efs_kill_sb, 34 41 .fs_flags = FS_REQUIRES_DEV, 35 42 }; 36 43 MODULE_ALIAS_FS("efs"); ··· 112 105 kmem_cache_destroy(efs_inode_cachep); 113 106 } 114 107 115 - static void efs_put_super(struct super_block *s) 116 - { 117 - kfree(s->s_fs_info); 118 - s->s_fs_info = NULL; 119 - } 120 - 121 108 static int efs_remount(struct super_block *sb, int *flags, char *data) 122 109 { 123 110 *flags |= MS_RDONLY; ··· 121 120 static const struct super_operations efs_superblock_operations = { 122 121 .alloc_inode = efs_alloc_inode, 123 122 .destroy_inode = efs_destroy_inode, 124 - .put_super = efs_put_super, 125 123 .statfs = efs_statfs, 126 124 .remount_fs = efs_remount, 127 125 }; ··· 259 259 struct efs_sb_info *sb; 260 260 struct buffer_head *bh; 261 261 struct inode *root; 262 - int ret = -EINVAL; 263 262 264 263 sb = kzalloc(sizeof(struct efs_sb_info), GFP_KERNEL); 265 264 if (!sb) ··· 269 270 if (!sb_set_blocksize(s, EFS_BLOCKSIZE)) { 270 271 printk(KERN_ERR "EFS: device does not support %d byte blocks\n", 271 272 EFS_BLOCKSIZE); 272 - goto out_no_fs_ul; 273 + return -EINVAL; 273 274 } 274 275 275 276 /* read the vh (volume header) block */ ··· 277 278 278 279 if (!bh) { 279 280 printk(KERN_ERR "EFS: cannot read volume header\n"); 280 - goto out_no_fs_ul; 281 + return -EINVAL; 281 282 } 282 283 283 284 /* ··· 289 290 brelse(bh); 290 291 291 292 if (sb->fs_start == -1) { 292 - goto out_no_fs_ul; 293 + return -EINVAL; 293 294 } 294 295 295 296 bh = sb_bread(s, sb->fs_start + EFS_SUPER); 296 297 if (!bh) { 297 298 printk(KERN_ERR "EFS: cannot read superblock\n"); 298 - goto out_no_fs_ul; 299 + return -EINVAL; 299 300 } 300 301 301 302 if (efs_validate_super(sb, (struct efs_super *) bh->b_data)) { ··· 303 304 printk(KERN_WARNING "EFS: invalid superblock at block %u\n", sb->fs_start + EFS_SUPER); 304 305 #endif 305 306 brelse(bh); 306 - goto out_no_fs_ul; 307 + return -EINVAL; 307 308 } 308 309 brelse(bh); 309 310 ··· 318 319 root = efs_iget(s, EFS_ROOTINODE); 319 320 if (IS_ERR(root)) { 320 321 printk(KERN_ERR "EFS: get root inode failed\n"); 321 - ret = PTR_ERR(root); 322 - goto out_no_fs; 322 + return PTR_ERR(root); 323 323 } 324 324 325 325 s->s_root = d_make_root(root); 326 326 if (!(s->s_root)) { 327 327 printk(KERN_ERR "EFS: get root dentry failed\n"); 328 - ret = -ENOMEM; 329 - goto out_no_fs; 328 + return -ENOMEM; 330 329 } 331 330 332 331 return 0; 333 - 334 - out_no_fs_ul: 335 - out_no_fs: 336 - s->s_fs_info = NULL; 337 - kfree(sb); 338 - return ret; 339 332 } 340 333 341 334 static int efs_statfs(struct dentry *dentry, struct kstatfs *buf) {
+5 -8
fs/eventfd.c
··· 349 349 */ 350 350 struct eventfd_ctx *eventfd_ctx_fdget(int fd) 351 351 { 352 - struct file *file; 353 352 struct eventfd_ctx *ctx; 354 - 355 - file = eventfd_fget(fd); 356 - if (IS_ERR(file)) 357 - return (struct eventfd_ctx *) file; 358 - ctx = eventfd_ctx_get(file->private_data); 359 - fput(file); 360 - 353 + struct fd f = fdget(fd); 354 + if (!f.file) 355 + return ERR_PTR(-EBADF); 356 + ctx = eventfd_ctx_fileget(f.file); 357 + fdput(f); 361 358 return ctx; 362 359 } 363 360 EXPORT_SYMBOL_GPL(eventfd_ctx_fdget);
+15 -175
fs/ext2/acl.c
··· 148 148 struct posix_acl *acl; 149 149 int retval; 150 150 151 - if (!test_opt(inode->i_sb, POSIX_ACL)) 152 - return NULL; 153 - 154 - acl = get_cached_acl(inode, type); 155 - if (acl != ACL_NOT_CACHED) 156 - return acl; 157 - 158 151 switch (type) { 159 152 case ACL_TYPE_ACCESS: 160 153 name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS; ··· 182 189 /* 183 190 * inode->i_mutex: down 184 191 */ 185 - static int 186 - ext2_set_acl(struct inode *inode, int type, struct posix_acl *acl) 192 + int 193 + ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type) 187 194 { 188 195 int name_index; 189 196 void *value = NULL; 190 197 size_t size = 0; 191 198 int error; 192 - 193 - if (S_ISLNK(inode->i_mode)) 194 - return -EOPNOTSUPP; 195 - if (!test_opt(inode->i_sb, POSIX_ACL)) 196 - return 0; 197 199 198 200 switch(type) { 199 201 case ACL_TYPE_ACCESS: ··· 238 250 int 239 251 ext2_init_acl(struct inode *inode, struct inode *dir) 240 252 { 241 - struct posix_acl *acl = NULL; 242 - int error = 0; 253 + struct posix_acl *default_acl, *acl; 254 + int error; 243 255 244 - if (!S_ISLNK(inode->i_mode)) { 245 - if (test_opt(dir->i_sb, POSIX_ACL)) { 246 - acl = ext2_get_acl(dir, ACL_TYPE_DEFAULT); 247 - if (IS_ERR(acl)) 248 - return PTR_ERR(acl); 249 - } 250 - if (!acl) 251 - inode->i_mode &= ~current_umask(); 252 - } 253 - if (test_opt(inode->i_sb, POSIX_ACL) && acl) { 254 - if (S_ISDIR(inode->i_mode)) { 255 - error = ext2_set_acl(inode, ACL_TYPE_DEFAULT, acl); 256 - if (error) 257 - goto cleanup; 258 - } 259 - error = posix_acl_create(&acl, GFP_KERNEL, &inode->i_mode); 260 - if (error < 0) 261 - return error; 262 - if (error > 0) { 263 - /* This is an extended ACL */ 264 - error = ext2_set_acl(inode, ACL_TYPE_ACCESS, acl); 265 - } 266 - } 267 - cleanup: 268 - posix_acl_release(acl); 269 - return error; 270 - } 271 - 272 - /* 273 - * Does chmod for an inode that may have an Access Control List. The 274 - * inode->i_mode field must be updated to the desired value by the caller 275 - * before calling this function. 276 - * Returns 0 on success, or a negative error number. 277 - * 278 - * We change the ACL rather than storing some ACL entries in the file 279 - * mode permission bits (which would be more efficient), because that 280 - * would break once additional permissions (like ACL_APPEND, ACL_DELETE 281 - * for directories) are added. There are no more bits available in the 282 - * file mode. 283 - * 284 - * inode->i_mutex: down 285 - */ 286 - int 287 - ext2_acl_chmod(struct inode *inode) 288 - { 289 - struct posix_acl *acl; 290 - int error; 291 - 292 - if (!test_opt(inode->i_sb, POSIX_ACL)) 293 - return 0; 294 - if (S_ISLNK(inode->i_mode)) 295 - return -EOPNOTSUPP; 296 - acl = ext2_get_acl(inode, ACL_TYPE_ACCESS); 297 - if (IS_ERR(acl) || !acl) 298 - return PTR_ERR(acl); 299 - error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode); 256 + error = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl); 300 257 if (error) 301 258 return error; 302 - error = ext2_set_acl(inode, ACL_TYPE_ACCESS, acl); 303 - posix_acl_release(acl); 259 + 260 + if (default_acl) { 261 + error = ext2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); 262 + posix_acl_release(default_acl); 263 + } 264 + if (acl) { 265 + if (!error) 266 + error = ext2_set_acl(inode, acl, ACL_TYPE_ACCESS); 267 + posix_acl_release(acl); 268 + } 304 269 return error; 305 270 } 306 - 307 - /* 308 - * Extended attribut handlers 309 - */ 310 - static size_t 311 - ext2_xattr_list_acl_access(struct dentry *dentry, char *list, size_t list_size, 312 - const char *name, size_t name_len, int type) 313 - { 314 - const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); 315 - 316 - if (!test_opt(dentry->d_sb, POSIX_ACL)) 317 - return 0; 318 - if (list && size <= list_size) 319 - memcpy(list, POSIX_ACL_XATTR_ACCESS, size); 320 - return size; 321 - } 322 - 323 - static size_t 324 - ext2_xattr_list_acl_default(struct dentry *dentry, char *list, size_t list_size, 325 - const char *name, size_t name_len, int type) 326 - { 327 - const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); 328 - 329 - if (!test_opt(dentry->d_sb, POSIX_ACL)) 330 - return 0; 331 - if (list && size <= list_size) 332 - memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); 333 - return size; 334 - } 335 - 336 - static int 337 - ext2_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer, 338 - size_t size, int type) 339 - { 340 - struct posix_acl *acl; 341 - int error; 342 - 343 - if (strcmp(name, "") != 0) 344 - return -EINVAL; 345 - if (!test_opt(dentry->d_sb, POSIX_ACL)) 346 - return -EOPNOTSUPP; 347 - 348 - acl = ext2_get_acl(dentry->d_inode, type); 349 - if (IS_ERR(acl)) 350 - return PTR_ERR(acl); 351 - if (acl == NULL) 352 - return -ENODATA; 353 - error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size); 354 - posix_acl_release(acl); 355 - 356 - return error; 357 - } 358 - 359 - static int 360 - ext2_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, 361 - size_t size, int flags, int type) 362 - { 363 - struct posix_acl *acl; 364 - int error; 365 - 366 - if (strcmp(name, "") != 0) 367 - return -EINVAL; 368 - if (!test_opt(dentry->d_sb, POSIX_ACL)) 369 - return -EOPNOTSUPP; 370 - if (!inode_owner_or_capable(dentry->d_inode)) 371 - return -EPERM; 372 - 373 - if (value) { 374 - acl = posix_acl_from_xattr(&init_user_ns, value, size); 375 - if (IS_ERR(acl)) 376 - return PTR_ERR(acl); 377 - else if (acl) { 378 - error = posix_acl_valid(acl); 379 - if (error) 380 - goto release_and_out; 381 - } 382 - } else 383 - acl = NULL; 384 - 385 - error = ext2_set_acl(dentry->d_inode, type, acl); 386 - 387 - release_and_out: 388 - posix_acl_release(acl); 389 - return error; 390 - } 391 - 392 - const struct xattr_handler ext2_xattr_acl_access_handler = { 393 - .prefix = POSIX_ACL_XATTR_ACCESS, 394 - .flags = ACL_TYPE_ACCESS, 395 - .list = ext2_xattr_list_acl_access, 396 - .get = ext2_xattr_get_acl, 397 - .set = ext2_xattr_set_acl, 398 - }; 399 - 400 - const struct xattr_handler ext2_xattr_acl_default_handler = { 401 - .prefix = POSIX_ACL_XATTR_DEFAULT, 402 - .flags = ACL_TYPE_DEFAULT, 403 - .list = ext2_xattr_list_acl_default, 404 - .get = ext2_xattr_get_acl, 405 - .set = ext2_xattr_set_acl, 406 - };
+1 -7
fs/ext2/acl.h
··· 55 55 56 56 /* acl.c */ 57 57 extern struct posix_acl *ext2_get_acl(struct inode *inode, int type); 58 - extern int ext2_acl_chmod (struct inode *); 58 + extern int ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type); 59 59 extern int ext2_init_acl (struct inode *, struct inode *); 60 60 61 61 #else 62 62 #include <linux/sched.h> 63 63 #define ext2_get_acl NULL 64 64 #define ext2_set_acl NULL 65 - 66 - static inline int 67 - ext2_acl_chmod (struct inode *inode) 68 - { 69 - return 0; 70 - } 71 65 72 66 static inline int ext2_init_acl (struct inode *inode, struct inode *dir) 73 67 {
+1
fs/ext2/file.c
··· 103 103 #endif 104 104 .setattr = ext2_setattr, 105 105 .get_acl = ext2_get_acl, 106 + .set_acl = ext2_set_acl, 106 107 .fiemap = ext2_fiemap, 107 108 };
+1 -1
fs/ext2/inode.c
··· 1566 1566 } 1567 1567 setattr_copy(inode, iattr); 1568 1568 if (iattr->ia_valid & ATTR_MODE) 1569 - error = ext2_acl_chmod(inode); 1569 + error = posix_acl_chmod(inode, inode->i_mode); 1570 1570 mark_inode_dirty(inode); 1571 1571 1572 1572 return error;
+2
fs/ext2/namei.c
··· 421 421 #endif 422 422 .setattr = ext2_setattr, 423 423 .get_acl = ext2_get_acl, 424 + .set_acl = ext2_set_acl, 424 425 .tmpfile = ext2_tmpfile, 425 426 }; 426 427 ··· 434 433 #endif 435 434 .setattr = ext2_setattr, 436 435 .get_acl = ext2_get_acl, 436 + .set_acl = ext2_set_acl, 437 437 };
+4 -4
fs/ext2/xattr.c
··· 103 103 static const struct xattr_handler *ext2_xattr_handler_map[] = { 104 104 [EXT2_XATTR_INDEX_USER] = &ext2_xattr_user_handler, 105 105 #ifdef CONFIG_EXT2_FS_POSIX_ACL 106 - [EXT2_XATTR_INDEX_POSIX_ACL_ACCESS] = &ext2_xattr_acl_access_handler, 107 - [EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT] = &ext2_xattr_acl_default_handler, 106 + [EXT2_XATTR_INDEX_POSIX_ACL_ACCESS] = &posix_acl_access_xattr_handler, 107 + [EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT] = &posix_acl_default_xattr_handler, 108 108 #endif 109 109 [EXT2_XATTR_INDEX_TRUSTED] = &ext2_xattr_trusted_handler, 110 110 #ifdef CONFIG_EXT2_FS_SECURITY ··· 116 116 &ext2_xattr_user_handler, 117 117 &ext2_xattr_trusted_handler, 118 118 #ifdef CONFIG_EXT2_FS_POSIX_ACL 119 - &ext2_xattr_acl_access_handler, 120 - &ext2_xattr_acl_default_handler, 119 + &posix_acl_access_xattr_handler, 120 + &posix_acl_default_xattr_handler, 121 121 #endif 122 122 #ifdef CONFIG_EXT2_FS_SECURITY 123 123 &ext2_xattr_security_handler,
-2
fs/ext2/xattr.h
··· 57 57 58 58 extern const struct xattr_handler ext2_xattr_user_handler; 59 59 extern const struct xattr_handler ext2_xattr_trusted_handler; 60 - extern const struct xattr_handler ext2_xattr_acl_access_handler; 61 - extern const struct xattr_handler ext2_xattr_acl_default_handler; 62 60 extern const struct xattr_handler ext2_xattr_security_handler; 63 61 64 62 extern ssize_t ext2_listxattr(struct dentry *, char *, size_t);
+33 -198
fs/ext3/acl.c
··· 145 145 struct posix_acl *acl; 146 146 int retval; 147 147 148 - if (!test_opt(inode->i_sb, POSIX_ACL)) 149 - return NULL; 150 - 151 - acl = get_cached_acl(inode, type); 152 - if (acl != ACL_NOT_CACHED) 153 - return acl; 154 - 155 148 switch (type) { 156 149 case ACL_TYPE_ACCESS: 157 150 name_index = EXT3_XATTR_INDEX_POSIX_ACL_ACCESS; ··· 183 190 * inode->i_mutex: down unless called from ext3_new_inode 184 191 */ 185 192 static int 186 - ext3_set_acl(handle_t *handle, struct inode *inode, int type, 193 + __ext3_set_acl(handle_t *handle, struct inode *inode, int type, 187 194 struct posix_acl *acl) 188 195 { 189 196 int name_index; 190 197 void *value = NULL; 191 198 size_t size = 0; 192 199 int error; 193 - 194 - if (S_ISLNK(inode->i_mode)) 195 - return -EOPNOTSUPP; 196 200 197 201 switch(type) { 198 202 case ACL_TYPE_ACCESS: ··· 233 243 return error; 234 244 } 235 245 246 + int 247 + ext3_set_acl(struct inode *inode, struct posix_acl *acl, int type) 248 + { 249 + handle_t *handle; 250 + int error, retries = 0; 251 + 252 + retry: 253 + handle = ext3_journal_start(inode, EXT3_DATA_TRANS_BLOCKS(inode->i_sb)); 254 + if (IS_ERR(handle)) 255 + return PTR_ERR(handle); 256 + error = __ext3_set_acl(handle, inode, type, acl); 257 + ext3_journal_stop(handle); 258 + if (error == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries)) 259 + goto retry; 260 + return error; 261 + } 262 + 236 263 /* 237 264 * Initialize the ACLs of a new inode. Called from ext3_new_inode. 238 265 * ··· 259 252 int 260 253 ext3_init_acl(handle_t *handle, struct inode *inode, struct inode *dir) 261 254 { 262 - struct posix_acl *acl = NULL; 263 - int error = 0; 264 - 265 - if (!S_ISLNK(inode->i_mode)) { 266 - if (test_opt(dir->i_sb, POSIX_ACL)) { 267 - acl = ext3_get_acl(dir, ACL_TYPE_DEFAULT); 268 - if (IS_ERR(acl)) 269 - return PTR_ERR(acl); 270 - } 271 - if (!acl) 272 - inode->i_mode &= ~current_umask(); 273 - } 274 - if (test_opt(inode->i_sb, POSIX_ACL) && acl) { 275 - if (S_ISDIR(inode->i_mode)) { 276 - error = ext3_set_acl(handle, inode, 277 - ACL_TYPE_DEFAULT, acl); 278 - if (error) 279 - goto cleanup; 280 - } 281 - error = posix_acl_create(&acl, GFP_NOFS, &inode->i_mode); 282 - if (error < 0) 283 - return error; 284 - 285 - if (error > 0) { 286 - /* This is an extended ACL */ 287 - error = ext3_set_acl(handle, inode, ACL_TYPE_ACCESS, acl); 288 - } 289 - } 290 - cleanup: 291 - posix_acl_release(acl); 292 - return error; 293 - } 294 - 295 - /* 296 - * Does chmod for an inode that may have an Access Control List. The 297 - * inode->i_mode field must be updated to the desired value by the caller 298 - * before calling this function. 299 - * Returns 0 on success, or a negative error number. 300 - * 301 - * We change the ACL rather than storing some ACL entries in the file 302 - * mode permission bits (which would be more efficient), because that 303 - * would break once additional permissions (like ACL_APPEND, ACL_DELETE 304 - * for directories) are added. There are no more bits available in the 305 - * file mode. 306 - * 307 - * inode->i_mutex: down 308 - */ 309 - int 310 - ext3_acl_chmod(struct inode *inode) 311 - { 312 - struct posix_acl *acl; 313 - handle_t *handle; 314 - int retries = 0; 315 - int error; 316 - 317 - if (S_ISLNK(inode->i_mode)) 318 - return -EOPNOTSUPP; 319 - if (!test_opt(inode->i_sb, POSIX_ACL)) 320 - return 0; 321 - acl = ext3_get_acl(inode, ACL_TYPE_ACCESS); 322 - if (IS_ERR(acl) || !acl) 323 - return PTR_ERR(acl); 324 - error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode); 325 - if (error) 326 - return error; 327 - retry: 328 - handle = ext3_journal_start(inode, 329 - EXT3_DATA_TRANS_BLOCKS(inode->i_sb)); 330 - if (IS_ERR(handle)) { 331 - error = PTR_ERR(handle); 332 - ext3_std_error(inode->i_sb, error); 333 - goto out; 334 - } 335 - error = ext3_set_acl(handle, inode, ACL_TYPE_ACCESS, acl); 336 - ext3_journal_stop(handle); 337 - if (error == -ENOSPC && 338 - ext3_should_retry_alloc(inode->i_sb, &retries)) 339 - goto retry; 340 - out: 341 - posix_acl_release(acl); 342 - return error; 343 - } 344 - 345 - /* 346 - * Extended attribute handlers 347 - */ 348 - static size_t 349 - ext3_xattr_list_acl_access(struct dentry *dentry, char *list, size_t list_len, 350 - const char *name, size_t name_len, int type) 351 - { 352 - const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); 353 - 354 - if (!test_opt(dentry->d_sb, POSIX_ACL)) 355 - return 0; 356 - if (list && size <= list_len) 357 - memcpy(list, POSIX_ACL_XATTR_ACCESS, size); 358 - return size; 359 - } 360 - 361 - static size_t 362 - ext3_xattr_list_acl_default(struct dentry *dentry, char *list, size_t list_len, 363 - const char *name, size_t name_len, int type) 364 - { 365 - const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); 366 - 367 - if (!test_opt(dentry->d_sb, POSIX_ACL)) 368 - return 0; 369 - if (list && size <= list_len) 370 - memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); 371 - return size; 372 - } 373 - 374 - static int 375 - ext3_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer, 376 - size_t size, int type) 377 - { 378 - struct posix_acl *acl; 255 + struct posix_acl *default_acl, *acl; 379 256 int error; 380 257 381 - if (strcmp(name, "") != 0) 382 - return -EINVAL; 383 - if (!test_opt(dentry->d_sb, POSIX_ACL)) 384 - return -EOPNOTSUPP; 258 + error = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl); 259 + if (error) 260 + return error; 385 261 386 - acl = ext3_get_acl(dentry->d_inode, type); 387 - if (IS_ERR(acl)) 388 - return PTR_ERR(acl); 389 - if (acl == NULL) 390 - return -ENODATA; 391 - error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size); 392 - posix_acl_release(acl); 393 - 262 + if (default_acl) { 263 + error = __ext3_set_acl(handle, inode, ACL_TYPE_DEFAULT, 264 + default_acl); 265 + posix_acl_release(default_acl); 266 + } 267 + if (acl) { 268 + if (!error) 269 + error = __ext3_set_acl(handle, inode, ACL_TYPE_ACCESS, 270 + acl); 271 + posix_acl_release(acl); 272 + } 394 273 return error; 395 274 } 396 - 397 - static int 398 - ext3_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, 399 - size_t size, int flags, int type) 400 - { 401 - struct inode *inode = dentry->d_inode; 402 - handle_t *handle; 403 - struct posix_acl *acl; 404 - int error, retries = 0; 405 - 406 - if (strcmp(name, "") != 0) 407 - return -EINVAL; 408 - if (!test_opt(inode->i_sb, POSIX_ACL)) 409 - return -EOPNOTSUPP; 410 - if (!inode_owner_or_capable(inode)) 411 - return -EPERM; 412 - 413 - if (value) { 414 - acl = posix_acl_from_xattr(&init_user_ns, value, size); 415 - if (IS_ERR(acl)) 416 - return PTR_ERR(acl); 417 - else if (acl) { 418 - error = posix_acl_valid(acl); 419 - if (error) 420 - goto release_and_out; 421 - } 422 - } else 423 - acl = NULL; 424 - 425 - retry: 426 - handle = ext3_journal_start(inode, EXT3_DATA_TRANS_BLOCKS(inode->i_sb)); 427 - if (IS_ERR(handle)) 428 - return PTR_ERR(handle); 429 - error = ext3_set_acl(handle, inode, type, acl); 430 - ext3_journal_stop(handle); 431 - if (error == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries)) 432 - goto retry; 433 - 434 - release_and_out: 435 - posix_acl_release(acl); 436 - return error; 437 - } 438 - 439 - const struct xattr_handler ext3_xattr_acl_access_handler = { 440 - .prefix = POSIX_ACL_XATTR_ACCESS, 441 - .flags = ACL_TYPE_ACCESS, 442 - .list = ext3_xattr_list_acl_access, 443 - .get = ext3_xattr_get_acl, 444 - .set = ext3_xattr_set_acl, 445 - }; 446 - 447 - const struct xattr_handler ext3_xattr_acl_default_handler = { 448 - .prefix = POSIX_ACL_XATTR_DEFAULT, 449 - .flags = ACL_TYPE_DEFAULT, 450 - .list = ext3_xattr_list_acl_default, 451 - .get = ext3_xattr_get_acl, 452 - .set = ext3_xattr_set_acl, 453 - };
+2 -7
fs/ext3/acl.h
··· 55 55 56 56 /* acl.c */ 57 57 extern struct posix_acl *ext3_get_acl(struct inode *inode, int type); 58 - extern int ext3_acl_chmod (struct inode *); 58 + extern int ext3_set_acl(struct inode *inode, struct posix_acl *acl, int type); 59 59 extern int ext3_init_acl (handle_t *, struct inode *, struct inode *); 60 60 61 61 #else /* CONFIG_EXT3_FS_POSIX_ACL */ 62 62 #include <linux/sched.h> 63 63 #define ext3_get_acl NULL 64 - 65 - static inline int 66 - ext3_acl_chmod(struct inode *inode) 67 - { 68 - return 0; 69 - } 64 + #define ext3_set_acl NULL 70 65 71 66 static inline int 72 67 ext3_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
+1
fs/ext3/file.c
··· 75 75 .removexattr = generic_removexattr, 76 76 #endif 77 77 .get_acl = ext3_get_acl, 78 + .set_acl = ext3_set_acl, 78 79 .fiemap = ext3_fiemap, 79 80 }; 80 81
+1 -1
fs/ext3/inode.c
··· 3365 3365 mark_inode_dirty(inode); 3366 3366 3367 3367 if (ia_valid & ATTR_MODE) 3368 - rc = ext3_acl_chmod(inode); 3368 + rc = posix_acl_chmod(inode, inode->i_mode); 3369 3369 3370 3370 err_out: 3371 3371 ext3_std_error(inode->i_sb, error);
+2
fs/ext3/namei.c
··· 2569 2569 .removexattr = generic_removexattr, 2570 2570 #endif 2571 2571 .get_acl = ext3_get_acl, 2572 + .set_acl = ext3_set_acl, 2572 2573 }; 2573 2574 2574 2575 const struct inode_operations ext3_special_inode_operations = { ··· 2581 2580 .removexattr = generic_removexattr, 2582 2581 #endif 2583 2582 .get_acl = ext3_get_acl, 2583 + .set_acl = ext3_set_acl, 2584 2584 };
+4 -4
fs/ext3/xattr.c
··· 102 102 static const struct xattr_handler *ext3_xattr_handler_map[] = { 103 103 [EXT3_XATTR_INDEX_USER] = &ext3_xattr_user_handler, 104 104 #ifdef CONFIG_EXT3_FS_POSIX_ACL 105 - [EXT3_XATTR_INDEX_POSIX_ACL_ACCESS] = &ext3_xattr_acl_access_handler, 106 - [EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT] = &ext3_xattr_acl_default_handler, 105 + [EXT3_XATTR_INDEX_POSIX_ACL_ACCESS] = &posix_acl_access_xattr_handler, 106 + [EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT] = &posix_acl_default_xattr_handler, 107 107 #endif 108 108 [EXT3_XATTR_INDEX_TRUSTED] = &ext3_xattr_trusted_handler, 109 109 #ifdef CONFIG_EXT3_FS_SECURITY ··· 115 115 &ext3_xattr_user_handler, 116 116 &ext3_xattr_trusted_handler, 117 117 #ifdef CONFIG_EXT3_FS_POSIX_ACL 118 - &ext3_xattr_acl_access_handler, 119 - &ext3_xattr_acl_default_handler, 118 + &posix_acl_access_xattr_handler, 119 + &posix_acl_default_xattr_handler, 120 120 #endif 121 121 #ifdef CONFIG_EXT3_FS_SECURITY 122 122 &ext3_xattr_security_handler,
-2
fs/ext3/xattr.h
··· 60 60 61 61 extern const struct xattr_handler ext3_xattr_user_handler; 62 62 extern const struct xattr_handler ext3_xattr_trusted_handler; 63 - extern const struct xattr_handler ext3_xattr_acl_access_handler; 64 - extern const struct xattr_handler ext3_xattr_acl_default_handler; 65 63 extern const struct xattr_handler ext3_xattr_security_handler; 66 64 67 65 extern ssize_t ext3_listxattr(struct dentry *, char *, size_t);
+32 -199
fs/ext4/acl.c
··· 152 152 struct posix_acl *acl; 153 153 int retval; 154 154 155 - if (!test_opt(inode->i_sb, POSIX_ACL)) 156 - return NULL; 157 - 158 - acl = get_cached_acl(inode, type); 159 - if (acl != ACL_NOT_CACHED) 160 - return acl; 161 - 162 155 switch (type) { 163 156 case ACL_TYPE_ACCESS: 164 157 name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS; ··· 189 196 * inode->i_mutex: down unless called from ext4_new_inode 190 197 */ 191 198 static int 192 - ext4_set_acl(handle_t *handle, struct inode *inode, int type, 199 + __ext4_set_acl(handle_t *handle, struct inode *inode, int type, 193 200 struct posix_acl *acl) 194 201 { 195 202 int name_index; 196 203 void *value = NULL; 197 204 size_t size = 0; 198 205 int error; 199 - 200 - if (S_ISLNK(inode->i_mode)) 201 - return -EOPNOTSUPP; 202 206 203 207 switch (type) { 204 208 case ACL_TYPE_ACCESS: ··· 238 248 return error; 239 249 } 240 250 251 + int 252 + ext4_set_acl(struct inode *inode, struct posix_acl *acl, int type) 253 + { 254 + handle_t *handle; 255 + int error, retries = 0; 256 + 257 + retry: 258 + handle = ext4_journal_start(inode, EXT4_HT_XATTR, 259 + ext4_jbd2_credits_xattr(inode)); 260 + if (IS_ERR(handle)) 261 + return PTR_ERR(handle); 262 + 263 + error = __ext4_set_acl(handle, inode, type, acl); 264 + ext4_journal_stop(handle); 265 + if (error == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) 266 + goto retry; 267 + return error; 268 + } 269 + 241 270 /* 242 271 * Initialize the ACLs of a new inode. Called from ext4_new_inode. 243 272 * ··· 266 257 int 267 258 ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir) 268 259 { 269 - struct posix_acl *acl = NULL; 270 - int error = 0; 271 - 272 - if (!S_ISLNK(inode->i_mode)) { 273 - if (test_opt(dir->i_sb, POSIX_ACL)) { 274 - acl = ext4_get_acl(dir, ACL_TYPE_DEFAULT); 275 - if (IS_ERR(acl)) 276 - return PTR_ERR(acl); 277 - } 278 - if (!acl) 279 - inode->i_mode &= ~current_umask(); 280 - } 281 - if (test_opt(inode->i_sb, POSIX_ACL) && acl) { 282 - if (S_ISDIR(inode->i_mode)) { 283 - error = ext4_set_acl(handle, inode, 284 - ACL_TYPE_DEFAULT, acl); 285 - if (error) 286 - goto cleanup; 287 - } 288 - error = posix_acl_create(&acl, GFP_NOFS, &inode->i_mode); 289 - if (error < 0) 290 - return error; 291 - 292 - if (error > 0) { 293 - /* This is an extended ACL */ 294 - error = ext4_set_acl(handle, inode, ACL_TYPE_ACCESS, acl); 295 - } 296 - } 297 - cleanup: 298 - posix_acl_release(acl); 299 - return error; 300 - } 301 - 302 - /* 303 - * Does chmod for an inode that may have an Access Control List. The 304 - * inode->i_mode field must be updated to the desired value by the caller 305 - * before calling this function. 306 - * Returns 0 on success, or a negative error number. 307 - * 308 - * We change the ACL rather than storing some ACL entries in the file 309 - * mode permission bits (which would be more efficient), because that 310 - * would break once additional permissions (like ACL_APPEND, ACL_DELETE 311 - * for directories) are added. There are no more bits available in the 312 - * file mode. 313 - * 314 - * inode->i_mutex: down 315 - */ 316 - int 317 - ext4_acl_chmod(struct inode *inode) 318 - { 319 - struct posix_acl *acl; 320 - handle_t *handle; 321 - int retries = 0; 260 + struct posix_acl *default_acl, *acl; 322 261 int error; 323 262 324 - 325 - if (S_ISLNK(inode->i_mode)) 326 - return -EOPNOTSUPP; 327 - if (!test_opt(inode->i_sb, POSIX_ACL)) 328 - return 0; 329 - acl = ext4_get_acl(inode, ACL_TYPE_ACCESS); 330 - if (IS_ERR(acl) || !acl) 331 - return PTR_ERR(acl); 332 - error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode); 263 + error = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl); 333 264 if (error) 334 265 return error; 335 - retry: 336 - handle = ext4_journal_start(inode, EXT4_HT_XATTR, 337 - ext4_jbd2_credits_xattr(inode)); 338 - if (IS_ERR(handle)) { 339 - error = PTR_ERR(handle); 340 - ext4_std_error(inode->i_sb, error); 341 - goto out; 266 + 267 + if (default_acl) { 268 + error = __ext4_set_acl(handle, inode, ACL_TYPE_DEFAULT, 269 + default_acl); 270 + posix_acl_release(default_acl); 342 271 } 343 - error = ext4_set_acl(handle, inode, ACL_TYPE_ACCESS, acl); 344 - ext4_journal_stop(handle); 345 - if (error == -ENOSPC && 346 - ext4_should_retry_alloc(inode->i_sb, &retries)) 347 - goto retry; 348 - out: 349 - posix_acl_release(acl); 350 - return error; 351 - } 352 - 353 - /* 354 - * Extended attribute handlers 355 - */ 356 - static size_t 357 - ext4_xattr_list_acl_access(struct dentry *dentry, char *list, size_t list_len, 358 - const char *name, size_t name_len, int type) 359 - { 360 - const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); 361 - 362 - if (!test_opt(dentry->d_sb, POSIX_ACL)) 363 - return 0; 364 - if (list && size <= list_len) 365 - memcpy(list, POSIX_ACL_XATTR_ACCESS, size); 366 - return size; 367 - } 368 - 369 - static size_t 370 - ext4_xattr_list_acl_default(struct dentry *dentry, char *list, size_t list_len, 371 - const char *name, size_t name_len, int type) 372 - { 373 - const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); 374 - 375 - if (!test_opt(dentry->d_sb, POSIX_ACL)) 376 - return 0; 377 - if (list && size <= list_len) 378 - memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); 379 - return size; 380 - } 381 - 382 - static int 383 - ext4_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer, 384 - size_t size, int type) 385 - { 386 - struct posix_acl *acl; 387 - int error; 388 - 389 - if (strcmp(name, "") != 0) 390 - return -EINVAL; 391 - if (!test_opt(dentry->d_sb, POSIX_ACL)) 392 - return -EOPNOTSUPP; 393 - 394 - acl = ext4_get_acl(dentry->d_inode, type); 395 - if (IS_ERR(acl)) 396 - return PTR_ERR(acl); 397 - if (acl == NULL) 398 - return -ENODATA; 399 - error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size); 400 - posix_acl_release(acl); 401 - 402 - return error; 403 - } 404 - 405 - static int 406 - ext4_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, 407 - size_t size, int flags, int type) 408 - { 409 - struct inode *inode = dentry->d_inode; 410 - handle_t *handle; 411 - struct posix_acl *acl; 412 - int error, retries = 0; 413 - 414 - if (strcmp(name, "") != 0) 415 - return -EINVAL; 416 - if (!test_opt(inode->i_sb, POSIX_ACL)) 417 - return -EOPNOTSUPP; 418 - if (!inode_owner_or_capable(inode)) 419 - return -EPERM; 420 - 421 - if (value) { 422 - acl = posix_acl_from_xattr(&init_user_ns, value, size); 423 - if (IS_ERR(acl)) 424 - return PTR_ERR(acl); 425 - else if (acl) { 426 - error = posix_acl_valid(acl); 427 - if (error) 428 - goto release_and_out; 429 - } 430 - } else 431 - acl = NULL; 432 - 433 - retry: 434 - handle = ext4_journal_start(inode, EXT4_HT_XATTR, 435 - ext4_jbd2_credits_xattr(inode)); 436 - if (IS_ERR(handle)) { 437 - error = PTR_ERR(handle); 438 - goto release_and_out; 272 + if (acl) { 273 + if (!error) 274 + error = __ext4_set_acl(handle, inode, ACL_TYPE_ACCESS, 275 + acl); 276 + posix_acl_release(acl); 439 277 } 440 - error = ext4_set_acl(handle, inode, type, acl); 441 - ext4_journal_stop(handle); 442 - if (error == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) 443 - goto retry; 444 - 445 - release_and_out: 446 - posix_acl_release(acl); 447 278 return error; 448 279 } 449 - 450 - const struct xattr_handler ext4_xattr_acl_access_handler = { 451 - .prefix = POSIX_ACL_XATTR_ACCESS, 452 - .flags = ACL_TYPE_ACCESS, 453 - .list = ext4_xattr_list_acl_access, 454 - .get = ext4_xattr_get_acl, 455 - .set = ext4_xattr_set_acl, 456 - }; 457 - 458 - const struct xattr_handler ext4_xattr_acl_default_handler = { 459 - .prefix = POSIX_ACL_XATTR_DEFAULT, 460 - .flags = ACL_TYPE_DEFAULT, 461 - .list = ext4_xattr_list_acl_default, 462 - .get = ext4_xattr_get_acl, 463 - .set = ext4_xattr_set_acl, 464 - };
+2 -7
fs/ext4/acl.h
··· 55 55 56 56 /* acl.c */ 57 57 struct posix_acl *ext4_get_acl(struct inode *inode, int type); 58 - extern int ext4_acl_chmod(struct inode *); 58 + int ext4_set_acl(struct inode *inode, struct posix_acl *acl, int type); 59 59 extern int ext4_init_acl(handle_t *, struct inode *, struct inode *); 60 60 61 61 #else /* CONFIG_EXT4_FS_POSIX_ACL */ 62 62 #include <linux/sched.h> 63 63 #define ext4_get_acl NULL 64 - 65 - static inline int 66 - ext4_acl_chmod(struct inode *inode) 67 - { 68 - return 0; 69 - } 64 + #define ext4_set_acl NULL 70 65 71 66 static inline int 72 67 ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
+1
fs/ext4/file.c
··· 617 617 .listxattr = ext4_listxattr, 618 618 .removexattr = generic_removexattr, 619 619 .get_acl = ext4_get_acl, 620 + .set_acl = ext4_set_acl, 620 621 .fiemap = ext4_fiemap, 621 622 }; 622 623
+1 -1
fs/ext4/inode.c
··· 4667 4667 ext4_orphan_del(NULL, inode); 4668 4668 4669 4669 if (!rc && (ia_valid & ATTR_MODE)) 4670 - rc = ext4_acl_chmod(inode); 4670 + rc = posix_acl_chmod(inode, inode->i_mode); 4671 4671 4672 4672 err_out: 4673 4673 ext4_std_error(inode->i_sb, error);
+2
fs/ext4/namei.c
··· 3225 3225 .listxattr = ext4_listxattr, 3226 3226 .removexattr = generic_removexattr, 3227 3227 .get_acl = ext4_get_acl, 3228 + .set_acl = ext4_set_acl, 3228 3229 .fiemap = ext4_fiemap, 3229 3230 }; 3230 3231 ··· 3236 3235 .listxattr = ext4_listxattr, 3237 3236 .removexattr = generic_removexattr, 3238 3237 .get_acl = ext4_get_acl, 3238 + .set_acl = ext4_set_acl, 3239 3239 };
+4 -4
fs/ext4/xattr.c
··· 95 95 static const struct xattr_handler *ext4_xattr_handler_map[] = { 96 96 [EXT4_XATTR_INDEX_USER] = &ext4_xattr_user_handler, 97 97 #ifdef CONFIG_EXT4_FS_POSIX_ACL 98 - [EXT4_XATTR_INDEX_POSIX_ACL_ACCESS] = &ext4_xattr_acl_access_handler, 99 - [EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT] = &ext4_xattr_acl_default_handler, 98 + [EXT4_XATTR_INDEX_POSIX_ACL_ACCESS] = &posix_acl_access_xattr_handler, 99 + [EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT] = &posix_acl_default_xattr_handler, 100 100 #endif 101 101 [EXT4_XATTR_INDEX_TRUSTED] = &ext4_xattr_trusted_handler, 102 102 #ifdef CONFIG_EXT4_FS_SECURITY ··· 108 108 &ext4_xattr_user_handler, 109 109 &ext4_xattr_trusted_handler, 110 110 #ifdef CONFIG_EXT4_FS_POSIX_ACL 111 - &ext4_xattr_acl_access_handler, 112 - &ext4_xattr_acl_default_handler, 111 + &posix_acl_access_xattr_handler, 112 + &posix_acl_default_xattr_handler, 113 113 #endif 114 114 #ifdef CONFIG_EXT4_FS_SECURITY 115 115 &ext4_xattr_security_handler,
-2
fs/ext4/xattr.h
··· 96 96 97 97 extern const struct xattr_handler ext4_xattr_user_handler; 98 98 extern const struct xattr_handler ext4_xattr_trusted_handler; 99 - extern const struct xattr_handler ext4_xattr_acl_access_handler; 100 - extern const struct xattr_handler ext4_xattr_acl_default_handler; 101 99 extern const struct xattr_handler ext4_xattr_security_handler; 102 100 103 101 extern ssize_t ext4_listxattr(struct dentry *, char *, size_t);
+17 -157
fs/f2fs/acl.c
··· 17 17 #include "xattr.h" 18 18 #include "acl.h" 19 19 20 - #define get_inode_mode(i) ((is_inode_flag_set(F2FS_I(i), FI_ACL_MODE)) ? \ 21 - (F2FS_I(i)->i_acl_mode) : ((i)->i_mode)) 22 - 23 20 static inline size_t f2fs_acl_size(int count) 24 21 { 25 22 if (count <= 4) { ··· 164 167 165 168 struct posix_acl *f2fs_get_acl(struct inode *inode, int type) 166 169 { 167 - struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 168 170 int name_index = F2FS_XATTR_INDEX_POSIX_ACL_DEFAULT; 169 171 void *value = NULL; 170 172 struct posix_acl *acl; 171 173 int retval; 172 - 173 - if (!test_opt(sbi, POSIX_ACL)) 174 - return NULL; 175 - 176 - acl = get_cached_acl(inode, type); 177 - if (acl != ACL_NOT_CACHED) 178 - return acl; 179 174 180 175 if (type == ACL_TYPE_ACCESS) 181 176 name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS; ··· 194 205 return acl; 195 206 } 196 207 197 - static int f2fs_set_acl(struct inode *inode, int type, 208 + static int __f2fs_set_acl(struct inode *inode, int type, 198 209 struct posix_acl *acl, struct page *ipage) 199 210 { 200 - struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 201 211 struct f2fs_inode_info *fi = F2FS_I(inode); 202 212 int name_index; 203 213 void *value = NULL; 204 214 size_t size = 0; 205 215 int error; 206 - 207 - if (!test_opt(sbi, POSIX_ACL)) 208 - return 0; 209 - if (S_ISLNK(inode->i_mode)) 210 - return -EOPNOTSUPP; 211 216 212 217 switch (type) { 213 218 case ACL_TYPE_ACCESS: ··· 244 261 return error; 245 262 } 246 263 247 - int f2fs_init_acl(struct inode *inode, struct inode *dir, struct page *ipage) 264 + int f2fs_set_acl(struct inode *inode, struct posix_acl *acl, int type) 248 265 { 249 - struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); 250 - struct posix_acl *acl = NULL; 251 - int error = 0; 252 - 253 - if (!S_ISLNK(inode->i_mode)) { 254 - if (test_opt(sbi, POSIX_ACL)) { 255 - acl = f2fs_get_acl(dir, ACL_TYPE_DEFAULT); 256 - if (IS_ERR(acl)) 257 - return PTR_ERR(acl); 258 - } 259 - if (!acl) 260 - inode->i_mode &= ~current_umask(); 261 - } 262 - 263 - if (!test_opt(sbi, POSIX_ACL) || !acl) 264 - goto cleanup; 265 - 266 - if (S_ISDIR(inode->i_mode)) { 267 - error = f2fs_set_acl(inode, ACL_TYPE_DEFAULT, acl, ipage); 268 - if (error) 269 - goto cleanup; 270 - } 271 - error = posix_acl_create(&acl, GFP_KERNEL, &inode->i_mode); 272 - if (error < 0) 273 - return error; 274 - if (error > 0) 275 - error = f2fs_set_acl(inode, ACL_TYPE_ACCESS, acl, ipage); 276 - cleanup: 277 - posix_acl_release(acl); 278 - return error; 266 + return __f2fs_set_acl(inode, type, acl, NULL); 279 267 } 280 268 281 - int f2fs_acl_chmod(struct inode *inode) 269 + int f2fs_init_acl(struct inode *inode, struct inode *dir, struct page *ipage) 282 270 { 283 - struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 284 - struct posix_acl *acl; 285 - int error; 286 - umode_t mode = get_inode_mode(inode); 271 + struct posix_acl *default_acl, *acl; 272 + int error = 0; 287 273 288 - if (!test_opt(sbi, POSIX_ACL)) 289 - return 0; 290 - if (S_ISLNK(mode)) 291 - return -EOPNOTSUPP; 292 - 293 - acl = f2fs_get_acl(inode, ACL_TYPE_ACCESS); 294 - if (IS_ERR(acl) || !acl) 295 - return PTR_ERR(acl); 296 - 297 - error = posix_acl_chmod(&acl, GFP_KERNEL, mode); 274 + error = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl); 298 275 if (error) 299 276 return error; 300 277 301 - error = f2fs_set_acl(inode, ACL_TYPE_ACCESS, acl, NULL); 302 - posix_acl_release(acl); 303 - return error; 304 - } 305 - 306 - static size_t f2fs_xattr_list_acl(struct dentry *dentry, char *list, 307 - size_t list_size, const char *name, size_t name_len, int type) 308 - { 309 - struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb); 310 - const char *xname = POSIX_ACL_XATTR_DEFAULT; 311 - size_t size; 312 - 313 - if (!test_opt(sbi, POSIX_ACL)) 314 - return 0; 315 - 316 - if (type == ACL_TYPE_ACCESS) 317 - xname = POSIX_ACL_XATTR_ACCESS; 318 - 319 - size = strlen(xname) + 1; 320 - if (list && size <= list_size) 321 - memcpy(list, xname, size); 322 - return size; 323 - } 324 - 325 - static int f2fs_xattr_get_acl(struct dentry *dentry, const char *name, 326 - void *buffer, size_t size, int type) 327 - { 328 - struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb); 329 - struct posix_acl *acl; 330 - int error; 331 - 332 - if (strcmp(name, "") != 0) 333 - return -EINVAL; 334 - if (!test_opt(sbi, POSIX_ACL)) 335 - return -EOPNOTSUPP; 336 - 337 - acl = f2fs_get_acl(dentry->d_inode, type); 338 - if (IS_ERR(acl)) 339 - return PTR_ERR(acl); 340 - if (!acl) 341 - return -ENODATA; 342 - error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size); 343 - posix_acl_release(acl); 344 - 345 - return error; 346 - } 347 - 348 - static int f2fs_xattr_set_acl(struct dentry *dentry, const char *name, 349 - const void *value, size_t size, int flags, int type) 350 - { 351 - struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb); 352 - struct inode *inode = dentry->d_inode; 353 - struct posix_acl *acl = NULL; 354 - int error; 355 - 356 - if (strcmp(name, "") != 0) 357 - return -EINVAL; 358 - if (!test_opt(sbi, POSIX_ACL)) 359 - return -EOPNOTSUPP; 360 - if (!inode_owner_or_capable(inode)) 361 - return -EPERM; 362 - 363 - if (value) { 364 - acl = posix_acl_from_xattr(&init_user_ns, value, size); 365 - if (IS_ERR(acl)) 366 - return PTR_ERR(acl); 367 - if (acl) { 368 - error = posix_acl_valid(acl); 369 - if (error) 370 - goto release_and_out; 371 - } 372 - } else { 373 - acl = NULL; 278 + if (default_acl) { 279 + error = __f2fs_set_acl(inode, ACL_TYPE_DEFAULT, default_acl, 280 + ipage); 281 + posix_acl_release(default_acl); 282 + } 283 + if (acl) { 284 + if (error) 285 + error = __f2fs_set_acl(inode, ACL_TYPE_ACCESS, acl, 286 + ipage); 287 + posix_acl_release(acl); 374 288 } 375 289 376 - error = f2fs_set_acl(inode, type, acl, NULL); 377 - 378 - release_and_out: 379 - posix_acl_release(acl); 380 290 return error; 381 291 } 382 - 383 - const struct xattr_handler f2fs_xattr_acl_default_handler = { 384 - .prefix = POSIX_ACL_XATTR_DEFAULT, 385 - .flags = ACL_TYPE_DEFAULT, 386 - .list = f2fs_xattr_list_acl, 387 - .get = f2fs_xattr_get_acl, 388 - .set = f2fs_xattr_set_acl, 389 - }; 390 - 391 - const struct xattr_handler f2fs_xattr_acl_access_handler = { 392 - .prefix = POSIX_ACL_XATTR_ACCESS, 393 - .flags = ACL_TYPE_ACCESS, 394 - .list = f2fs_xattr_list_acl, 395 - .get = f2fs_xattr_get_acl, 396 - .set = f2fs_xattr_set_acl, 397 - };
+1 -6
fs/f2fs/acl.h
··· 37 37 #ifdef CONFIG_F2FS_FS_POSIX_ACL 38 38 39 39 extern struct posix_acl *f2fs_get_acl(struct inode *, int); 40 - extern int f2fs_acl_chmod(struct inode *); 40 + extern int f2fs_set_acl(struct inode *inode, struct posix_acl *acl, int type); 41 41 extern int f2fs_init_acl(struct inode *, struct inode *, struct page *); 42 42 #else 43 43 #define f2fs_check_acl NULL 44 44 #define f2fs_get_acl NULL 45 45 #define f2fs_set_acl NULL 46 - 47 - static inline int f2fs_acl_chmod(struct inode *inode) 48 - { 49 - return 0; 50 - } 51 46 52 47 static inline int f2fs_init_acl(struct inode *inode, struct inode *dir, 53 48 struct page *page)
+4
fs/f2fs/f2fs.h
··· 1023 1023 return sb->s_flags & MS_RDONLY; 1024 1024 } 1025 1025 1026 + #define get_inode_mode(i) \ 1027 + ((is_inode_flag_set(F2FS_I(i), FI_ACL_MODE)) ? \ 1028 + (F2FS_I(i)->i_acl_mode) : ((i)->i_mode)) 1029 + 1026 1030 /* 1027 1031 * file.c 1028 1032 */
+2 -1
fs/f2fs/file.c
··· 382 382 __setattr_copy(inode, attr); 383 383 384 384 if (attr->ia_valid & ATTR_MODE) { 385 - err = f2fs_acl_chmod(inode); 385 + err = posix_acl_chmod(inode, get_inode_mode(inode)); 386 386 if (err || is_inode_flag_set(fi, FI_ACL_MODE)) { 387 387 inode->i_mode = fi->i_acl_mode; 388 388 clear_inode_flag(fi, FI_ACL_MODE); ··· 397 397 .getattr = f2fs_getattr, 398 398 .setattr = f2fs_setattr, 399 399 .get_acl = f2fs_get_acl, 400 + .set_acl = f2fs_set_acl, 400 401 #ifdef CONFIG_F2FS_FS_XATTR 401 402 .setxattr = generic_setxattr, 402 403 .getxattr = generic_getxattr,
+2
fs/f2fs/namei.c
··· 501 501 .getattr = f2fs_getattr, 502 502 .setattr = f2fs_setattr, 503 503 .get_acl = f2fs_get_acl, 504 + .set_acl = f2fs_set_acl, 504 505 #ifdef CONFIG_F2FS_FS_XATTR 505 506 .setxattr = generic_setxattr, 506 507 .getxattr = generic_getxattr, ··· 528 527 .getattr = f2fs_getattr, 529 528 .setattr = f2fs_setattr, 530 529 .get_acl = f2fs_get_acl, 530 + .set_acl = f2fs_set_acl, 531 531 #ifdef CONFIG_F2FS_FS_XATTR 532 532 .setxattr = generic_setxattr, 533 533 .getxattr = generic_getxattr,
+5 -4
fs/f2fs/xattr.c
··· 21 21 #include <linux/rwsem.h> 22 22 #include <linux/f2fs_fs.h> 23 23 #include <linux/security.h> 24 + #include <linux/posix_acl_xattr.h> 24 25 #include "f2fs.h" 25 26 #include "xattr.h" 26 27 ··· 217 216 static const struct xattr_handler *f2fs_xattr_handler_map[] = { 218 217 [F2FS_XATTR_INDEX_USER] = &f2fs_xattr_user_handler, 219 218 #ifdef CONFIG_F2FS_FS_POSIX_ACL 220 - [F2FS_XATTR_INDEX_POSIX_ACL_ACCESS] = &f2fs_xattr_acl_access_handler, 221 - [F2FS_XATTR_INDEX_POSIX_ACL_DEFAULT] = &f2fs_xattr_acl_default_handler, 219 + [F2FS_XATTR_INDEX_POSIX_ACL_ACCESS] = &posix_acl_access_xattr_handler, 220 + [F2FS_XATTR_INDEX_POSIX_ACL_DEFAULT] = &posix_acl_default_xattr_handler, 222 221 #endif 223 222 [F2FS_XATTR_INDEX_TRUSTED] = &f2fs_xattr_trusted_handler, 224 223 #ifdef CONFIG_F2FS_FS_SECURITY ··· 230 229 const struct xattr_handler *f2fs_xattr_handlers[] = { 231 230 &f2fs_xattr_user_handler, 232 231 #ifdef CONFIG_F2FS_FS_POSIX_ACL 233 - &f2fs_xattr_acl_access_handler, 234 - &f2fs_xattr_acl_default_handler, 232 + &posix_acl_access_xattr_handler, 233 + &posix_acl_default_xattr_handler, 235 234 #endif 236 235 &f2fs_xattr_trusted_handler, 237 236 #ifdef CONFIG_F2FS_FS_SECURITY
-2
fs/f2fs/xattr.h
··· 108 108 #ifdef CONFIG_F2FS_FS_XATTR 109 109 extern const struct xattr_handler f2fs_xattr_user_handler; 110 110 extern const struct xattr_handler f2fs_xattr_trusted_handler; 111 - extern const struct xattr_handler f2fs_xattr_acl_access_handler; 112 - extern const struct xattr_handler f2fs_xattr_acl_default_handler; 113 111 extern const struct xattr_handler f2fs_xattr_advise_handler; 114 112 extern const struct xattr_handler f2fs_xattr_security_handler; 115 113
+29 -69
fs/file.c
··· 348 348 return NULL; 349 349 } 350 350 351 - static void close_files(struct files_struct * files) 351 + static struct fdtable *close_files(struct files_struct * files) 352 352 { 353 - int i, j; 354 - struct fdtable *fdt; 355 - 356 - j = 0; 357 - 358 353 /* 359 354 * It is safe to dereference the fd table without RCU or 360 355 * ->file_lock because this is the last reference to the 361 - * files structure. But use RCU to shut RCU-lockdep up. 356 + * files structure. 362 357 */ 363 - rcu_read_lock(); 364 - fdt = files_fdtable(files); 365 - rcu_read_unlock(); 358 + struct fdtable *fdt = rcu_dereference_raw(files->fdt); 359 + int i, j = 0; 360 + 366 361 for (;;) { 367 362 unsigned long set; 368 363 i = j * BITS_PER_LONG; ··· 376 381 set >>= 1; 377 382 } 378 383 } 384 + 385 + return fdt; 379 386 } 380 387 381 388 struct files_struct *get_files_struct(struct task_struct *task) ··· 395 398 396 399 void put_files_struct(struct files_struct *files) 397 400 { 398 - struct fdtable *fdt; 399 - 400 401 if (atomic_dec_and_test(&files->count)) { 401 - close_files(files); 402 - /* not really needed, since nobody can see us */ 403 - rcu_read_lock(); 404 - fdt = files_fdtable(files); 405 - rcu_read_unlock(); 402 + struct fdtable *fdt = close_files(files); 403 + 406 404 /* free the arrays if they are not embedded */ 407 405 if (fdt != &files->fdtab) 408 406 __free_fdtable(fdt); ··· 637 645 spin_unlock(&files->file_lock); 638 646 } 639 647 640 - struct file *fget(unsigned int fd) 648 + static struct file *__fget(unsigned int fd, fmode_t mask) 641 649 { 642 - struct file *file; 643 650 struct files_struct *files = current->files; 651 + struct file *file; 644 652 645 653 rcu_read_lock(); 646 654 file = fcheck_files(files, fd); 647 655 if (file) { 648 656 /* File object ref couldn't be taken */ 649 - if (file->f_mode & FMODE_PATH || 657 + if ((file->f_mode & mask) || 650 658 !atomic_long_inc_not_zero(&file->f_count)) 651 659 file = NULL; 652 660 } ··· 655 663 return file; 656 664 } 657 665 666 + struct file *fget(unsigned int fd) 667 + { 668 + return __fget(fd, FMODE_PATH); 669 + } 658 670 EXPORT_SYMBOL(fget); 659 671 660 672 struct file *fget_raw(unsigned int fd) 661 673 { 662 - struct file *file; 663 - struct files_struct *files = current->files; 664 - 665 - rcu_read_lock(); 666 - file = fcheck_files(files, fd); 667 - if (file) { 668 - /* File object ref couldn't be taken */ 669 - if (!atomic_long_inc_not_zero(&file->f_count)) 670 - file = NULL; 671 - } 672 - rcu_read_unlock(); 673 - 674 - return file; 674 + return __fget(fd, 0); 675 675 } 676 - 677 676 EXPORT_SYMBOL(fget_raw); 678 677 679 678 /* ··· 683 700 * The fput_needed flag returned by fget_light should be passed to the 684 701 * corresponding fput_light. 685 702 */ 686 - struct file *fget_light(unsigned int fd, int *fput_needed) 703 + struct file *__fget_light(unsigned int fd, fmode_t mask, int *fput_needed) 687 704 { 688 - struct file *file; 689 705 struct files_struct *files = current->files; 706 + struct file *file; 690 707 691 708 *fput_needed = 0; 692 709 if (atomic_read(&files->count) == 1) { 693 - file = fcheck_files(files, fd); 694 - if (file && (file->f_mode & FMODE_PATH)) 710 + file = __fcheck_files(files, fd); 711 + if (file && (file->f_mode & mask)) 695 712 file = NULL; 696 713 } else { 697 - rcu_read_lock(); 698 - file = fcheck_files(files, fd); 699 - if (file) { 700 - if (!(file->f_mode & FMODE_PATH) && 701 - atomic_long_inc_not_zero(&file->f_count)) 702 - *fput_needed = 1; 703 - else 704 - /* Didn't get the reference, someone's freed */ 705 - file = NULL; 706 - } 707 - rcu_read_unlock(); 714 + file = __fget(fd, mask); 715 + if (file) 716 + *fput_needed = 1; 708 717 } 709 718 710 719 return file; 720 + } 721 + struct file *fget_light(unsigned int fd, int *fput_needed) 722 + { 723 + return __fget_light(fd, FMODE_PATH, fput_needed); 711 724 } 712 725 EXPORT_SYMBOL(fget_light); 713 726 714 727 struct file *fget_raw_light(unsigned int fd, int *fput_needed) 715 728 { 716 - struct file *file; 717 - struct files_struct *files = current->files; 718 - 719 - *fput_needed = 0; 720 - if (atomic_read(&files->count) == 1) { 721 - file = fcheck_files(files, fd); 722 - } else { 723 - rcu_read_lock(); 724 - file = fcheck_files(files, fd); 725 - if (file) { 726 - if (atomic_long_inc_not_zero(&file->f_count)) 727 - *fput_needed = 1; 728 - else 729 - /* Didn't get the reference, someone's freed */ 730 - file = NULL; 731 - } 732 - rcu_read_unlock(); 733 - } 734 - 735 - return file; 729 + return __fget_light(fd, 0, fput_needed); 736 730 } 737 731 738 732 void set_close_on_exec(unsigned int fd, int flag)
+3
fs/fuse/file.c
··· 2727 2727 inode = file->f_mapping->host; 2728 2728 i_size = i_size_read(inode); 2729 2729 2730 + if ((rw == READ) && (offset > i_size)) 2731 + return 0; 2732 + 2730 2733 /* optimization for short read */ 2731 2734 if (async_dio && rw != WRITE && offset + count > i_size) { 2732 2735 if (offset >= i_size)
-184
fs/generic_acl.c
··· 1 - /* 2 - * (C) 2005 Andreas Gruenbacher <agruen@suse.de> 3 - * 4 - * This file is released under the GPL. 5 - * 6 - * Generic ACL support for in-memory filesystems. 7 - */ 8 - 9 - #include <linux/sched.h> 10 - #include <linux/gfp.h> 11 - #include <linux/fs.h> 12 - #include <linux/generic_acl.h> 13 - #include <linux/posix_acl.h> 14 - #include <linux/posix_acl_xattr.h> 15 - 16 - 17 - static size_t 18 - generic_acl_list(struct dentry *dentry, char *list, size_t list_size, 19 - const char *name, size_t name_len, int type) 20 - { 21 - struct posix_acl *acl; 22 - const char *xname; 23 - size_t size; 24 - 25 - acl = get_cached_acl(dentry->d_inode, type); 26 - if (!acl) 27 - return 0; 28 - posix_acl_release(acl); 29 - 30 - switch (type) { 31 - case ACL_TYPE_ACCESS: 32 - xname = POSIX_ACL_XATTR_ACCESS; 33 - break; 34 - case ACL_TYPE_DEFAULT: 35 - xname = POSIX_ACL_XATTR_DEFAULT; 36 - break; 37 - default: 38 - return 0; 39 - } 40 - size = strlen(xname) + 1; 41 - if (list && size <= list_size) 42 - memcpy(list, xname, size); 43 - return size; 44 - } 45 - 46 - static int 47 - generic_acl_get(struct dentry *dentry, const char *name, void *buffer, 48 - size_t size, int type) 49 - { 50 - struct posix_acl *acl; 51 - int error; 52 - 53 - if (strcmp(name, "") != 0) 54 - return -EINVAL; 55 - 56 - acl = get_cached_acl(dentry->d_inode, type); 57 - if (!acl) 58 - return -ENODATA; 59 - error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size); 60 - posix_acl_release(acl); 61 - 62 - return error; 63 - } 64 - 65 - static int 66 - generic_acl_set(struct dentry *dentry, const char *name, const void *value, 67 - size_t size, int flags, int type) 68 - { 69 - struct inode *inode = dentry->d_inode; 70 - struct posix_acl *acl = NULL; 71 - int error; 72 - 73 - if (strcmp(name, "") != 0) 74 - return -EINVAL; 75 - if (S_ISLNK(inode->i_mode)) 76 - return -EOPNOTSUPP; 77 - if (!inode_owner_or_capable(inode)) 78 - return -EPERM; 79 - if (value) { 80 - acl = posix_acl_from_xattr(&init_user_ns, value, size); 81 - if (IS_ERR(acl)) 82 - return PTR_ERR(acl); 83 - } 84 - if (acl) { 85 - error = posix_acl_valid(acl); 86 - if (error) 87 - goto failed; 88 - switch (type) { 89 - case ACL_TYPE_ACCESS: 90 - error = posix_acl_equiv_mode(acl, &inode->i_mode); 91 - if (error < 0) 92 - goto failed; 93 - inode->i_ctime = CURRENT_TIME; 94 - if (error == 0) { 95 - posix_acl_release(acl); 96 - acl = NULL; 97 - } 98 - break; 99 - case ACL_TYPE_DEFAULT: 100 - if (!S_ISDIR(inode->i_mode)) { 101 - error = -EINVAL; 102 - goto failed; 103 - } 104 - break; 105 - } 106 - } 107 - set_cached_acl(inode, type, acl); 108 - error = 0; 109 - failed: 110 - posix_acl_release(acl); 111 - return error; 112 - } 113 - 114 - /** 115 - * generic_acl_init - Take care of acl inheritance at @inode create time 116 - * 117 - * Files created inside a directory with a default ACL inherit the 118 - * directory's default ACL. 119 - */ 120 - int 121 - generic_acl_init(struct inode *inode, struct inode *dir) 122 - { 123 - struct posix_acl *acl = NULL; 124 - int error; 125 - 126 - if (!S_ISLNK(inode->i_mode)) 127 - acl = get_cached_acl(dir, ACL_TYPE_DEFAULT); 128 - if (acl) { 129 - if (S_ISDIR(inode->i_mode)) 130 - set_cached_acl(inode, ACL_TYPE_DEFAULT, acl); 131 - error = posix_acl_create(&acl, GFP_KERNEL, &inode->i_mode); 132 - if (error < 0) 133 - return error; 134 - if (error > 0) 135 - set_cached_acl(inode, ACL_TYPE_ACCESS, acl); 136 - } else { 137 - inode->i_mode &= ~current_umask(); 138 - } 139 - error = 0; 140 - 141 - posix_acl_release(acl); 142 - return error; 143 - } 144 - 145 - /** 146 - * generic_acl_chmod - change the access acl of @inode upon chmod() 147 - * 148 - * A chmod also changes the permissions of the owner, group/mask, and 149 - * other ACL entries. 150 - */ 151 - int 152 - generic_acl_chmod(struct inode *inode) 153 - { 154 - struct posix_acl *acl; 155 - int error = 0; 156 - 157 - if (S_ISLNK(inode->i_mode)) 158 - return -EOPNOTSUPP; 159 - acl = get_cached_acl(inode, ACL_TYPE_ACCESS); 160 - if (acl) { 161 - error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode); 162 - if (error) 163 - return error; 164 - set_cached_acl(inode, ACL_TYPE_ACCESS, acl); 165 - posix_acl_release(acl); 166 - } 167 - return error; 168 - } 169 - 170 - const struct xattr_handler generic_acl_access_handler = { 171 - .prefix = POSIX_ACL_XATTR_ACCESS, 172 - .flags = ACL_TYPE_ACCESS, 173 - .list = generic_acl_list, 174 - .get = generic_acl_get, 175 - .set = generic_acl_set, 176 - }; 177 - 178 - const struct xattr_handler generic_acl_default_handler = { 179 - .prefix = POSIX_ACL_XATTR_DEFAULT, 180 - .flags = ACL_TYPE_DEFAULT, 181 - .list = generic_acl_list, 182 - .get = generic_acl_get, 183 - .set = generic_acl_set, 184 - };
+30 -204
fs/gfs2/acl.c
··· 49 49 if (!ip->i_eattr) 50 50 return NULL; 51 51 52 - acl = get_cached_acl(&ip->i_inode, type); 53 - if (acl != ACL_NOT_CACHED) 54 - return acl; 55 - 56 52 name = gfs2_acl_name(type); 57 53 if (name == NULL) 58 54 return ERR_PTR(-EINVAL); ··· 76 80 return error; 77 81 } 78 82 79 - static int gfs2_acl_set(struct inode *inode, int type, struct posix_acl *acl) 83 + int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type) 80 84 { 81 85 int error; 82 86 int len; ··· 84 88 const char *name = gfs2_acl_name(type); 85 89 86 90 BUG_ON(name == NULL); 87 - len = posix_acl_to_xattr(&init_user_ns, acl, NULL, 0); 88 - if (len == 0) 89 - return 0; 90 - data = kmalloc(len, GFP_NOFS); 91 - if (data == NULL) 92 - return -ENOMEM; 93 - error = posix_acl_to_xattr(&init_user_ns, acl, data, len); 94 - if (error < 0) 95 - goto out; 96 - error = __gfs2_xattr_set(inode, name, data, len, 0, GFS2_EATYPE_SYS); 97 - if (!error) 98 - set_cached_acl(inode, type, acl); 99 - out: 100 - kfree(data); 101 - return error; 102 - } 103 91 104 - int gfs2_acl_create(struct gfs2_inode *dip, struct inode *inode) 105 - { 106 - struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); 107 - struct posix_acl *acl; 108 - umode_t mode = inode->i_mode; 109 - int error = 0; 110 - 111 - if (!sdp->sd_args.ar_posix_acl) 112 - return 0; 113 - if (S_ISLNK(inode->i_mode)) 114 - return 0; 115 - 116 - acl = gfs2_get_acl(&dip->i_inode, ACL_TYPE_DEFAULT); 117 - if (IS_ERR(acl)) 118 - return PTR_ERR(acl); 119 - if (!acl) { 120 - mode &= ~current_umask(); 121 - return gfs2_set_mode(inode, mode); 122 - } 123 - 124 - if (S_ISDIR(inode->i_mode)) { 125 - error = gfs2_acl_set(inode, ACL_TYPE_DEFAULT, acl); 126 - if (error) 127 - goto out; 128 - } 129 - 130 - error = posix_acl_create(&acl, GFP_NOFS, &mode); 131 - if (error < 0) 132 - return error; 133 - 134 - if (error == 0) 135 - goto munge; 136 - 137 - error = gfs2_acl_set(inode, ACL_TYPE_ACCESS, acl); 138 - if (error) 139 - goto out; 140 - munge: 141 - error = gfs2_set_mode(inode, mode); 142 - out: 143 - posix_acl_release(acl); 144 - return error; 145 - } 146 - 147 - int gfs2_acl_chmod(struct gfs2_inode *ip, struct iattr *attr) 148 - { 149 - struct inode *inode = &ip->i_inode; 150 - struct posix_acl *acl; 151 - char *data; 152 - unsigned int len; 153 - int error; 154 - 155 - acl = gfs2_get_acl(&ip->i_inode, ACL_TYPE_ACCESS); 156 - if (IS_ERR(acl)) 157 - return PTR_ERR(acl); 158 - if (!acl) 159 - return gfs2_setattr_simple(inode, attr); 160 - 161 - error = posix_acl_chmod(&acl, GFP_NOFS, attr->ia_mode); 162 - if (error) 163 - return error; 164 - 165 - len = posix_acl_to_xattr(&init_user_ns, acl, NULL, 0); 166 - data = kmalloc(len, GFP_NOFS); 167 - error = -ENOMEM; 168 - if (data == NULL) 169 - goto out; 170 - posix_acl_to_xattr(&init_user_ns, acl, data, len); 171 - error = gfs2_xattr_acl_chmod(ip, attr, data); 172 - kfree(data); 173 - set_cached_acl(&ip->i_inode, ACL_TYPE_ACCESS, acl); 174 - 175 - out: 176 - posix_acl_release(acl); 177 - return error; 178 - } 179 - 180 - static int gfs2_acl_type(const char *name) 181 - { 182 - if (strcmp(name, GFS2_POSIX_ACL_ACCESS) == 0) 183 - return ACL_TYPE_ACCESS; 184 - if (strcmp(name, GFS2_POSIX_ACL_DEFAULT) == 0) 185 - return ACL_TYPE_DEFAULT; 186 - return -EINVAL; 187 - } 188 - 189 - static int gfs2_xattr_system_get(struct dentry *dentry, const char *name, 190 - void *buffer, size_t size, int xtype) 191 - { 192 - struct inode *inode = dentry->d_inode; 193 - struct gfs2_sbd *sdp = GFS2_SB(inode); 194 - struct posix_acl *acl; 195 - int type; 196 - int error; 197 - 198 - if (!sdp->sd_args.ar_posix_acl) 199 - return -EOPNOTSUPP; 200 - 201 - type = gfs2_acl_type(name); 202 - if (type < 0) 203 - return type; 204 - 205 - acl = gfs2_get_acl(inode, type); 206 - if (IS_ERR(acl)) 207 - return PTR_ERR(acl); 208 - if (acl == NULL) 209 - return -ENODATA; 210 - 211 - error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size); 212 - posix_acl_release(acl); 213 - 214 - return error; 215 - } 216 - 217 - static int gfs2_xattr_system_set(struct dentry *dentry, const char *name, 218 - const void *value, size_t size, int flags, 219 - int xtype) 220 - { 221 - struct inode *inode = dentry->d_inode; 222 - struct gfs2_sbd *sdp = GFS2_SB(inode); 223 - struct posix_acl *acl = NULL; 224 - int error = 0, type; 225 - 226 - if (!sdp->sd_args.ar_posix_acl) 227 - return -EOPNOTSUPP; 228 - 229 - type = gfs2_acl_type(name); 230 - if (type < 0) 231 - return type; 232 - if (flags & XATTR_CREATE) 233 - return -EINVAL; 234 - if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) 235 - return value ? -EACCES : 0; 236 - if (!uid_eq(current_fsuid(), inode->i_uid) && !capable(CAP_FOWNER)) 237 - return -EPERM; 238 - if (S_ISLNK(inode->i_mode)) 239 - return -EOPNOTSUPP; 240 - 241 - if (!value) 242 - goto set_acl; 243 - 244 - acl = posix_acl_from_xattr(&init_user_ns, value, size); 245 - if (!acl) { 246 - /* 247 - * acl_set_file(3) may request that we set default ACLs with 248 - * zero length -- defend (gracefully) against that here. 249 - */ 250 - goto out; 251 - } 252 - if (IS_ERR(acl)) { 253 - error = PTR_ERR(acl); 254 - goto out; 255 - } 256 - 257 - error = posix_acl_valid(acl); 258 - if (error) 259 - goto out_release; 260 - 261 - error = -EINVAL; 262 92 if (acl->a_count > GFS2_ACL_MAX_ENTRIES) 263 - goto out_release; 93 + return -EINVAL; 264 94 265 95 if (type == ACL_TYPE_ACCESS) { 266 96 umode_t mode = inode->i_mode; 97 + 267 98 error = posix_acl_equiv_mode(acl, &mode); 99 + if (error < 0) 100 + return error; 268 101 269 - if (error <= 0) { 270 - posix_acl_release(acl); 102 + if (error == 0) 271 103 acl = NULL; 272 - 273 - if (error < 0) 274 - return error; 275 - } 276 104 277 105 error = gfs2_set_mode(inode, mode); 278 106 if (error) 279 - goto out_release; 107 + return error; 280 108 } 281 109 282 - set_acl: 283 - error = __gfs2_xattr_set(inode, name, value, size, 0, GFS2_EATYPE_SYS); 284 - if (!error) { 285 - if (acl) 286 - set_cached_acl(inode, type, acl); 287 - else 288 - forget_cached_acl(inode, type); 110 + if (acl) { 111 + len = posix_acl_to_xattr(&init_user_ns, acl, NULL, 0); 112 + if (len == 0) 113 + return 0; 114 + data = kmalloc(len, GFP_NOFS); 115 + if (data == NULL) 116 + return -ENOMEM; 117 + error = posix_acl_to_xattr(&init_user_ns, acl, data, len); 118 + if (error < 0) 119 + goto out; 120 + } else { 121 + data = NULL; 122 + len = 0; 289 123 } 290 - out_release: 291 - posix_acl_release(acl); 124 + 125 + error = __gfs2_xattr_set(inode, name, data, len, 0, GFS2_EATYPE_SYS); 126 + if (error) 127 + goto out; 128 + 129 + if (acl) 130 + set_cached_acl(inode, type, acl); 131 + else 132 + forget_cached_acl(inode, type); 292 133 out: 134 + kfree(data); 293 135 return error; 294 136 } 295 - 296 - const struct xattr_handler gfs2_xattr_system_handler = { 297 - .prefix = XATTR_SYSTEM_PREFIX, 298 - .flags = GFS2_EATYPE_SYS, 299 - .get = gfs2_xattr_system_get, 300 - .set = gfs2_xattr_system_set, 301 - }; 302 -
+1 -3
fs/gfs2/acl.h
··· 17 17 #define GFS2_ACL_MAX_ENTRIES 25 18 18 19 19 extern struct posix_acl *gfs2_get_acl(struct inode *inode, int type); 20 - extern int gfs2_acl_create(struct gfs2_inode *dip, struct inode *inode); 21 - extern int gfs2_acl_chmod(struct gfs2_inode *ip, struct iattr *attr); 22 - extern const struct xattr_handler gfs2_xattr_system_handler; 20 + extern int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type); 23 21 24 22 #endif /* __ACL_DOT_H__ */
+28 -6
fs/gfs2/inode.c
··· 571 571 unsigned int size, int excl, int *opened) 572 572 { 573 573 const struct qstr *name = &dentry->d_name; 574 + struct posix_acl *default_acl, *acl; 574 575 struct gfs2_holder ghs[2]; 575 576 struct inode *inode = NULL; 576 577 struct gfs2_inode *dip = GFS2_I(dir), *ip; ··· 634 633 if (!inode) 635 634 goto fail_gunlock; 636 635 636 + error = posix_acl_create(dir, &mode, &default_acl, &acl); 637 + if (error) 638 + goto fail_free_vfs_inode; 639 + 637 640 ip = GFS2_I(inode); 638 641 error = gfs2_rs_alloc(ip); 639 642 if (error) 640 - goto fail_free_inode; 643 + goto fail_free_acls; 641 644 642 645 inode->i_mode = mode; 643 646 set_nlink(inode, S_ISDIR(mode) ? 2 : 1); ··· 709 704 gfs2_set_iop(inode); 710 705 insert_inode_hash(inode); 711 706 712 - error = gfs2_acl_create(dip, inode); 707 + if (default_acl) { 708 + error = gfs2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); 709 + posix_acl_release(default_acl); 710 + } 711 + if (acl) { 712 + if (!error) 713 + error = gfs2_set_acl(inode, acl, ACL_TYPE_ACCESS); 714 + posix_acl_release(acl); 715 + } 716 + 713 717 if (error) 714 718 goto fail_gunlock3; 715 719 ··· 752 738 if (ip->i_gl) 753 739 gfs2_glock_put(ip->i_gl); 754 740 gfs2_rs_delete(ip, NULL); 741 + fail_free_acls: 742 + if (default_acl) 743 + posix_acl_release(default_acl); 744 + if (acl) 745 + posix_acl_release(acl); 746 + fail_free_vfs_inode: 755 747 free_inode_nonrcu(inode); 756 748 inode = NULL; 757 749 fail_gunlock: ··· 1736 1716 error = gfs2_setattr_size(inode, attr->ia_size); 1737 1717 else if (attr->ia_valid & (ATTR_UID | ATTR_GID)) 1738 1718 error = setattr_chown(inode, attr); 1739 - else if ((attr->ia_valid & ATTR_MODE) && IS_POSIXACL(inode)) 1740 - error = gfs2_acl_chmod(ip, attr); 1741 - else 1719 + else { 1742 1720 error = gfs2_setattr_simple(inode, attr); 1721 + if (!error && attr->ia_valid & ATTR_MODE) 1722 + error = posix_acl_chmod(inode, inode->i_mode); 1723 + } 1743 1724 1744 1725 out: 1745 1726 if (!error) ··· 1900 1879 .removexattr = gfs2_removexattr, 1901 1880 .fiemap = gfs2_fiemap, 1902 1881 .get_acl = gfs2_get_acl, 1882 + .set_acl = gfs2_set_acl, 1903 1883 }; 1904 1884 1905 1885 const struct inode_operations gfs2_dir_iops = { ··· 1922 1900 .removexattr = gfs2_removexattr, 1923 1901 .fiemap = gfs2_fiemap, 1924 1902 .get_acl = gfs2_get_acl, 1903 + .set_acl = gfs2_set_acl, 1925 1904 .atomic_open = gfs2_atomic_open, 1926 1905 }; 1927 1906 ··· 1938 1915 .listxattr = gfs2_listxattr, 1939 1916 .removexattr = gfs2_removexattr, 1940 1917 .fiemap = gfs2_fiemap, 1941 - .get_acl = gfs2_get_acl, 1942 1918 }; 1943 1919
+3 -1
fs/gfs2/xattr.c
··· 13 13 #include <linux/buffer_head.h> 14 14 #include <linux/xattr.h> 15 15 #include <linux/gfs2_ondisk.h> 16 + #include <linux/posix_acl_xattr.h> 16 17 #include <asm/uaccess.h> 17 18 18 19 #include "gfs2.h" ··· 1501 1500 const struct xattr_handler *gfs2_xattr_handlers[] = { 1502 1501 &gfs2_xattr_user_handler, 1503 1502 &gfs2_xattr_security_handler, 1504 - &gfs2_xattr_system_handler, 1503 + &posix_acl_access_xattr_handler, 1504 + &posix_acl_default_xattr_handler, 1505 1505 NULL, 1506 1506 }; 1507 1507
+3 -6
fs/hfsplus/acl.h
··· 12 12 13 13 /* posix_acl.c */ 14 14 struct posix_acl *hfsplus_get_posix_acl(struct inode *inode, int type); 15 - extern int hfsplus_posix_acl_chmod(struct inode *); 15 + int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl, 16 + int type); 16 17 extern int hfsplus_init_posix_acl(struct inode *, struct inode *); 17 18 18 19 #else /* CONFIG_HFSPLUS_FS_POSIX_ACL */ 19 20 #define hfsplus_get_posix_acl NULL 20 - 21 - static inline int hfsplus_posix_acl_chmod(struct inode *inode) 22 - { 23 - return 0; 24 - } 21 + #define hfsplus_set_posix_acl NULL 25 22 26 23 static inline int hfsplus_init_posix_acl(struct inode *inode, struct inode *dir) 27 24 {
+1
fs/hfsplus/dir.c
··· 532 532 .removexattr = hfsplus_removexattr, 533 533 #ifdef CONFIG_HFSPLUS_FS_POSIX_ACL 534 534 .get_acl = hfsplus_get_posix_acl, 535 + .set_acl = hfsplus_set_posix_acl, 535 536 #endif 536 537 }; 537 538
+2 -1
fs/hfsplus/inode.c
··· 261 261 mark_inode_dirty(inode); 262 262 263 263 if (attr->ia_valid & ATTR_MODE) { 264 - error = hfsplus_posix_acl_chmod(inode); 264 + error = posix_acl_chmod(inode, inode->i_mode); 265 265 if (unlikely(error)) 266 266 return error; 267 267 } ··· 334 334 .removexattr = hfsplus_removexattr, 335 335 #ifdef CONFIG_HFSPLUS_FS_POSIX_ACL 336 336 .get_acl = hfsplus_get_posix_acl, 337 + .set_acl = hfsplus_set_posix_acl, 337 338 #endif 338 339 }; 339 340
+17 -151
fs/hfsplus/posix_acl.c
··· 17 17 char *value = NULL; 18 18 ssize_t size; 19 19 20 - acl = get_cached_acl(inode, type); 21 - if (acl != ACL_NOT_CACHED) 22 - return acl; 20 + hfs_dbg(ACL_MOD, "[%s]: ino %lu\n", __func__, inode->i_ino); 23 21 24 22 switch (type) { 25 23 case ACL_TYPE_ACCESS: ··· 54 56 return acl; 55 57 } 56 58 57 - static int hfsplus_set_posix_acl(struct inode *inode, 58 - int type, 59 - struct posix_acl *acl) 59 + int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl, 60 + int type) 60 61 { 61 62 int err; 62 63 char *xattr_name; 63 64 size_t size = 0; 64 65 char *value = NULL; 65 66 66 - if (S_ISLNK(inode->i_mode)) 67 - return -EOPNOTSUPP; 67 + hfs_dbg(ACL_MOD, "[%s]: ino %lu\n", __func__, inode->i_ino); 68 68 69 69 switch (type) { 70 70 case ACL_TYPE_ACCESS: ··· 111 115 int hfsplus_init_posix_acl(struct inode *inode, struct inode *dir) 112 116 { 113 117 int err = 0; 114 - struct posix_acl *acl = NULL; 118 + struct posix_acl *default_acl, *acl; 115 119 116 120 hfs_dbg(ACL_MOD, 117 121 "[%s]: ino %lu, dir->ino %lu\n", ··· 120 124 if (S_ISLNK(inode->i_mode)) 121 125 return 0; 122 126 123 - acl = hfsplus_get_posix_acl(dir, ACL_TYPE_DEFAULT); 124 - if (IS_ERR(acl)) 125 - return PTR_ERR(acl); 126 - 127 - if (acl) { 128 - if (S_ISDIR(inode->i_mode)) { 129 - err = hfsplus_set_posix_acl(inode, 130 - ACL_TYPE_DEFAULT, 131 - acl); 132 - if (unlikely(err)) 133 - goto init_acl_cleanup; 134 - } 135 - 136 - err = posix_acl_create(&acl, GFP_NOFS, &inode->i_mode); 137 - if (unlikely(err < 0)) 138 - return err; 139 - 140 - if (err > 0) 141 - err = hfsplus_set_posix_acl(inode, 142 - ACL_TYPE_ACCESS, 143 - acl); 144 - } else 145 - inode->i_mode &= ~current_umask(); 146 - 147 - init_acl_cleanup: 148 - posix_acl_release(acl); 149 - return err; 150 - } 151 - 152 - int hfsplus_posix_acl_chmod(struct inode *inode) 153 - { 154 - int err; 155 - struct posix_acl *acl; 156 - 157 - hfs_dbg(ACL_MOD, "[%s]: ino %lu\n", __func__, inode->i_ino); 158 - 159 - if (S_ISLNK(inode->i_mode)) 160 - return -EOPNOTSUPP; 161 - 162 - acl = hfsplus_get_posix_acl(inode, ACL_TYPE_ACCESS); 163 - if (IS_ERR(acl) || !acl) 164 - return PTR_ERR(acl); 165 - 166 - err = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode); 167 - if (unlikely(err)) 127 + err = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl); 128 + if (err) 168 129 return err; 169 130 170 - err = hfsplus_set_posix_acl(inode, ACL_TYPE_ACCESS, acl); 171 - posix_acl_release(acl); 172 - return err; 173 - } 174 - 175 - static int hfsplus_xattr_get_posix_acl(struct dentry *dentry, 176 - const char *name, 177 - void *buffer, 178 - size_t size, 179 - int type) 180 - { 181 - int err = 0; 182 - struct posix_acl *acl; 183 - 184 - hfs_dbg(ACL_MOD, 185 - "[%s]: ino %lu, buffer %p, size %zu, type %#x\n", 186 - __func__, dentry->d_inode->i_ino, buffer, size, type); 187 - 188 - if (strcmp(name, "") != 0) 189 - return -EINVAL; 190 - 191 - acl = hfsplus_get_posix_acl(dentry->d_inode, type); 192 - if (IS_ERR(acl)) 193 - return PTR_ERR(acl); 194 - if (acl == NULL) 195 - return -ENODATA; 196 - 197 - err = posix_acl_to_xattr(&init_user_ns, acl, buffer, size); 198 - posix_acl_release(acl); 199 - 200 - return err; 201 - } 202 - 203 - static int hfsplus_xattr_set_posix_acl(struct dentry *dentry, 204 - const char *name, 205 - const void *value, 206 - size_t size, 207 - int flags, 208 - int type) 209 - { 210 - int err = 0; 211 - struct inode *inode = dentry->d_inode; 212 - struct posix_acl *acl = NULL; 213 - 214 - hfs_dbg(ACL_MOD, 215 - "[%s]: ino %lu, value %p, size %zu, flags %#x, type %#x\n", 216 - __func__, inode->i_ino, value, size, flags, type); 217 - 218 - if (strcmp(name, "") != 0) 219 - return -EINVAL; 220 - 221 - if (!inode_owner_or_capable(inode)) 222 - return -EPERM; 223 - 224 - if (value) { 225 - acl = posix_acl_from_xattr(&init_user_ns, value, size); 226 - if (IS_ERR(acl)) 227 - return PTR_ERR(acl); 228 - else if (acl) { 229 - err = posix_acl_valid(acl); 230 - if (err) 231 - goto end_xattr_set_acl; 232 - } 131 + if (default_acl) { 132 + err = hfsplus_set_posix_acl(inode, default_acl, 133 + ACL_TYPE_DEFAULT); 134 + posix_acl_release(default_acl); 233 135 } 234 136 235 - err = hfsplus_set_posix_acl(inode, type, acl); 236 - 237 - end_xattr_set_acl: 238 - posix_acl_release(acl); 137 + if (acl) { 138 + if (!err) 139 + err = hfsplus_set_posix_acl(inode, acl, 140 + ACL_TYPE_ACCESS); 141 + posix_acl_release(acl); 142 + } 239 143 return err; 240 144 } 241 - 242 - static size_t hfsplus_xattr_list_posix_acl(struct dentry *dentry, 243 - char *list, 244 - size_t list_size, 245 - const char *name, 246 - size_t name_len, 247 - int type) 248 - { 249 - /* 250 - * This method is not used. 251 - * It is used hfsplus_listxattr() instead of generic_listxattr(). 252 - */ 253 - return -EOPNOTSUPP; 254 - } 255 - 256 - const struct xattr_handler hfsplus_xattr_acl_access_handler = { 257 - .prefix = POSIX_ACL_XATTR_ACCESS, 258 - .flags = ACL_TYPE_ACCESS, 259 - .list = hfsplus_xattr_list_posix_acl, 260 - .get = hfsplus_xattr_get_posix_acl, 261 - .set = hfsplus_xattr_set_posix_acl, 262 - }; 263 - 264 - const struct xattr_handler hfsplus_xattr_acl_default_handler = { 265 - .prefix = POSIX_ACL_XATTR_DEFAULT, 266 - .flags = ACL_TYPE_DEFAULT, 267 - .list = hfsplus_xattr_list_posix_acl, 268 - .get = hfsplus_xattr_get_posix_acl, 269 - .set = hfsplus_xattr_set_posix_acl, 270 - };
+6 -86
fs/hfsplus/xattr.c
··· 7 7 */ 8 8 9 9 #include "hfsplus_fs.h" 10 + #include <linux/posix_acl_xattr.h> 10 11 #include "xattr.h" 11 12 #include "acl.h" 12 13 ··· 16 15 &hfsplus_xattr_user_handler, 17 16 &hfsplus_xattr_trusted_handler, 18 17 #ifdef CONFIG_HFSPLUS_FS_POSIX_ACL 19 - &hfsplus_xattr_acl_access_handler, 20 - &hfsplus_xattr_acl_default_handler, 18 + &posix_acl_access_xattr_handler, 19 + &posix_acl_default_xattr_handler, 21 20 #endif 22 21 &hfsplus_xattr_security_handler, 23 22 NULL ··· 50 49 return false; 51 50 52 51 return true; 53 - } 54 - 55 - static int can_set_system_xattr(struct inode *inode, const char *name, 56 - const void *value, size_t size) 57 - { 58 - #ifdef CONFIG_HFSPLUS_FS_POSIX_ACL 59 - struct posix_acl *acl; 60 - int err; 61 - 62 - if (!inode_owner_or_capable(inode)) 63 - return -EPERM; 64 - 65 - /* 66 - * POSIX_ACL_XATTR_ACCESS is tied to i_mode 67 - */ 68 - if (strcmp(name, POSIX_ACL_XATTR_ACCESS) == 0) { 69 - acl = posix_acl_from_xattr(&init_user_ns, value, size); 70 - if (IS_ERR(acl)) 71 - return PTR_ERR(acl); 72 - if (acl) { 73 - err = posix_acl_equiv_mode(acl, &inode->i_mode); 74 - posix_acl_release(acl); 75 - if (err < 0) 76 - return err; 77 - mark_inode_dirty(inode); 78 - } 79 - /* 80 - * We're changing the ACL. Get rid of the cached one 81 - */ 82 - forget_cached_acl(inode, ACL_TYPE_ACCESS); 83 - 84 - return 0; 85 - } else if (strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0) { 86 - acl = posix_acl_from_xattr(&init_user_ns, value, size); 87 - if (IS_ERR(acl)) 88 - return PTR_ERR(acl); 89 - posix_acl_release(acl); 90 - 91 - /* 92 - * We're changing the default ACL. Get rid of the cached one 93 - */ 94 - forget_cached_acl(inode, ACL_TYPE_DEFAULT); 95 - 96 - return 0; 97 - } 98 - #endif /* CONFIG_HFSPLUS_FS_POSIX_ACL */ 99 - return -EOPNOTSUPP; 100 - } 101 - 102 - static int can_set_xattr(struct inode *inode, const char *name, 103 - const void *value, size_t value_len) 104 - { 105 - if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN)) 106 - return can_set_system_xattr(inode, name, value, value_len); 107 - 108 - if (!strncmp(name, XATTR_MAC_OSX_PREFIX, XATTR_MAC_OSX_PREFIX_LEN)) { 109 - /* 110 - * This makes sure that we aren't trying to set an 111 - * attribute in a different namespace by prefixing it 112 - * with "osx." 113 - */ 114 - if (is_known_namespace(name + XATTR_MAC_OSX_PREFIX_LEN)) 115 - return -EOPNOTSUPP; 116 - 117 - return 0; 118 - } 119 - 120 - /* 121 - * Don't allow setting an attribute in an unknown namespace. 122 - */ 123 - if (strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) && 124 - strncmp(name, XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN) && 125 - strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) 126 - return -EOPNOTSUPP; 127 - 128 - return 0; 129 52 } 130 53 131 54 static void hfsplus_init_header_node(struct inode *attr_file, ··· 273 348 !S_ISDIR(inode->i_mode)) || 274 349 HFSPLUS_IS_RSRC(inode)) 275 350 return -EOPNOTSUPP; 276 - 277 - err = can_set_xattr(inode, name, value, size); 278 - if (err) 279 - return err; 280 351 281 352 if (strncmp(name, XATTR_MAC_OSX_PREFIX, 282 353 XATTR_MAC_OSX_PREFIX_LEN) == 0) ··· 761 840 if (!HFSPLUS_SB(inode->i_sb)->attr_tree) 762 841 return -EOPNOTSUPP; 763 842 764 - err = can_set_xattr(inode, name, NULL, 0); 765 - if (err) 766 - return err; 767 - 768 843 if (strncmp(name, XATTR_MAC_OSX_PREFIX, 769 844 XATTR_MAC_OSX_PREFIX_LEN) == 0) 770 845 name += XATTR_MAC_OSX_PREFIX_LEN; ··· 855 938 return -EINVAL; 856 939 857 940 if (len > HFSPLUS_ATTR_MAX_STRLEN) 941 + return -EOPNOTSUPP; 942 + 943 + if (is_known_namespace(name)) 858 944 return -EOPNOTSUPP; 859 945 860 946 strcpy(xattr_name, XATTR_MAC_OSX_PREFIX);
-2
fs/hfsplus/xattr.h
··· 14 14 extern const struct xattr_handler hfsplus_xattr_osx_handler; 15 15 extern const struct xattr_handler hfsplus_xattr_user_handler; 16 16 extern const struct xattr_handler hfsplus_xattr_trusted_handler; 17 - extern const struct xattr_handler hfsplus_xattr_acl_access_handler; 18 - extern const struct xattr_handler hfsplus_xattr_acl_default_handler; 19 17 extern const struct xattr_handler hfsplus_xattr_security_handler; 20 18 21 19 extern const struct xattr_handler *hfsplus_xattr_handlers[];
+11 -130
fs/jffs2/acl.c
··· 178 178 char *value = NULL; 179 179 int rc, xprefix; 180 180 181 - acl = get_cached_acl(inode, type); 182 - if (acl != ACL_NOT_CACHED) 183 - return acl; 184 - 185 181 switch (type) { 186 182 case ACL_TYPE_ACCESS: 187 183 xprefix = JFFS2_XPREFIX_ACL_ACCESS; ··· 228 232 return rc; 229 233 } 230 234 231 - static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl) 235 + int jffs2_set_acl(struct inode *inode, struct posix_acl *acl, int type) 232 236 { 233 237 int rc, xprefix; 234 - 235 - if (S_ISLNK(inode->i_mode)) 236 - return -EOPNOTSUPP; 237 238 238 239 switch (type) { 239 240 case ACL_TYPE_ACCESS: ··· 270 277 271 278 int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, umode_t *i_mode) 272 279 { 273 - struct posix_acl *acl; 280 + struct posix_acl *default_acl, *acl; 274 281 int rc; 275 282 276 283 cache_no_acl(inode); 277 284 278 - if (S_ISLNK(*i_mode)) 279 - return 0; /* Symlink always has no-ACL */ 285 + rc = posix_acl_create(dir_i, i_mode, &default_acl, &acl); 286 + if (rc) 287 + return rc; 280 288 281 - acl = jffs2_get_acl(dir_i, ACL_TYPE_DEFAULT); 282 - if (IS_ERR(acl)) 283 - return PTR_ERR(acl); 284 - 285 - if (!acl) { 286 - *i_mode &= ~current_umask(); 287 - } else { 288 - if (S_ISDIR(*i_mode)) 289 - set_cached_acl(inode, ACL_TYPE_DEFAULT, acl); 290 - 291 - rc = posix_acl_create(&acl, GFP_KERNEL, i_mode); 292 - if (rc < 0) 293 - return rc; 294 - if (rc > 0) 295 - set_cached_acl(inode, ACL_TYPE_ACCESS, acl); 296 - 289 + if (default_acl) { 290 + set_cached_acl(inode, ACL_TYPE_DEFAULT, default_acl); 291 + posix_acl_release(default_acl); 292 + } 293 + if (acl) { 294 + set_cached_acl(inode, ACL_TYPE_ACCESS, acl); 297 295 posix_acl_release(acl); 298 296 } 299 297 return 0; ··· 308 324 309 325 return 0; 310 326 } 311 - 312 - int jffs2_acl_chmod(struct inode *inode) 313 - { 314 - struct posix_acl *acl; 315 - int rc; 316 - 317 - if (S_ISLNK(inode->i_mode)) 318 - return -EOPNOTSUPP; 319 - acl = jffs2_get_acl(inode, ACL_TYPE_ACCESS); 320 - if (IS_ERR(acl) || !acl) 321 - return PTR_ERR(acl); 322 - rc = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode); 323 - if (rc) 324 - return rc; 325 - rc = jffs2_set_acl(inode, ACL_TYPE_ACCESS, acl); 326 - posix_acl_release(acl); 327 - return rc; 328 - } 329 - 330 - static size_t jffs2_acl_access_listxattr(struct dentry *dentry, char *list, 331 - size_t list_size, const char *name, size_t name_len, int type) 332 - { 333 - const int retlen = sizeof(POSIX_ACL_XATTR_ACCESS); 334 - 335 - if (list && retlen <= list_size) 336 - strcpy(list, POSIX_ACL_XATTR_ACCESS); 337 - return retlen; 338 - } 339 - 340 - static size_t jffs2_acl_default_listxattr(struct dentry *dentry, char *list, 341 - size_t list_size, const char *name, size_t name_len, int type) 342 - { 343 - const int retlen = sizeof(POSIX_ACL_XATTR_DEFAULT); 344 - 345 - if (list && retlen <= list_size) 346 - strcpy(list, POSIX_ACL_XATTR_DEFAULT); 347 - return retlen; 348 - } 349 - 350 - static int jffs2_acl_getxattr(struct dentry *dentry, const char *name, 351 - void *buffer, size_t size, int type) 352 - { 353 - struct posix_acl *acl; 354 - int rc; 355 - 356 - if (name[0] != '\0') 357 - return -EINVAL; 358 - 359 - acl = jffs2_get_acl(dentry->d_inode, type); 360 - if (IS_ERR(acl)) 361 - return PTR_ERR(acl); 362 - if (!acl) 363 - return -ENODATA; 364 - rc = posix_acl_to_xattr(&init_user_ns, acl, buffer, size); 365 - posix_acl_release(acl); 366 - 367 - return rc; 368 - } 369 - 370 - static int jffs2_acl_setxattr(struct dentry *dentry, const char *name, 371 - const void *value, size_t size, int flags, int type) 372 - { 373 - struct posix_acl *acl; 374 - int rc; 375 - 376 - if (name[0] != '\0') 377 - return -EINVAL; 378 - if (!inode_owner_or_capable(dentry->d_inode)) 379 - return -EPERM; 380 - 381 - if (value) { 382 - acl = posix_acl_from_xattr(&init_user_ns, value, size); 383 - if (IS_ERR(acl)) 384 - return PTR_ERR(acl); 385 - if (acl) { 386 - rc = posix_acl_valid(acl); 387 - if (rc) 388 - goto out; 389 - } 390 - } else { 391 - acl = NULL; 392 - } 393 - rc = jffs2_set_acl(dentry->d_inode, type, acl); 394 - out: 395 - posix_acl_release(acl); 396 - return rc; 397 - } 398 - 399 - const struct xattr_handler jffs2_acl_access_xattr_handler = { 400 - .prefix = POSIX_ACL_XATTR_ACCESS, 401 - .flags = ACL_TYPE_DEFAULT, 402 - .list = jffs2_acl_access_listxattr, 403 - .get = jffs2_acl_getxattr, 404 - .set = jffs2_acl_setxattr, 405 - }; 406 - 407 - const struct xattr_handler jffs2_acl_default_xattr_handler = { 408 - .prefix = POSIX_ACL_XATTR_DEFAULT, 409 - .flags = ACL_TYPE_DEFAULT, 410 - .list = jffs2_acl_default_listxattr, 411 - .get = jffs2_acl_getxattr, 412 - .set = jffs2_acl_setxattr, 413 - };
+2 -5
fs/jffs2/acl.h
··· 27 27 #ifdef CONFIG_JFFS2_FS_POSIX_ACL 28 28 29 29 struct posix_acl *jffs2_get_acl(struct inode *inode, int type); 30 - extern int jffs2_acl_chmod(struct inode *); 30 + int jffs2_set_acl(struct inode *inode, struct posix_acl *acl, int type); 31 31 extern int jffs2_init_acl_pre(struct inode *, struct inode *, umode_t *); 32 32 extern int jffs2_init_acl_post(struct inode *); 33 - 34 - extern const struct xattr_handler jffs2_acl_access_xattr_handler; 35 - extern const struct xattr_handler jffs2_acl_default_xattr_handler; 36 33 37 34 #else 38 35 39 36 #define jffs2_get_acl (NULL) 40 - #define jffs2_acl_chmod(inode) (0) 37 + #define jffs2_set_acl (NULL) 41 38 #define jffs2_init_acl_pre(dir_i,inode,mode) (0) 42 39 #define jffs2_init_acl_post(inode) (0) 43 40
+1
fs/jffs2/dir.c
··· 59 59 .mknod = jffs2_mknod, 60 60 .rename = jffs2_rename, 61 61 .get_acl = jffs2_get_acl, 62 + .set_acl = jffs2_set_acl, 62 63 .setattr = jffs2_setattr, 63 64 .setxattr = jffs2_setxattr, 64 65 .getxattr = jffs2_getxattr,
+1
fs/jffs2/file.c
··· 66 66 const struct inode_operations jffs2_file_inode_operations = 67 67 { 68 68 .get_acl = jffs2_get_acl, 69 + .set_acl = jffs2_set_acl, 69 70 .setattr = jffs2_setattr, 70 71 .setxattr = jffs2_setxattr, 71 72 .getxattr = jffs2_getxattr,
+4 -3
fs/jffs2/fs.c
··· 190 190 191 191 int jffs2_setattr(struct dentry *dentry, struct iattr *iattr) 192 192 { 193 + struct inode *inode = dentry->d_inode; 193 194 int rc; 194 195 195 - rc = inode_change_ok(dentry->d_inode, iattr); 196 + rc = inode_change_ok(inode, iattr); 196 197 if (rc) 197 198 return rc; 198 199 199 - rc = jffs2_do_setattr(dentry->d_inode, iattr); 200 + rc = jffs2_do_setattr(inode, iattr); 200 201 if (!rc && (iattr->ia_valid & ATTR_MODE)) 201 - rc = jffs2_acl_chmod(dentry->d_inode); 202 + rc = posix_acl_chmod(inode, inode->i_mode); 202 203 203 204 return rc; 204 205 }
-1
fs/jffs2/symlink.c
··· 22 22 { 23 23 .readlink = generic_readlink, 24 24 .follow_link = jffs2_follow_link, 25 - .get_acl = jffs2_get_acl, 26 25 .setattr = jffs2_setattr, 27 26 .setxattr = jffs2_setxattr, 28 27 .getxattr = jffs2_getxattr,
+5 -4
fs/jffs2/xattr.c
··· 22 22 #include <linux/crc32.h> 23 23 #include <linux/jffs2.h> 24 24 #include <linux/xattr.h> 25 + #include <linux/posix_acl_xattr.h> 25 26 #include <linux/mtd/mtd.h> 26 27 #include "nodelist.h" 27 28 /* -------- xdatum related functions ---------------- ··· 922 921 &jffs2_security_xattr_handler, 923 922 #endif 924 923 #ifdef CONFIG_JFFS2_FS_POSIX_ACL 925 - &jffs2_acl_access_xattr_handler, 926 - &jffs2_acl_default_xattr_handler, 924 + &posix_acl_access_xattr_handler, 925 + &posix_acl_default_xattr_handler, 927 926 #endif 928 927 &jffs2_trusted_xattr_handler, 929 928 NULL ··· 943 942 #endif 944 943 #ifdef CONFIG_JFFS2_FS_POSIX_ACL 945 944 case JFFS2_XPREFIX_ACL_ACCESS: 946 - ret = &jffs2_acl_access_xattr_handler; 945 + ret = &posix_acl_access_xattr_handler; 947 946 break; 948 947 case JFFS2_XPREFIX_ACL_DEFAULT: 949 - ret = &jffs2_acl_default_xattr_handler; 948 + ret = &posix_acl_default_xattr_handler; 950 949 break; 951 950 #endif 952 951 case JFFS2_XPREFIX_TRUSTED:
+43 -64
fs/jfs/acl.c
··· 72 72 return acl; 73 73 } 74 74 75 - static int jfs_set_acl(tid_t tid, struct inode *inode, int type, 75 + static int __jfs_set_acl(tid_t tid, struct inode *inode, int type, 76 76 struct posix_acl *acl) 77 77 { 78 78 char *ea_name; ··· 80 80 int size = 0; 81 81 char *value = NULL; 82 82 83 - if (S_ISLNK(inode->i_mode)) 84 - return -EOPNOTSUPP; 85 - 86 - switch(type) { 87 - case ACL_TYPE_ACCESS: 88 - ea_name = POSIX_ACL_XATTR_ACCESS; 89 - break; 90 - case ACL_TYPE_DEFAULT: 91 - ea_name = POSIX_ACL_XATTR_DEFAULT; 92 - if (!S_ISDIR(inode->i_mode)) 93 - return acl ? -EACCES : 0; 94 - break; 95 - default: 96 - return -EINVAL; 83 + switch (type) { 84 + case ACL_TYPE_ACCESS: 85 + ea_name = POSIX_ACL_XATTR_ACCESS; 86 + rc = posix_acl_equiv_mode(acl, &inode->i_mode); 87 + if (rc < 0) 88 + return rc; 89 + if (rc == 0) 90 + acl = NULL; 91 + break; 92 + case ACL_TYPE_DEFAULT: 93 + ea_name = POSIX_ACL_XATTR_DEFAULT; 94 + break; 95 + default: 96 + return -EINVAL; 97 97 } 98 + 98 99 if (acl) { 99 100 size = posix_acl_xattr_size(acl->a_count); 100 101 value = kmalloc(size, GFP_KERNEL); ··· 115 114 return rc; 116 115 } 117 116 118 - int jfs_init_acl(tid_t tid, struct inode *inode, struct inode *dir) 117 + int jfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) 119 118 { 120 - struct posix_acl *acl = NULL; 121 - int rc = 0; 122 - 123 - if (S_ISLNK(inode->i_mode)) 124 - return 0; 125 - 126 - acl = jfs_get_acl(dir, ACL_TYPE_DEFAULT); 127 - if (IS_ERR(acl)) 128 - return PTR_ERR(acl); 129 - 130 - if (acl) { 131 - if (S_ISDIR(inode->i_mode)) { 132 - rc = jfs_set_acl(tid, inode, ACL_TYPE_DEFAULT, acl); 133 - if (rc) 134 - goto cleanup; 135 - } 136 - rc = posix_acl_create(&acl, GFP_KERNEL, &inode->i_mode); 137 - if (rc < 0) 138 - goto cleanup; /* posix_acl_release(NULL) is no-op */ 139 - if (rc > 0) 140 - rc = jfs_set_acl(tid, inode, ACL_TYPE_ACCESS, acl); 141 - cleanup: 142 - posix_acl_release(acl); 143 - } else 144 - inode->i_mode &= ~current_umask(); 145 - 146 - JFS_IP(inode)->mode2 = (JFS_IP(inode)->mode2 & 0xffff0000) | 147 - inode->i_mode; 148 - 149 - return rc; 150 - } 151 - 152 - int jfs_acl_chmod(struct inode *inode) 153 - { 154 - struct posix_acl *acl; 155 119 int rc; 156 120 tid_t tid; 157 121 158 - if (S_ISLNK(inode->i_mode)) 159 - return -EOPNOTSUPP; 160 - 161 - acl = jfs_get_acl(inode, ACL_TYPE_ACCESS); 162 - if (IS_ERR(acl) || !acl) 163 - return PTR_ERR(acl); 164 - 165 - rc = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode); 166 - if (rc) 167 - return rc; 168 - 169 122 tid = txBegin(inode->i_sb, 0); 170 123 mutex_lock(&JFS_IP(inode)->commit_mutex); 171 - rc = jfs_set_acl(tid, inode, ACL_TYPE_ACCESS, acl); 124 + rc = __jfs_set_acl(tid, inode, type, acl); 172 125 if (!rc) 173 126 rc = txCommit(tid, 1, &inode, 0); 174 127 txEnd(tid); 175 128 mutex_unlock(&JFS_IP(inode)->commit_mutex); 129 + return rc; 130 + } 176 131 177 - posix_acl_release(acl); 132 + int jfs_init_acl(tid_t tid, struct inode *inode, struct inode *dir) 133 + { 134 + struct posix_acl *default_acl, *acl; 135 + int rc = 0; 136 + 137 + rc = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl); 138 + if (rc) 139 + return rc; 140 + 141 + if (default_acl) { 142 + rc = __jfs_set_acl(tid, inode, ACL_TYPE_DEFAULT, default_acl); 143 + posix_acl_release(default_acl); 144 + } 145 + 146 + if (acl) { 147 + if (!rc) 148 + rc = __jfs_set_acl(tid, inode, ACL_TYPE_ACCESS, acl); 149 + posix_acl_release(acl); 150 + } 151 + 152 + JFS_IP(inode)->mode2 = (JFS_IP(inode)->mode2 & 0xffff0000) | 153 + inode->i_mode; 154 + 178 155 return rc; 179 156 }
+3 -1
fs/jfs/file.c
··· 19 19 20 20 #include <linux/mm.h> 21 21 #include <linux/fs.h> 22 + #include <linux/posix_acl.h> 22 23 #include <linux/quotaops.h> 23 24 #include "jfs_incore.h" 24 25 #include "jfs_inode.h" ··· 132 131 mark_inode_dirty(inode); 133 132 134 133 if (iattr->ia_valid & ATTR_MODE) 135 - rc = jfs_acl_chmod(inode); 134 + rc = posix_acl_chmod(inode, inode->i_mode); 136 135 return rc; 137 136 } 138 137 ··· 144 143 .setattr = jfs_setattr, 145 144 #ifdef CONFIG_JFS_POSIX_ACL 146 145 .get_acl = jfs_get_acl, 146 + .set_acl = jfs_set_acl, 147 147 #endif 148 148 }; 149 149
+1 -6
fs/jfs/jfs_acl.h
··· 21 21 #ifdef CONFIG_JFS_POSIX_ACL 22 22 23 23 struct posix_acl *jfs_get_acl(struct inode *inode, int type); 24 + int jfs_set_acl(struct inode *inode, struct posix_acl *acl, int type); 24 25 int jfs_init_acl(tid_t, struct inode *, struct inode *); 25 - int jfs_acl_chmod(struct inode *inode); 26 26 27 27 #else 28 28 29 29 static inline int jfs_init_acl(tid_t tid, struct inode *inode, 30 30 struct inode *dir) 31 - { 32 - return 0; 33 - } 34 - 35 - static inline int jfs_acl_chmod(struct inode *inode) 36 31 { 37 32 return 0; 38 33 }
+2
fs/jfs/jfs_xattr.h
··· 61 61 extern ssize_t jfs_listxattr(struct dentry *, char *, size_t); 62 62 extern int jfs_removexattr(struct dentry *, const char *); 63 63 64 + extern const struct xattr_handler *jfs_xattr_handlers[]; 65 + 64 66 #ifdef CONFIG_JFS_SECURITY 65 67 extern int jfs_init_security(tid_t, struct inode *, struct inode *, 66 68 const struct qstr *);
+1
fs/jfs/namei.c
··· 1524 1524 .setattr = jfs_setattr, 1525 1525 #ifdef CONFIG_JFS_POSIX_ACL 1526 1526 .get_acl = jfs_get_acl, 1527 + .set_acl = jfs_set_acl, 1527 1528 #endif 1528 1529 }; 1529 1530
+2
fs/jfs/super.c
··· 44 44 #include "jfs_imap.h" 45 45 #include "jfs_acl.h" 46 46 #include "jfs_debug.h" 47 + #include "jfs_xattr.h" 47 48 48 49 MODULE_DESCRIPTION("The Journaled Filesystem (JFS)"); 49 50 MODULE_AUTHOR("Steve Best/Dave Kleikamp/Barry Arndt, IBM"); ··· 523 522 */ 524 523 sb->s_op = &jfs_super_operations; 525 524 sb->s_export_op = &jfs_export_operations; 525 + sb->s_xattr = jfs_xattr_handlers; 526 526 #ifdef CONFIG_QUOTA 527 527 sb->dq_op = &dquot_operations; 528 528 sb->s_qcop = &dquot_quotactl_ops;
+38 -70
fs/jfs/xattr.c
··· 666 666 } 667 667 668 668 /* 669 - * can_set_system_xattr 670 - * 671 - * This code is specific to the system.* namespace. It contains policy 672 - * which doesn't belong in the main xattr codepath. 673 - */ 674 - static int can_set_system_xattr(struct inode *inode, const char *name, 675 - const void *value, size_t value_len) 676 - { 677 - #ifdef CONFIG_JFS_POSIX_ACL 678 - struct posix_acl *acl; 679 - int rc; 680 - 681 - if (!inode_owner_or_capable(inode)) 682 - return -EPERM; 683 - 684 - /* 685 - * POSIX_ACL_XATTR_ACCESS is tied to i_mode 686 - */ 687 - if (strcmp(name, POSIX_ACL_XATTR_ACCESS) == 0) { 688 - acl = posix_acl_from_xattr(&init_user_ns, value, value_len); 689 - if (IS_ERR(acl)) { 690 - rc = PTR_ERR(acl); 691 - printk(KERN_ERR "posix_acl_from_xattr returned %d\n", 692 - rc); 693 - return rc; 694 - } 695 - if (acl) { 696 - rc = posix_acl_equiv_mode(acl, &inode->i_mode); 697 - posix_acl_release(acl); 698 - if (rc < 0) { 699 - printk(KERN_ERR 700 - "posix_acl_equiv_mode returned %d\n", 701 - rc); 702 - return rc; 703 - } 704 - mark_inode_dirty(inode); 705 - } 706 - /* 707 - * We're changing the ACL. Get rid of the cached one 708 - */ 709 - forget_cached_acl(inode, ACL_TYPE_ACCESS); 710 - 711 - return 0; 712 - } else if (strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0) { 713 - acl = posix_acl_from_xattr(&init_user_ns, value, value_len); 714 - if (IS_ERR(acl)) { 715 - rc = PTR_ERR(acl); 716 - printk(KERN_ERR "posix_acl_from_xattr returned %d\n", 717 - rc); 718 - return rc; 719 - } 720 - posix_acl_release(acl); 721 - 722 - /* 723 - * We're changing the default ACL. Get rid of the cached one 724 - */ 725 - forget_cached_acl(inode, ACL_TYPE_DEFAULT); 726 - 727 - return 0; 728 - } 729 - #endif /* CONFIG_JFS_POSIX_ACL */ 730 - return -EOPNOTSUPP; 731 - } 732 - 733 - /* 734 669 * Most of the permission checking is done by xattr_permission in the vfs. 735 - * The local file system is responsible for handling the system.* namespace. 736 670 * We also need to verify that this is a namespace that we recognize. 737 671 */ 738 672 static int can_set_xattr(struct inode *inode, const char *name, 739 673 const void *value, size_t value_len) 740 674 { 741 - if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN)) 742 - return can_set_system_xattr(inode, name, value, value_len); 743 - 744 675 if (!strncmp(name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN)) { 745 676 /* 746 677 * This makes sure that we aren't trying to set an ··· 679 748 * with "os2." 680 749 */ 681 750 if (is_known_namespace(name + XATTR_OS2_PREFIX_LEN)) 682 - return -EOPNOTSUPP; 751 + return -EOPNOTSUPP; 683 752 return 0; 684 753 } 685 754 ··· 844 913 if ((rc = can_set_xattr(inode, name, value, value_len))) 845 914 return rc; 846 915 916 + /* 917 + * If this is a request for a synthetic attribute in the system.* 918 + * namespace use the generic infrastructure to resolve a handler 919 + * for it via sb->s_xattr. 920 + */ 921 + if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN)) 922 + return generic_setxattr(dentry, name, value, value_len, flags); 923 + 847 924 if (value == NULL) { /* empty EA, do not remove */ 848 925 value = ""; 849 926 value_len = 0; ··· 924 985 size_t buf_size) 925 986 { 926 987 int err; 988 + 989 + /* 990 + * If this is a request for a synthetic attribute in the system.* 991 + * namespace use the generic infrastructure to resolve a handler 992 + * for it via sb->s_xattr. 993 + */ 994 + if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN)) 995 + return generic_getxattr(dentry, name, data, buf_size); 927 996 928 997 if (strncmp(name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN) == 0) { 929 998 /* ··· 1024 1077 if ((rc = can_set_xattr(inode, name, NULL, 0))) 1025 1078 return rc; 1026 1079 1080 + /* 1081 + * If this is a request for a synthetic attribute in the system.* 1082 + * namespace use the generic infrastructure to resolve a handler 1083 + * for it via sb->s_xattr. 1084 + */ 1085 + if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN)) 1086 + return generic_removexattr(dentry, name); 1087 + 1027 1088 tid = txBegin(inode->i_sb, 0); 1028 1089 mutex_lock(&ji->commit_mutex); 1029 1090 rc = __jfs_setxattr(tid, dentry->d_inode, name, NULL, 0, XATTR_REPLACE); ··· 1042 1087 1043 1088 return rc; 1044 1089 } 1090 + 1091 + /* 1092 + * List of handlers for synthetic system.* attributes. All real ondisk 1093 + * attributes are handled directly. 1094 + */ 1095 + const struct xattr_handler *jfs_xattr_handlers[] = { 1096 + #ifdef JFS_POSIX_ACL 1097 + &posix_acl_access_xattr_handler, 1098 + &posix_acl_default_xattr_handler, 1099 + #endif 1100 + NULL, 1101 + }; 1102 + 1045 1103 1046 1104 #ifdef CONFIG_JFS_SECURITY 1047 1105 static int jfs_initxattrs(struct inode *inode, const struct xattr *xattr_array,
+1 -1
fs/mount.h
··· 74 74 static inline int is_mounted(struct vfsmount *mnt) 75 75 { 76 76 /* neither detached nor internal? */ 77 - return !IS_ERR_OR_NULL(real_mount(mnt)); 77 + return !IS_ERR_OR_NULL(real_mount(mnt)->mnt_ns); 78 78 } 79 79 80 80 extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *);
+3 -21
fs/namei.c
··· 235 235 return posix_acl_permission(inode, acl, mask & ~MAY_NOT_BLOCK); 236 236 } 237 237 238 - acl = get_cached_acl(inode, ACL_TYPE_ACCESS); 239 - 240 - /* 241 - * A filesystem can force a ACL callback by just never filling the 242 - * ACL cache. But normally you'd fill the cache either at inode 243 - * instantiation time, or on the first ->get_acl call. 244 - * 245 - * If the filesystem doesn't have a get_acl() function at all, we'll 246 - * just create the negative cache entry. 247 - */ 248 - if (acl == ACL_NOT_CACHED) { 249 - if (inode->i_op->get_acl) { 250 - acl = inode->i_op->get_acl(inode, ACL_TYPE_ACCESS); 251 - if (IS_ERR(acl)) 252 - return PTR_ERR(acl); 253 - } else { 254 - set_cached_acl(inode, ACL_TYPE_ACCESS, NULL); 255 - return -EAGAIN; 256 - } 257 - } 258 - 238 + acl = get_acl(inode, ACL_TYPE_ACCESS); 239 + if (IS_ERR(acl)) 240 + return PTR_ERR(acl); 259 241 if (acl) { 260 242 int error = posix_acl_permission(inode, acl, mask); 261 243 posix_acl_release(acl);
-4
fs/nfs/inode.c
··· 1641 1641 return NULL; 1642 1642 nfsi->flags = 0UL; 1643 1643 nfsi->cache_validity = 0UL; 1644 - #ifdef CONFIG_NFS_V3_ACL 1645 - nfsi->acl_access = ERR_PTR(-EAGAIN); 1646 - nfsi->acl_default = ERR_PTR(-EAGAIN); 1647 - #endif 1648 1644 #if IS_ENABLED(CONFIG_NFS_V4) 1649 1645 nfsi->nfs4_acl = NULL; 1650 1646 #endif /* CONFIG_NFS_V4 */
+54 -235
fs/nfs/nfs3acl.c
··· 10 10 11 11 #define NFSDBG_FACILITY NFSDBG_PROC 12 12 13 - ssize_t nfs3_listxattr(struct dentry *dentry, char *buffer, size_t size) 14 - { 15 - struct inode *inode = dentry->d_inode; 16 - struct posix_acl *acl; 17 - int pos=0, len=0; 18 - 19 - # define output(s) do { \ 20 - if (pos + sizeof(s) <= size) { \ 21 - memcpy(buffer + pos, s, sizeof(s)); \ 22 - pos += sizeof(s); \ 23 - } \ 24 - len += sizeof(s); \ 25 - } while(0) 26 - 27 - acl = nfs3_proc_getacl(inode, ACL_TYPE_ACCESS); 28 - if (IS_ERR(acl)) 29 - return PTR_ERR(acl); 30 - if (acl) { 31 - output("system.posix_acl_access"); 32 - posix_acl_release(acl); 33 - } 34 - 35 - if (S_ISDIR(inode->i_mode)) { 36 - acl = nfs3_proc_getacl(inode, ACL_TYPE_DEFAULT); 37 - if (IS_ERR(acl)) 38 - return PTR_ERR(acl); 39 - if (acl) { 40 - output("system.posix_acl_default"); 41 - posix_acl_release(acl); 42 - } 43 - } 44 - 45 - # undef output 46 - 47 - if (!buffer || len <= size) 48 - return len; 49 - return -ERANGE; 50 - } 51 - 52 - ssize_t nfs3_getxattr(struct dentry *dentry, const char *name, 53 - void *buffer, size_t size) 54 - { 55 - struct inode *inode = dentry->d_inode; 56 - struct posix_acl *acl; 57 - int type, error = 0; 58 - 59 - if (strcmp(name, POSIX_ACL_XATTR_ACCESS) == 0) 60 - type = ACL_TYPE_ACCESS; 61 - else if (strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0) 62 - type = ACL_TYPE_DEFAULT; 63 - else 64 - return -EOPNOTSUPP; 65 - 66 - acl = nfs3_proc_getacl(inode, type); 67 - if (IS_ERR(acl)) 68 - return PTR_ERR(acl); 69 - else if (acl) { 70 - if (type == ACL_TYPE_ACCESS && acl->a_count == 0) 71 - error = -ENODATA; 72 - else 73 - error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size); 74 - posix_acl_release(acl); 75 - } else 76 - error = -ENODATA; 77 - 78 - return error; 79 - } 80 - 81 - int nfs3_setxattr(struct dentry *dentry, const char *name, 82 - const void *value, size_t size, int flags) 83 - { 84 - struct inode *inode = dentry->d_inode; 85 - struct posix_acl *acl; 86 - int type, error; 87 - 88 - if (strcmp(name, POSIX_ACL_XATTR_ACCESS) == 0) 89 - type = ACL_TYPE_ACCESS; 90 - else if (strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0) 91 - type = ACL_TYPE_DEFAULT; 92 - else 93 - return -EOPNOTSUPP; 94 - 95 - acl = posix_acl_from_xattr(&init_user_ns, value, size); 96 - if (IS_ERR(acl)) 97 - return PTR_ERR(acl); 98 - error = nfs3_proc_setacl(inode, type, acl); 99 - posix_acl_release(acl); 100 - 101 - return error; 102 - } 103 - 104 - int nfs3_removexattr(struct dentry *dentry, const char *name) 105 - { 106 - struct inode *inode = dentry->d_inode; 107 - int type; 108 - 109 - if (strcmp(name, POSIX_ACL_XATTR_ACCESS) == 0) 110 - type = ACL_TYPE_ACCESS; 111 - else if (strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0) 112 - type = ACL_TYPE_DEFAULT; 113 - else 114 - return -EOPNOTSUPP; 115 - 116 - return nfs3_proc_setacl(inode, type, NULL); 117 - } 118 - 119 - static void __nfs3_forget_cached_acls(struct nfs_inode *nfsi) 120 - { 121 - if (!IS_ERR(nfsi->acl_access)) { 122 - posix_acl_release(nfsi->acl_access); 123 - nfsi->acl_access = ERR_PTR(-EAGAIN); 124 - } 125 - if (!IS_ERR(nfsi->acl_default)) { 126 - posix_acl_release(nfsi->acl_default); 127 - nfsi->acl_default = ERR_PTR(-EAGAIN); 128 - } 129 - } 130 - 131 - void nfs3_forget_cached_acls(struct inode *inode) 132 - { 133 - dprintk("NFS: nfs3_forget_cached_acls(%s/%ld)\n", inode->i_sb->s_id, 134 - inode->i_ino); 135 - spin_lock(&inode->i_lock); 136 - __nfs3_forget_cached_acls(NFS_I(inode)); 137 - spin_unlock(&inode->i_lock); 138 - } 139 - 140 - static struct posix_acl *nfs3_get_cached_acl(struct inode *inode, int type) 141 - { 142 - struct nfs_inode *nfsi = NFS_I(inode); 143 - struct posix_acl *acl = ERR_PTR(-EINVAL); 144 - 145 - spin_lock(&inode->i_lock); 146 - switch(type) { 147 - case ACL_TYPE_ACCESS: 148 - acl = nfsi->acl_access; 149 - break; 150 - 151 - case ACL_TYPE_DEFAULT: 152 - acl = nfsi->acl_default; 153 - break; 154 - 155 - default: 156 - goto out; 157 - } 158 - if (IS_ERR(acl)) 159 - acl = ERR_PTR(-EAGAIN); 160 - else 161 - acl = posix_acl_dup(acl); 162 - out: 163 - spin_unlock(&inode->i_lock); 164 - dprintk("NFS: nfs3_get_cached_acl(%s/%ld, %d) = %p\n", inode->i_sb->s_id, 165 - inode->i_ino, type, acl); 166 - return acl; 167 - } 168 - 169 - static void nfs3_cache_acls(struct inode *inode, struct posix_acl *acl, 170 - struct posix_acl *dfacl) 171 - { 172 - struct nfs_inode *nfsi = NFS_I(inode); 173 - 174 - dprintk("nfs3_cache_acls(%s/%ld, %p, %p)\n", inode->i_sb->s_id, 175 - inode->i_ino, acl, dfacl); 176 - spin_lock(&inode->i_lock); 177 - __nfs3_forget_cached_acls(NFS_I(inode)); 178 - if (!IS_ERR(acl)) 179 - nfsi->acl_access = posix_acl_dup(acl); 180 - if (!IS_ERR(dfacl)) 181 - nfsi->acl_default = posix_acl_dup(dfacl); 182 - spin_unlock(&inode->i_lock); 183 - } 184 - 185 - struct posix_acl *nfs3_proc_getacl(struct inode *inode, int type) 13 + struct posix_acl *nfs3_get_acl(struct inode *inode, int type) 186 14 { 187 15 struct nfs_server *server = NFS_SERVER(inode); 188 16 struct page *pages[NFSACL_MAXPAGES] = { }; ··· 26 198 .rpc_argp = &args, 27 199 .rpc_resp = &res, 28 200 }; 29 - struct posix_acl *acl; 30 201 int status, count; 31 202 32 203 if (!nfs_server_capable(inode, NFS_CAP_ACLS)) ··· 34 207 status = nfs_revalidate_inode(server, inode); 35 208 if (status < 0) 36 209 return ERR_PTR(status); 37 - acl = nfs3_get_cached_acl(inode, type); 38 - if (acl != ERR_PTR(-EAGAIN)) 39 - return acl; 40 - acl = NULL; 41 210 42 211 /* 43 212 * Only get the access acl when explicitly requested: We don't ··· 80 257 } 81 258 82 259 if (res.acl_access != NULL) { 83 - if (posix_acl_equiv_mode(res.acl_access, NULL) == 0) { 260 + if (posix_acl_equiv_mode(res.acl_access, NULL) || 261 + res.acl_access->a_count == 0) { 84 262 posix_acl_release(res.acl_access); 85 263 res.acl_access = NULL; 86 264 } 87 265 } 88 - nfs3_cache_acls(inode, 89 - (res.mask & NFS_ACL) ? res.acl_access : ERR_PTR(-EINVAL), 90 - (res.mask & NFS_DFACL) ? res.acl_default : ERR_PTR(-EINVAL)); 91 266 92 - switch(type) { 93 - case ACL_TYPE_ACCESS: 94 - acl = res.acl_access; 95 - res.acl_access = NULL; 96 - break; 267 + if (res.mask & NFS_ACL) 268 + set_cached_acl(inode, ACL_TYPE_ACCESS, res.acl_access); 269 + else 270 + forget_cached_acl(inode, ACL_TYPE_ACCESS); 97 271 98 - case ACL_TYPE_DEFAULT: 99 - acl = res.acl_default; 100 - res.acl_default = NULL; 272 + if (res.mask & NFS_DFACL) 273 + set_cached_acl(inode, ACL_TYPE_DEFAULT, res.acl_default); 274 + else 275 + forget_cached_acl(inode, ACL_TYPE_DEFAULT); 276 + 277 + nfs_free_fattr(res.fattr); 278 + if (type == ACL_TYPE_ACCESS) { 279 + posix_acl_release(res.acl_default); 280 + return res.acl_access; 281 + } else { 282 + posix_acl_release(res.acl_access); 283 + return res.acl_default; 101 284 } 102 285 103 286 getout: 104 287 posix_acl_release(res.acl_access); 105 288 posix_acl_release(res.acl_default); 106 289 nfs_free_fattr(res.fattr); 107 - 108 - if (status != 0) { 109 - posix_acl_release(acl); 110 - acl = ERR_PTR(status); 111 - } 112 - return acl; 290 + return ERR_PTR(status); 113 291 } 114 292 115 - static int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl, 116 - struct posix_acl *dfacl) 293 + int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl, 294 + struct posix_acl *dfacl) 117 295 { 118 296 struct nfs_server *server = NFS_SERVER(inode); 119 297 struct nfs_fattr *fattr; ··· 177 353 switch (status) { 178 354 case 0: 179 355 status = nfs_refresh_inode(inode, fattr); 180 - nfs3_cache_acls(inode, acl, dfacl); 356 + set_cached_acl(inode, ACL_TYPE_ACCESS, acl); 357 + set_cached_acl(inode, ACL_TYPE_DEFAULT, dfacl); 181 358 break; 182 359 case -EPFNOSUPPORT: 183 360 case -EPROTONOSUPPORT: ··· 198 373 return status; 199 374 } 200 375 201 - int nfs3_proc_setacl(struct inode *inode, int type, struct posix_acl *acl) 376 + int nfs3_set_acl(struct inode *inode, struct posix_acl *acl, int type) 202 377 { 203 378 struct posix_acl *alloc = NULL, *dfacl = NULL; 204 379 int status; 205 380 206 381 if (S_ISDIR(inode->i_mode)) { 207 382 switch(type) { 208 - case ACL_TYPE_ACCESS: 209 - alloc = dfacl = nfs3_proc_getacl(inode, 210 - ACL_TYPE_DEFAULT); 211 - if (IS_ERR(alloc)) 212 - goto fail; 213 - break; 383 + case ACL_TYPE_ACCESS: 384 + alloc = dfacl = get_acl(inode, ACL_TYPE_DEFAULT); 385 + if (IS_ERR(alloc)) 386 + goto fail; 387 + break; 214 388 215 - case ACL_TYPE_DEFAULT: 216 - dfacl = acl; 217 - alloc = acl = nfs3_proc_getacl(inode, 218 - ACL_TYPE_ACCESS); 219 - if (IS_ERR(alloc)) 220 - goto fail; 221 - break; 222 - 223 - default: 224 - return -EINVAL; 389 + case ACL_TYPE_DEFAULT: 390 + dfacl = acl; 391 + alloc = acl = get_acl(inode, ACL_TYPE_ACCESS); 392 + if (IS_ERR(alloc)) 393 + goto fail; 394 + break; 225 395 } 226 - } else if (type != ACL_TYPE_ACCESS) 227 - return -EINVAL; 396 + } 228 397 229 398 if (acl == NULL) { 230 399 alloc = acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL); ··· 236 417 int nfs3_proc_set_default_acl(struct inode *dir, struct inode *inode, 237 418 umode_t mode) 238 419 { 239 - struct posix_acl *dfacl, *acl; 240 - int error = 0; 420 + struct posix_acl *default_acl, *acl; 421 + int error; 241 422 242 - dfacl = nfs3_proc_getacl(dir, ACL_TYPE_DEFAULT); 243 - if (IS_ERR(dfacl)) { 244 - error = PTR_ERR(dfacl); 423 + error = posix_acl_create(dir, &mode, &default_acl, &acl); 424 + if (error) 245 425 return (error == -EOPNOTSUPP) ? 0 : error; 246 - } 247 - if (!dfacl) 248 - return 0; 249 - acl = posix_acl_dup(dfacl); 250 - error = posix_acl_create(&acl, GFP_KERNEL, &mode); 251 - if (error < 0) 252 - goto out_release_dfacl; 253 - error = nfs3_proc_setacls(inode, acl, S_ISDIR(inode->i_mode) ? 254 - dfacl : NULL); 255 - posix_acl_release(acl); 256 - out_release_dfacl: 257 - posix_acl_release(dfacl); 426 + 427 + error = nfs3_proc_setacls(inode, acl, default_acl); 428 + 429 + if (acl) 430 + posix_acl_release(acl); 431 + if (default_acl) 432 + posix_acl_release(default_acl); 258 433 return error; 259 434 } 435 + 436 + const struct xattr_handler *nfs3_xattr_handlers[] = { 437 + &posix_acl_access_xattr_handler, 438 + &posix_acl_default_xattr_handler, 439 + NULL, 440 + };
+52 -24
fs/nfs/nfs3proc.c
··· 317 317 nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, 318 318 int flags) 319 319 { 320 + struct posix_acl *default_acl, *acl; 320 321 struct nfs3_createdata *data; 321 - umode_t mode = sattr->ia_mode; 322 322 int status = -ENOMEM; 323 323 324 324 dprintk("NFS call create %pd\n", dentry); ··· 340 340 data->arg.create.verifier[1] = cpu_to_be32(current->pid); 341 341 } 342 342 343 - sattr->ia_mode &= ~current_umask(); 343 + status = posix_acl_create(dir, &sattr->ia_mode, &default_acl, &acl); 344 + if (status) 345 + goto out; 344 346 345 347 for (;;) { 346 348 status = nfs3_do_create(dir, dentry, data); ··· 368 366 } 369 367 370 368 if (status != 0) 371 - goto out; 369 + goto out_release_acls; 372 370 373 371 /* When we created the file with exclusive semantics, make 374 372 * sure we set the attributes afterwards. */ ··· 387 385 nfs_post_op_update_inode(dentry->d_inode, data->res.fattr); 388 386 dprintk("NFS reply setattr (post-create): %d\n", status); 389 387 if (status != 0) 390 - goto out; 388 + goto out_release_acls; 391 389 } 392 - status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode); 390 + 391 + status = nfs3_proc_setacls(dentry->d_inode, acl, default_acl); 392 + 393 + out_release_acls: 394 + posix_acl_release(acl); 395 + posix_acl_release(default_acl); 393 396 out: 394 397 nfs3_free_createdata(data); 395 398 dprintk("NFS reply create: %d\n", status); ··· 579 572 static int 580 573 nfs3_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr) 581 574 { 575 + struct posix_acl *default_acl, *acl; 582 576 struct nfs3_createdata *data; 583 - umode_t mode = sattr->ia_mode; 584 577 int status = -ENOMEM; 585 578 586 579 dprintk("NFS call mkdir %pd\n", dentry); 587 580 588 - sattr->ia_mode &= ~current_umask(); 589 - 590 581 data = nfs3_alloc_createdata(); 591 582 if (data == NULL) 583 + goto out; 584 + 585 + status = posix_acl_create(dir, &sattr->ia_mode, &default_acl, &acl); 586 + if (status) 592 587 goto out; 593 588 594 589 data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_MKDIR]; ··· 601 592 602 593 status = nfs3_do_create(dir, dentry, data); 603 594 if (status != 0) 604 - goto out; 595 + goto out_release_acls; 605 596 606 - status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode); 597 + status = nfs3_proc_setacls(dentry->d_inode, acl, default_acl); 598 + 599 + out_release_acls: 600 + posix_acl_release(acl); 601 + posix_acl_release(default_acl); 607 602 out: 608 603 nfs3_free_createdata(data); 609 604 dprintk("NFS reply mkdir: %d\n", status); ··· 704 691 nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr, 705 692 dev_t rdev) 706 693 { 694 + struct posix_acl *default_acl, *acl; 707 695 struct nfs3_createdata *data; 708 - umode_t mode = sattr->ia_mode; 709 696 int status = -ENOMEM; 710 697 711 698 dprintk("NFS call mknod %pd %u:%u\n", dentry, 712 699 MAJOR(rdev), MINOR(rdev)); 713 700 714 - sattr->ia_mode &= ~current_umask(); 715 - 716 701 data = nfs3_alloc_createdata(); 717 702 if (data == NULL) 703 + goto out; 704 + 705 + status = posix_acl_create(dir, &sattr->ia_mode, &default_acl, &acl); 706 + if (status) 718 707 goto out; 719 708 720 709 data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_MKNOD]; ··· 746 731 747 732 status = nfs3_do_create(dir, dentry, data); 748 733 if (status != 0) 749 - goto out; 750 - status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode); 734 + goto out_release_acls; 735 + 736 + status = nfs3_proc_setacls(dentry->d_inode, acl, default_acl); 737 + 738 + out_release_acls: 739 + posix_acl_release(acl); 740 + posix_acl_release(default_acl); 751 741 out: 752 742 nfs3_free_createdata(data); 753 743 dprintk("NFS reply mknod: %d\n", status); ··· 924 904 .permission = nfs_permission, 925 905 .getattr = nfs_getattr, 926 906 .setattr = nfs_setattr, 927 - .listxattr = nfs3_listxattr, 928 - .getxattr = nfs3_getxattr, 929 - .setxattr = nfs3_setxattr, 930 - .removexattr = nfs3_removexattr, 907 + .listxattr = generic_listxattr, 908 + .getxattr = generic_getxattr, 909 + .setxattr = generic_setxattr, 910 + .removexattr = generic_removexattr, 911 + #ifdef CONFIG_NFS_V3_ACL 912 + .get_acl = nfs3_get_acl, 913 + .set_acl = nfs3_set_acl, 914 + #endif 931 915 }; 932 916 933 917 static const struct inode_operations nfs3_file_inode_operations = { 934 918 .permission = nfs_permission, 935 919 .getattr = nfs_getattr, 936 920 .setattr = nfs_setattr, 937 - .listxattr = nfs3_listxattr, 938 - .getxattr = nfs3_getxattr, 939 - .setxattr = nfs3_setxattr, 940 - .removexattr = nfs3_removexattr, 921 + .listxattr = generic_listxattr, 922 + .getxattr = generic_getxattr, 923 + .setxattr = generic_setxattr, 924 + .removexattr = generic_removexattr, 925 + #ifdef CONFIG_NFS_V3_ACL 926 + .get_acl = nfs3_get_acl, 927 + .set_acl = nfs3_set_acl, 928 + #endif 941 929 }; 942 930 943 931 const struct nfs_rpc_ops nfs_v3_clientops = { ··· 993 965 .commit_rpc_prepare = nfs3_proc_commit_rpc_prepare, 994 966 .commit_done = nfs3_commit_done, 995 967 .lock = nfs3_proc_lock, 996 - .clear_acl_cache = nfs3_forget_cached_acls, 968 + .clear_acl_cache = forget_all_cached_acls, 997 969 .close_context = nfs_close_context, 998 970 .have_delegation = nfs3_have_delegation, 999 971 .return_delegation = nfs3_return_delegation,
+3
fs/nfs/nfs3super.c
··· 12 12 .rpc_vers = &nfs_version3, 13 13 .rpc_ops = &nfs_v3_clientops, 14 14 .sops = &nfs_sops, 15 + #ifdef CONFIG_NFS_V3_ACL 16 + .xattr = nfs3_xattr_handlers, 17 + #endif 15 18 }; 16 19 17 20 static int __init init_nfs_v3(void)
+7 -9
fs/nfsd/acl.h
··· 35 35 #ifndef LINUX_NFS4_ACL_H 36 36 #define LINUX_NFS4_ACL_H 37 37 38 - #include <linux/posix_acl.h> 38 + struct nfs4_acl; 39 + struct svc_fh; 40 + struct svc_rqst; 39 41 40 42 /* Maximum ACL we'll accept from client; chosen (somewhat arbitrarily) to 41 43 * fit in a page: */ ··· 47 45 int nfs4_acl_get_whotype(char *, u32); 48 46 int nfs4_acl_write_who(int who, char *p); 49 47 50 - #define NFS4_ACL_TYPE_DEFAULT 0x01 51 - #define NFS4_ACL_DIR 0x02 52 - #define NFS4_ACL_OWNER 0x04 53 - 54 - struct nfs4_acl *nfs4_acl_posix_to_nfsv4(struct posix_acl *, 55 - struct posix_acl *, unsigned int flags); 56 - int nfs4_acl_nfsv4_to_posix(struct nfs4_acl *, struct posix_acl **, 57 - struct posix_acl **, unsigned int flags); 48 + int nfsd4_get_nfs4_acl(struct svc_rqst *rqstp, struct dentry *dentry, 49 + struct nfs4_acl **acl); 50 + __be32 nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp, 51 + struct nfs4_acl *acl); 58 52 59 53 #endif /* LINUX_NFS4_ACL_H */
+40 -32
fs/nfsd/nfs2acl.c
··· 30 30 static __be32 nfsacld_proc_getacl(struct svc_rqst * rqstp, 31 31 struct nfsd3_getaclargs *argp, struct nfsd3_getaclres *resp) 32 32 { 33 - svc_fh *fh; 34 33 struct posix_acl *acl; 34 + struct inode *inode; 35 + svc_fh *fh; 35 36 __be32 nfserr = 0; 36 37 37 38 dprintk("nfsd: GETACL(2acl) %s\n", SVCFH_fmt(&argp->fh)); ··· 41 40 nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP); 42 41 if (nfserr) 43 42 RETURN_STATUS(nfserr); 43 + 44 + inode = fh->fh_dentry->d_inode; 44 45 45 46 if (argp->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT)) 46 47 RETURN_STATUS(nfserr_inval); ··· 53 50 goto fail; 54 51 55 52 if (resp->mask & (NFS_ACL|NFS_ACLCNT)) { 56 - acl = nfsd_get_posix_acl(fh, ACL_TYPE_ACCESS); 53 + acl = get_acl(inode, ACL_TYPE_ACCESS); 57 54 if (IS_ERR(acl)) { 58 - int err = PTR_ERR(acl); 59 - 60 - if (err == -ENODATA || err == -EOPNOTSUPP) 61 - acl = NULL; 62 - else { 63 - nfserr = nfserrno(err); 64 - goto fail; 65 - } 55 + nfserr = nfserrno(PTR_ERR(acl)); 56 + goto fail; 66 57 } 67 58 if (acl == NULL) { 68 59 /* Solaris returns the inode's minimum ACL. */ 69 - 70 - struct inode *inode = fh->fh_dentry->d_inode; 71 60 acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL); 72 61 } 73 62 resp->acl_access = acl; ··· 67 72 if (resp->mask & (NFS_DFACL|NFS_DFACLCNT)) { 68 73 /* Check how Solaris handles requests for the Default ACL 69 74 of a non-directory! */ 70 - 71 - acl = nfsd_get_posix_acl(fh, ACL_TYPE_DEFAULT); 75 + acl = get_acl(inode, ACL_TYPE_DEFAULT); 72 76 if (IS_ERR(acl)) { 73 - int err = PTR_ERR(acl); 74 - 75 - if (err == -ENODATA || err == -EOPNOTSUPP) 76 - acl = NULL; 77 - else { 78 - nfserr = nfserrno(err); 79 - goto fail; 80 - } 77 + nfserr = nfserrno(PTR_ERR(acl)); 78 + goto fail; 81 79 } 82 80 resp->acl_default = acl; 83 81 } ··· 91 103 struct nfsd3_setaclargs *argp, 92 104 struct nfsd_attrstat *resp) 93 105 { 106 + struct inode *inode; 94 107 svc_fh *fh; 95 108 __be32 nfserr = 0; 109 + int error; 96 110 97 111 dprintk("nfsd: SETACL(2acl) %s\n", SVCFH_fmt(&argp->fh)); 98 112 99 113 fh = fh_copy(&resp->fh, &argp->fh); 100 114 nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR); 115 + if (nfserr) 116 + goto out; 101 117 102 - if (!nfserr) { 103 - nfserr = nfserrno( nfsd_set_posix_acl( 104 - fh, ACL_TYPE_ACCESS, argp->acl_access) ); 105 - } 106 - if (!nfserr) { 107 - nfserr = nfserrno( nfsd_set_posix_acl( 108 - fh, ACL_TYPE_DEFAULT, argp->acl_default) ); 109 - } 110 - if (!nfserr) { 111 - nfserr = fh_getattr(fh, &resp->stat); 118 + inode = fh->fh_dentry->d_inode; 119 + if (!IS_POSIXACL(inode) || !inode->i_op->set_acl) { 120 + error = -EOPNOTSUPP; 121 + goto out_errno; 112 122 } 113 123 124 + error = fh_want_write(fh); 125 + if (error) 126 + goto out_errno; 127 + 128 + error = inode->i_op->set_acl(inode, argp->acl_access, ACL_TYPE_ACCESS); 129 + if (error) 130 + goto out_drop_write; 131 + error = inode->i_op->set_acl(inode, argp->acl_default, 132 + ACL_TYPE_DEFAULT); 133 + if (error) 134 + goto out_drop_write; 135 + 136 + fh_drop_write(fh); 137 + 138 + nfserr = fh_getattr(fh, &resp->stat); 139 + 140 + out: 114 141 /* argp->acl_{access,default} may have been allocated in 115 142 nfssvc_decode_setaclargs. */ 116 143 posix_acl_release(argp->acl_access); 117 144 posix_acl_release(argp->acl_default); 118 145 return nfserr; 146 + out_drop_write: 147 + fh_drop_write(fh); 148 + out_errno: 149 + nfserr = nfserrno(error); 150 + goto out; 119 151 } 120 152 121 153 /*
+33 -29
fs/nfsd/nfs3acl.c
··· 29 29 static __be32 nfsd3_proc_getacl(struct svc_rqst * rqstp, 30 30 struct nfsd3_getaclargs *argp, struct nfsd3_getaclres *resp) 31 31 { 32 - svc_fh *fh; 33 32 struct posix_acl *acl; 33 + struct inode *inode; 34 + svc_fh *fh; 34 35 __be32 nfserr = 0; 35 36 36 37 fh = fh_copy(&resp->fh, &argp->fh); ··· 39 38 if (nfserr) 40 39 RETURN_STATUS(nfserr); 41 40 41 + inode = fh->fh_dentry->d_inode; 42 + 42 43 if (argp->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT)) 43 44 RETURN_STATUS(nfserr_inval); 44 45 resp->mask = argp->mask; 45 46 46 47 if (resp->mask & (NFS_ACL|NFS_ACLCNT)) { 47 - acl = nfsd_get_posix_acl(fh, ACL_TYPE_ACCESS); 48 + acl = get_acl(inode, ACL_TYPE_ACCESS); 48 49 if (IS_ERR(acl)) { 49 - int err = PTR_ERR(acl); 50 - 51 - if (err == -ENODATA || err == -EOPNOTSUPP) 52 - acl = NULL; 53 - else { 54 - nfserr = nfserrno(err); 55 - goto fail; 56 - } 50 + nfserr = nfserrno(PTR_ERR(acl)); 51 + goto fail; 57 52 } 58 53 if (acl == NULL) { 59 54 /* Solaris returns the inode's minimum ACL. */ 60 - 61 - struct inode *inode = fh->fh_dentry->d_inode; 62 55 acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL); 63 56 } 64 57 resp->acl_access = acl; ··· 60 65 if (resp->mask & (NFS_DFACL|NFS_DFACLCNT)) { 61 66 /* Check how Solaris handles requests for the Default ACL 62 67 of a non-directory! */ 63 - 64 - acl = nfsd_get_posix_acl(fh, ACL_TYPE_DEFAULT); 68 + acl = get_acl(inode, ACL_TYPE_DEFAULT); 65 69 if (IS_ERR(acl)) { 66 - int err = PTR_ERR(acl); 67 - 68 - if (err == -ENODATA || err == -EOPNOTSUPP) 69 - acl = NULL; 70 - else { 71 - nfserr = nfserrno(err); 72 - goto fail; 73 - } 70 + nfserr = nfserrno(PTR_ERR(acl)); 71 + goto fail; 74 72 } 75 73 resp->acl_default = acl; 76 74 } ··· 84 96 struct nfsd3_setaclargs *argp, 85 97 struct nfsd3_attrstat *resp) 86 98 { 99 + struct inode *inode; 87 100 svc_fh *fh; 88 101 __be32 nfserr = 0; 102 + int error; 89 103 90 104 fh = fh_copy(&resp->fh, &argp->fh); 91 105 nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR); 106 + if (nfserr) 107 + goto out; 92 108 93 - if (!nfserr) { 94 - nfserr = nfserrno( nfsd_set_posix_acl( 95 - fh, ACL_TYPE_ACCESS, argp->acl_access) ); 96 - } 97 - if (!nfserr) { 98 - nfserr = nfserrno( nfsd_set_posix_acl( 99 - fh, ACL_TYPE_DEFAULT, argp->acl_default) ); 109 + inode = fh->fh_dentry->d_inode; 110 + if (!IS_POSIXACL(inode) || !inode->i_op->set_acl) { 111 + error = -EOPNOTSUPP; 112 + goto out_errno; 100 113 } 101 114 115 + error = fh_want_write(fh); 116 + if (error) 117 + goto out_errno; 118 + 119 + error = inode->i_op->set_acl(inode, argp->acl_access, ACL_TYPE_ACCESS); 120 + if (error) 121 + goto out_drop_write; 122 + error = inode->i_op->set_acl(inode, argp->acl_default, 123 + ACL_TYPE_DEFAULT); 124 + 125 + out_drop_write: 126 + fh_drop_write(fh); 127 + out_errno: 128 + nfserr = nfserrno(error); 129 + out: 102 130 /* argp->acl_{access,default} may have been allocated in 103 131 nfs3svc_decode_setaclargs. */ 104 132 posix_acl_release(argp->acl_access);
+93 -29
fs/nfsd/nfs4acl.c
··· 37 37 #include <linux/slab.h> 38 38 #include <linux/nfs_fs.h> 39 39 #include <linux/export.h> 40 + #include "nfsfh.h" 40 41 #include "acl.h" 42 + #include "vfs.h" 41 43 44 + #define NFS4_ACL_TYPE_DEFAULT 0x01 45 + #define NFS4_ACL_DIR 0x02 46 + #define NFS4_ACL_OWNER 0x04 42 47 43 48 /* mode bit translations: */ 44 49 #define NFS4_READ_MODE (NFS4_ACE_READ_DATA) ··· 135 130 static void _posix_to_nfsv4_one(struct posix_acl *, struct nfs4_acl *, 136 131 unsigned int); 137 132 138 - struct nfs4_acl * 139 - nfs4_acl_posix_to_nfsv4(struct posix_acl *pacl, struct posix_acl *dpacl, 140 - unsigned int flags) 133 + int 134 + nfsd4_get_nfs4_acl(struct svc_rqst *rqstp, struct dentry *dentry, 135 + struct nfs4_acl **acl) 141 136 { 142 - struct nfs4_acl *acl; 137 + struct inode *inode = dentry->d_inode; 138 + int error = 0; 139 + struct posix_acl *pacl = NULL, *dpacl = NULL; 140 + unsigned int flags = 0; 143 141 int size = 0; 144 142 145 - if (pacl) { 146 - if (posix_acl_valid(pacl) < 0) 147 - return ERR_PTR(-EINVAL); 148 - size += 2*pacl->a_count; 149 - } 150 - if (dpacl) { 151 - if (posix_acl_valid(dpacl) < 0) 152 - return ERR_PTR(-EINVAL); 153 - size += 2*dpacl->a_count; 143 + pacl = get_acl(inode, ACL_TYPE_ACCESS); 144 + if (!pacl) { 145 + pacl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL); 146 + if (IS_ERR(pacl)) 147 + return PTR_ERR(pacl); 148 + /* allocate for worst case: one (deny, allow) pair each: */ 149 + size += 2 * pacl->a_count; 154 150 } 155 151 156 - /* Allocate for worst case: one (deny, allow) pair each: */ 157 - acl = nfs4_acl_new(size); 158 - if (acl == NULL) 159 - return ERR_PTR(-ENOMEM); 152 + if (S_ISDIR(inode->i_mode)) { 153 + flags = NFS4_ACL_DIR; 154 + dpacl = get_acl(inode, ACL_TYPE_DEFAULT); 155 + if (dpacl) 156 + size += 2 * dpacl->a_count; 157 + } else { 158 + dpacl = NULL; 159 + } 160 + 161 + *acl = nfs4_acl_new(size); 162 + if (*acl == NULL) { 163 + error = -ENOMEM; 164 + goto out; 165 + } 160 166 161 167 if (pacl) 162 - _posix_to_nfsv4_one(pacl, acl, flags & ~NFS4_ACL_TYPE_DEFAULT); 168 + _posix_to_nfsv4_one(pacl, *acl, flags & ~NFS4_ACL_TYPE_DEFAULT); 163 169 164 170 if (dpacl) 165 - _posix_to_nfsv4_one(dpacl, acl, flags | NFS4_ACL_TYPE_DEFAULT); 171 + _posix_to_nfsv4_one(dpacl, *acl, flags | NFS4_ACL_TYPE_DEFAULT); 166 172 167 - return acl; 173 + out: 174 + posix_acl_release(pacl); 175 + posix_acl_release(dpacl); 176 + return error; 168 177 } 169 178 170 179 struct posix_acl_summary { ··· 738 719 } 739 720 } 740 721 741 - int nfs4_acl_nfsv4_to_posix(struct nfs4_acl *acl, struct posix_acl **pacl, 742 - struct posix_acl **dpacl, unsigned int flags) 722 + static int nfs4_acl_nfsv4_to_posix(struct nfs4_acl *acl, 723 + struct posix_acl **pacl, struct posix_acl **dpacl, 724 + unsigned int flags) 743 725 { 744 726 struct posix_acl_state effective_acl_state, default_acl_state; 745 727 struct nfs4_ace *ace; ··· 800 780 return ret; 801 781 } 802 782 783 + __be32 784 + nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp, 785 + struct nfs4_acl *acl) 786 + { 787 + __be32 error; 788 + int host_error; 789 + struct dentry *dentry; 790 + struct inode *inode; 791 + struct posix_acl *pacl = NULL, *dpacl = NULL; 792 + unsigned int flags = 0; 793 + 794 + /* Get inode */ 795 + error = fh_verify(rqstp, fhp, 0, NFSD_MAY_SATTR); 796 + if (error) 797 + return error; 798 + 799 + dentry = fhp->fh_dentry; 800 + inode = dentry->d_inode; 801 + 802 + if (!inode->i_op->set_acl || !IS_POSIXACL(inode)) 803 + return nfserr_attrnotsupp; 804 + 805 + if (S_ISDIR(inode->i_mode)) 806 + flags = NFS4_ACL_DIR; 807 + 808 + host_error = nfs4_acl_nfsv4_to_posix(acl, &pacl, &dpacl, flags); 809 + if (host_error == -EINVAL) 810 + return nfserr_attrnotsupp; 811 + if (host_error < 0) 812 + goto out_nfserr; 813 + 814 + host_error = inode->i_op->set_acl(inode, pacl, ACL_TYPE_ACCESS); 815 + if (host_error < 0) 816 + goto out_release; 817 + 818 + if (S_ISDIR(inode->i_mode)) { 819 + host_error = inode->i_op->set_acl(inode, dpacl, 820 + ACL_TYPE_DEFAULT); 821 + } 822 + 823 + out_release: 824 + posix_acl_release(pacl); 825 + posix_acl_release(dpacl); 826 + out_nfserr: 827 + if (host_error == -EOPNOTSUPP) 828 + return nfserr_attrnotsupp; 829 + else 830 + return nfserrno(host_error); 831 + } 832 + 833 + 803 834 static short 804 835 ace2type(struct nfs4_ace *ace) 805 836 { ··· 868 797 BUG(); 869 798 return -1; 870 799 } 871 - 872 - EXPORT_SYMBOL(nfs4_acl_posix_to_nfsv4); 873 - EXPORT_SYMBOL(nfs4_acl_nfsv4_to_posix); 874 800 875 801 struct nfs4_acl * 876 802 nfs4_acl_new(int n) ··· 930 862 BUG(); 931 863 return -1; 932 864 } 933 - 934 - EXPORT_SYMBOL(nfs4_acl_new); 935 - EXPORT_SYMBOL(nfs4_acl_get_whotype); 936 - EXPORT_SYMBOL(nfs4_acl_write_who);
+1
fs/nfsd/nfs4proc.c
··· 41 41 #include "vfs.h" 42 42 #include "current_stateid.h" 43 43 #include "netns.h" 44 + #include "acl.h" 44 45 45 46 #ifdef CONFIG_NFSD_V4_SECURITY_LABEL 46 47 #include <linux/security.h>
-241
fs/nfsd/vfs.c
··· 468 468 return err; 469 469 } 470 470 471 - #if defined(CONFIG_NFSD_V2_ACL) || \ 472 - defined(CONFIG_NFSD_V3_ACL) || \ 473 - defined(CONFIG_NFSD_V4) 474 - static ssize_t nfsd_getxattr(struct dentry *dentry, char *key, void **buf) 475 - { 476 - ssize_t buflen; 477 - ssize_t ret; 478 - 479 - buflen = vfs_getxattr(dentry, key, NULL, 0); 480 - if (buflen <= 0) 481 - return buflen; 482 - 483 - *buf = kmalloc(buflen, GFP_KERNEL); 484 - if (!*buf) 485 - return -ENOMEM; 486 - 487 - ret = vfs_getxattr(dentry, key, *buf, buflen); 488 - if (ret < 0) 489 - kfree(*buf); 490 - return ret; 491 - } 492 - #endif 493 - 494 471 #if defined(CONFIG_NFSD_V4) 495 - static int 496 - set_nfsv4_acl_one(struct dentry *dentry, struct posix_acl *pacl, char *key) 497 - { 498 - int len; 499 - size_t buflen; 500 - char *buf = NULL; 501 - int error = 0; 502 - 503 - buflen = posix_acl_xattr_size(pacl->a_count); 504 - buf = kmalloc(buflen, GFP_KERNEL); 505 - error = -ENOMEM; 506 - if (buf == NULL) 507 - goto out; 508 - 509 - len = posix_acl_to_xattr(&init_user_ns, pacl, buf, buflen); 510 - if (len < 0) { 511 - error = len; 512 - goto out; 513 - } 514 - 515 - error = vfs_setxattr(dentry, key, buf, len, 0); 516 - out: 517 - kfree(buf); 518 - return error; 519 - } 520 - 521 - __be32 522 - nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp, 523 - struct nfs4_acl *acl) 524 - { 525 - __be32 error; 526 - int host_error; 527 - struct dentry *dentry; 528 - struct inode *inode; 529 - struct posix_acl *pacl = NULL, *dpacl = NULL; 530 - unsigned int flags = 0; 531 - 532 - /* Get inode */ 533 - error = fh_verify(rqstp, fhp, 0, NFSD_MAY_SATTR); 534 - if (error) 535 - return error; 536 - 537 - dentry = fhp->fh_dentry; 538 - inode = dentry->d_inode; 539 - if (S_ISDIR(inode->i_mode)) 540 - flags = NFS4_ACL_DIR; 541 - 542 - host_error = nfs4_acl_nfsv4_to_posix(acl, &pacl, &dpacl, flags); 543 - if (host_error == -EINVAL) { 544 - return nfserr_attrnotsupp; 545 - } else if (host_error < 0) 546 - goto out_nfserr; 547 - 548 - host_error = set_nfsv4_acl_one(dentry, pacl, POSIX_ACL_XATTR_ACCESS); 549 - if (host_error < 0) 550 - goto out_release; 551 - 552 - if (S_ISDIR(inode->i_mode)) 553 - host_error = set_nfsv4_acl_one(dentry, dpacl, POSIX_ACL_XATTR_DEFAULT); 554 - 555 - out_release: 556 - posix_acl_release(pacl); 557 - posix_acl_release(dpacl); 558 - out_nfserr: 559 - if (host_error == -EOPNOTSUPP) 560 - return nfserr_attrnotsupp; 561 - else 562 - return nfserrno(host_error); 563 - } 564 - 565 - static struct posix_acl * 566 - _get_posix_acl(struct dentry *dentry, char *key) 567 - { 568 - void *buf = NULL; 569 - struct posix_acl *pacl = NULL; 570 - int buflen; 571 - 572 - buflen = nfsd_getxattr(dentry, key, &buf); 573 - if (!buflen) 574 - buflen = -ENODATA; 575 - if (buflen <= 0) 576 - return ERR_PTR(buflen); 577 - 578 - pacl = posix_acl_from_xattr(&init_user_ns, buf, buflen); 579 - kfree(buf); 580 - return pacl; 581 - } 582 - 583 - int 584 - nfsd4_get_nfs4_acl(struct svc_rqst *rqstp, struct dentry *dentry, struct nfs4_acl **acl) 585 - { 586 - struct inode *inode = dentry->d_inode; 587 - int error = 0; 588 - struct posix_acl *pacl = NULL, *dpacl = NULL; 589 - unsigned int flags = 0; 590 - 591 - pacl = _get_posix_acl(dentry, POSIX_ACL_XATTR_ACCESS); 592 - if (IS_ERR(pacl) && PTR_ERR(pacl) == -ENODATA) 593 - pacl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL); 594 - if (IS_ERR(pacl)) { 595 - error = PTR_ERR(pacl); 596 - pacl = NULL; 597 - goto out; 598 - } 599 - 600 - if (S_ISDIR(inode->i_mode)) { 601 - dpacl = _get_posix_acl(dentry, POSIX_ACL_XATTR_DEFAULT); 602 - if (IS_ERR(dpacl) && PTR_ERR(dpacl) == -ENODATA) 603 - dpacl = NULL; 604 - else if (IS_ERR(dpacl)) { 605 - error = PTR_ERR(dpacl); 606 - dpacl = NULL; 607 - goto out; 608 - } 609 - flags = NFS4_ACL_DIR; 610 - } 611 - 612 - *acl = nfs4_acl_posix_to_nfsv4(pacl, dpacl, flags); 613 - if (IS_ERR(*acl)) { 614 - error = PTR_ERR(*acl); 615 - *acl = NULL; 616 - } 617 - out: 618 - posix_acl_release(pacl); 619 - posix_acl_release(dpacl); 620 - return error; 621 - } 622 - 623 472 /* 624 473 * NFS junction information is stored in an extended attribute. 625 474 */ ··· 2133 2284 nfsd_racache_shutdown(); 2134 2285 return -ENOMEM; 2135 2286 } 2136 - 2137 - #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL) 2138 - struct posix_acl * 2139 - nfsd_get_posix_acl(struct svc_fh *fhp, int type) 2140 - { 2141 - struct inode *inode = fhp->fh_dentry->d_inode; 2142 - char *name; 2143 - void *value = NULL; 2144 - ssize_t size; 2145 - struct posix_acl *acl; 2146 - 2147 - if (!IS_POSIXACL(inode)) 2148 - return ERR_PTR(-EOPNOTSUPP); 2149 - 2150 - switch (type) { 2151 - case ACL_TYPE_ACCESS: 2152 - name = POSIX_ACL_XATTR_ACCESS; 2153 - break; 2154 - case ACL_TYPE_DEFAULT: 2155 - name = POSIX_ACL_XATTR_DEFAULT; 2156 - break; 2157 - default: 2158 - return ERR_PTR(-EOPNOTSUPP); 2159 - } 2160 - 2161 - size = nfsd_getxattr(fhp->fh_dentry, name, &value); 2162 - if (size < 0) 2163 - return ERR_PTR(size); 2164 - 2165 - acl = posix_acl_from_xattr(&init_user_ns, value, size); 2166 - kfree(value); 2167 - return acl; 2168 - } 2169 - 2170 - int 2171 - nfsd_set_posix_acl(struct svc_fh *fhp, int type, struct posix_acl *acl) 2172 - { 2173 - struct inode *inode = fhp->fh_dentry->d_inode; 2174 - char *name; 2175 - void *value = NULL; 2176 - size_t size; 2177 - int error; 2178 - 2179 - if (!IS_POSIXACL(inode) || 2180 - !inode->i_op->setxattr || !inode->i_op->removexattr) 2181 - return -EOPNOTSUPP; 2182 - switch(type) { 2183 - case ACL_TYPE_ACCESS: 2184 - name = POSIX_ACL_XATTR_ACCESS; 2185 - break; 2186 - case ACL_TYPE_DEFAULT: 2187 - name = POSIX_ACL_XATTR_DEFAULT; 2188 - break; 2189 - default: 2190 - return -EOPNOTSUPP; 2191 - } 2192 - 2193 - if (acl && acl->a_count) { 2194 - size = posix_acl_xattr_size(acl->a_count); 2195 - value = kmalloc(size, GFP_KERNEL); 2196 - if (!value) 2197 - return -ENOMEM; 2198 - error = posix_acl_to_xattr(&init_user_ns, acl, value, size); 2199 - if (error < 0) 2200 - goto getout; 2201 - size = error; 2202 - } else 2203 - size = 0; 2204 - 2205 - error = fh_want_write(fhp); 2206 - if (error) 2207 - goto getout; 2208 - if (size) 2209 - error = vfs_setxattr(fhp->fh_dentry, name, value, size, 0); 2210 - else { 2211 - if (!S_ISDIR(inode->i_mode) && type == ACL_TYPE_DEFAULT) 2212 - error = 0; 2213 - else { 2214 - error = vfs_removexattr(fhp->fh_dentry, name); 2215 - if (error == -ENODATA) 2216 - error = 0; 2217 - } 2218 - } 2219 - fh_drop_write(fhp); 2220 - 2221 - getout: 2222 - kfree(value); 2223 - return error; 2224 - } 2225 - #endif /* defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL) */
-8
fs/nfsd/vfs.h
··· 52 52 struct iattr *, int, time_t); 53 53 int nfsd_mountpoint(struct dentry *, struct svc_export *); 54 54 #ifdef CONFIG_NFSD_V4 55 - __be32 nfsd4_set_nfs4_acl(struct svc_rqst *, struct svc_fh *, 56 - struct nfs4_acl *); 57 - int nfsd4_get_nfs4_acl(struct svc_rqst *, struct dentry *, struct nfs4_acl **); 58 55 __be32 nfsd4_set_nfs4_label(struct svc_rqst *, struct svc_fh *, 59 56 struct xdr_netobj *); 60 57 #endif /* CONFIG_NFSD_V4 */ ··· 97 100 98 101 __be32 nfsd_permission(struct svc_rqst *, struct svc_export *, 99 102 struct dentry *, int); 100 - 101 - #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL) 102 - struct posix_acl *nfsd_get_posix_acl(struct svc_fh *, int); 103 - int nfsd_set_posix_acl(struct svc_fh *, int, struct posix_acl *); 104 - #endif 105 103 106 104 static inline int fh_want_write(struct svc_fh *fh) 107 105 {
-1
fs/nls/mac-celtic.c
··· 583 583 .char2uni = char2uni, 584 584 .charset2lower = charset2lower, 585 585 .charset2upper = charset2upper, 586 - .owner = THIS_MODULE, 587 586 }; 588 587 589 588 static int __init init_nls_macceltic(void)
-1
fs/nls/mac-centeuro.c
··· 513 513 .char2uni = char2uni, 514 514 .charset2lower = charset2lower, 515 515 .charset2upper = charset2upper, 516 - .owner = THIS_MODULE, 517 516 }; 518 517 519 518 static int __init init_nls_maccenteuro(void)
-1
fs/nls/mac-croatian.c
··· 583 583 .char2uni = char2uni, 584 584 .charset2lower = charset2lower, 585 585 .charset2upper = charset2upper, 586 - .owner = THIS_MODULE, 587 586 }; 588 587 589 588 static int __init init_nls_maccroatian(void)
-1
fs/nls/mac-cyrillic.c
··· 478 478 .char2uni = char2uni, 479 479 .charset2lower = charset2lower, 480 480 .charset2upper = charset2upper, 481 - .owner = THIS_MODULE, 482 481 }; 483 482 484 483 static int __init init_nls_maccyrillic(void)
-1
fs/nls/mac-gaelic.c
··· 548 548 .char2uni = char2uni, 549 549 .charset2lower = charset2lower, 550 550 .charset2upper = charset2upper, 551 - .owner = THIS_MODULE, 552 551 }; 553 552 554 553 static int __init init_nls_macgaelic(void)
-1
fs/nls/mac-greek.c
··· 478 478 .char2uni = char2uni, 479 479 .charset2lower = charset2lower, 480 480 .charset2upper = charset2upper, 481 - .owner = THIS_MODULE, 482 481 }; 483 482 484 483 static int __init init_nls_macgreek(void)
-1
fs/nls/mac-iceland.c
··· 583 583 .char2uni = char2uni, 584 584 .charset2lower = charset2lower, 585 585 .charset2upper = charset2upper, 586 - .owner = THIS_MODULE, 587 586 }; 588 587 589 588 static int __init init_nls_maciceland(void)
-1
fs/nls/mac-inuit.c
··· 513 513 .char2uni = char2uni, 514 514 .charset2lower = charset2lower, 515 515 .charset2upper = charset2upper, 516 - .owner = THIS_MODULE, 517 516 }; 518 517 519 518 static int __init init_nls_macinuit(void)
-1
fs/nls/mac-roman.c
··· 618 618 .char2uni = char2uni, 619 619 .charset2lower = charset2lower, 620 620 .charset2upper = charset2upper, 621 - .owner = THIS_MODULE, 622 621 }; 623 622 624 623 static int __init init_nls_macroman(void)
-1
fs/nls/mac-romanian.c
··· 583 583 .char2uni = char2uni, 584 584 .charset2lower = charset2lower, 585 585 .charset2upper = charset2upper, 586 - .owner = THIS_MODULE, 587 586 }; 588 587 589 588 static int __init init_nls_macromanian(void)
-1
fs/nls/mac-turkish.c
··· 583 583 .char2uni = char2uni, 584 584 .charset2lower = charset2lower, 585 585 .charset2upper = charset2upper, 586 - .owner = THIS_MODULE, 587 586 }; 588 587 589 588 static int __init init_nls_macturkish(void)
-1
fs/nls/nls_ascii.c
··· 148 148 .char2uni = char2uni, 149 149 .charset2lower = charset2lower, 150 150 .charset2upper = charset2upper, 151 - .owner = THIS_MODULE, 152 151 }; 153 152 154 153 static int __init init_nls_ascii(void)
+3 -2
fs/nls/nls_base.c
··· 232 232 } 233 233 EXPORT_SYMBOL(utf16s_to_utf8s); 234 234 235 - int register_nls(struct nls_table * nls) 235 + int __register_nls(struct nls_table *nls, struct module *owner) 236 236 { 237 237 struct nls_table ** tmp = &tables; 238 238 239 239 if (nls->next) 240 240 return -EBUSY; 241 241 242 + nls->owner = owner; 242 243 spin_lock(&nls_lock); 243 244 while (*tmp) { 244 245 if (nls == *tmp) { ··· 253 252 spin_unlock(&nls_lock); 254 253 return 0; 255 254 } 255 + EXPORT_SYMBOL(__register_nls); 256 256 257 257 int unregister_nls(struct nls_table * nls) 258 258 { ··· 540 538 return &default_table; 541 539 } 542 540 543 - EXPORT_SYMBOL(register_nls); 544 541 EXPORT_SYMBOL(unregister_nls); 545 542 EXPORT_SYMBOL(unload_nls); 546 543 EXPORT_SYMBOL(load_nls);
-1
fs/nls/nls_cp1250.c
··· 329 329 .char2uni = char2uni, 330 330 .charset2lower = charset2lower, 331 331 .charset2upper = charset2upper, 332 - .owner = THIS_MODULE, 333 332 }; 334 333 335 334 static int __init init_nls_cp1250(void)
-1
fs/nls/nls_cp1251.c
··· 283 283 .char2uni = char2uni, 284 284 .charset2lower = charset2lower, 285 285 .charset2upper = charset2upper, 286 - .owner = THIS_MODULE, 287 286 }; 288 287 289 288 static int __init init_nls_cp1251(void)
-1
fs/nls/nls_cp1255.c
··· 365 365 .char2uni = char2uni, 366 366 .charset2lower = charset2lower, 367 367 .charset2upper = charset2upper, 368 - .owner = THIS_MODULE, 369 368 }; 370 369 371 370 static int __init init_nls_cp1255(void)
-1
fs/nls/nls_cp437.c
··· 369 369 .char2uni = char2uni, 370 370 .charset2lower = charset2lower, 371 371 .charset2upper = charset2upper, 372 - .owner = THIS_MODULE, 373 372 }; 374 373 375 374 static int __init init_nls_cp437(void)
-1
fs/nls/nls_cp737.c
··· 332 332 .char2uni = char2uni, 333 333 .charset2lower = charset2lower, 334 334 .charset2upper = charset2upper, 335 - .owner = THIS_MODULE, 336 335 }; 337 336 338 337 static int __init init_nls_cp737(void)
-1
fs/nls/nls_cp775.c
··· 301 301 .char2uni = char2uni, 302 302 .charset2lower = charset2lower, 303 303 .charset2upper = charset2upper, 304 - .owner = THIS_MODULE, 305 304 }; 306 305 307 306 static int __init init_nls_cp775(void)
-1
fs/nls/nls_cp850.c
··· 297 297 .char2uni = char2uni, 298 298 .charset2lower = charset2lower, 299 299 .charset2upper = charset2upper, 300 - .owner = THIS_MODULE, 301 300 }; 302 301 303 302 static int __init init_nls_cp850(void)
-1
fs/nls/nls_cp852.c
··· 319 319 .char2uni = char2uni, 320 320 .charset2lower = charset2lower, 321 321 .charset2upper = charset2upper, 322 - .owner = THIS_MODULE, 323 322 }; 324 323 325 324 static int __init init_nls_cp852(void)
-1
fs/nls/nls_cp855.c
··· 281 281 .char2uni = char2uni, 282 282 .charset2lower = charset2lower, 283 283 .charset2upper = charset2upper, 284 - .owner = THIS_MODULE, 285 284 }; 286 285 287 286 static int __init init_nls_cp855(void)
-1
fs/nls/nls_cp857.c
··· 283 283 .char2uni = char2uni, 284 284 .charset2lower = charset2lower, 285 285 .charset2upper = charset2upper, 286 - .owner = THIS_MODULE, 287 286 }; 288 287 289 288 static int __init init_nls_cp857(void)
-1
fs/nls/nls_cp860.c
··· 346 346 .char2uni = char2uni, 347 347 .charset2lower = charset2lower, 348 348 .charset2upper = charset2upper, 349 - .owner = THIS_MODULE, 350 349 }; 351 350 352 351 static int __init init_nls_cp860(void)
-1
fs/nls/nls_cp861.c
··· 369 369 .char2uni = char2uni, 370 370 .charset2lower = charset2lower, 371 371 .charset2upper = charset2upper, 372 - .owner = THIS_MODULE, 373 372 }; 374 373 375 374 static int __init init_nls_cp861(void)
-1
fs/nls/nls_cp862.c
··· 403 403 .char2uni = char2uni, 404 404 .charset2lower = charset2lower, 405 405 .charset2upper = charset2upper, 406 - .owner = THIS_MODULE, 407 406 }; 408 407 409 408 static int __init init_nls_cp862(void)
-1
fs/nls/nls_cp863.c
··· 363 363 .char2uni = char2uni, 364 364 .charset2lower = charset2lower, 365 365 .charset2upper = charset2upper, 366 - .owner = THIS_MODULE, 367 366 }; 368 367 369 368 static int __init init_nls_cp863(void)
-1
fs/nls/nls_cp864.c
··· 389 389 .char2uni = char2uni, 390 390 .charset2lower = charset2lower, 391 391 .charset2upper = charset2upper, 392 - .owner = THIS_MODULE, 393 392 }; 394 393 395 394 static int __init init_nls_cp864(void)
-1
fs/nls/nls_cp865.c
··· 369 369 .char2uni = char2uni, 370 370 .charset2lower = charset2lower, 371 371 .charset2upper = charset2upper, 372 - .owner = THIS_MODULE, 373 372 }; 374 373 375 374 static int __init init_nls_cp865(void)
-1
fs/nls/nls_cp866.c
··· 287 287 .char2uni = char2uni, 288 288 .charset2lower = charset2lower, 289 289 .charset2upper = charset2upper, 290 - .owner = THIS_MODULE, 291 290 }; 292 291 293 292 static int __init init_nls_cp866(void)
-1
fs/nls/nls_cp869.c
··· 297 297 .char2uni = char2uni, 298 298 .charset2lower = charset2lower, 299 299 .charset2upper = charset2upper, 300 - .owner = THIS_MODULE, 301 300 }; 302 301 303 302 static int __init init_nls_cp869(void)
-1
fs/nls/nls_cp874.c
··· 256 256 .char2uni = char2uni, 257 257 .charset2lower = charset2lower, 258 258 .charset2upper = charset2upper, 259 - .owner = THIS_MODULE, 260 259 }; 261 260 262 261 static int __init init_nls_cp874(void)
-1
fs/nls/nls_cp932.c
··· 7914 7914 .char2uni = char2uni, 7915 7915 .charset2lower = charset2lower, 7916 7916 .charset2upper = charset2upper, 7917 - .owner = THIS_MODULE, 7918 7917 }; 7919 7918 7920 7919 static int __init init_nls_cp932(void)
-1
fs/nls/nls_cp936.c
··· 11092 11092 .char2uni = char2uni, 11093 11093 .charset2lower = charset2lower, 11094 11094 .charset2upper = charset2upper, 11095 - .owner = THIS_MODULE, 11096 11095 }; 11097 11096 11098 11097 static int __init init_nls_cp936(void)
-1
fs/nls/nls_cp949.c
··· 13927 13927 .char2uni = char2uni, 13928 13928 .charset2lower = charset2lower, 13929 13929 .charset2upper = charset2upper, 13930 - .owner = THIS_MODULE, 13931 13930 }; 13932 13931 13933 13932 static int __init init_nls_cp949(void)
-1
fs/nls/nls_cp950.c
··· 9463 9463 .char2uni = char2uni, 9464 9464 .charset2lower = charset2lower, 9465 9465 .charset2upper = charset2upper, 9466 - .owner = THIS_MODULE, 9467 9466 }; 9468 9467 9469 9468 static int __init init_nls_cp950(void)
-1
fs/nls/nls_euc-jp.c
··· 553 553 .charset = "euc-jp", 554 554 .uni2char = uni2char, 555 555 .char2uni = char2uni, 556 - .owner = THIS_MODULE, 557 556 }; 558 557 559 558 static int __init init_nls_euc_jp(void)
-1
fs/nls/nls_iso8859-1.c
··· 239 239 .char2uni = char2uni, 240 240 .charset2lower = charset2lower, 241 241 .charset2upper = charset2upper, 242 - .owner = THIS_MODULE, 243 242 }; 244 243 245 244 static int __init init_nls_iso8859_1(void)
-1
fs/nls/nls_iso8859-13.c
··· 267 267 .char2uni = char2uni, 268 268 .charset2lower = charset2lower, 269 269 .charset2upper = charset2upper, 270 - .owner = THIS_MODULE, 271 270 }; 272 271 273 272 static int __init init_nls_iso8859_13(void)
-1
fs/nls/nls_iso8859-14.c
··· 323 323 .char2uni = char2uni, 324 324 .charset2lower = charset2lower, 325 325 .charset2upper = charset2upper, 326 - .owner = THIS_MODULE, 327 326 }; 328 327 329 328 static int __init init_nls_iso8859_14(void)
-1
fs/nls/nls_iso8859-15.c
··· 289 289 .char2uni = char2uni, 290 290 .charset2lower = charset2lower, 291 291 .charset2upper = charset2upper, 292 - .owner = THIS_MODULE, 293 292 }; 294 293 295 294 static int __init init_nls_iso8859_15(void)
-1
fs/nls/nls_iso8859-2.c
··· 290 290 .char2uni = char2uni, 291 291 .charset2lower = charset2lower, 292 292 .charset2upper = charset2upper, 293 - .owner = THIS_MODULE, 294 293 }; 295 294 296 295 static int __init init_nls_iso8859_2(void)
-1
fs/nls/nls_iso8859-3.c
··· 290 290 .char2uni = char2uni, 291 291 .charset2lower = charset2lower, 292 292 .charset2upper = charset2upper, 293 - .owner = THIS_MODULE, 294 293 }; 295 294 296 295 static int __init init_nls_iso8859_3(void)
-1
fs/nls/nls_iso8859-4.c
··· 290 290 .char2uni = char2uni, 291 291 .charset2lower = charset2lower, 292 292 .charset2upper = charset2upper, 293 - .owner = THIS_MODULE, 294 293 }; 295 294 296 295 static int __init init_nls_iso8859_4(void)
-1
fs/nls/nls_iso8859-5.c
··· 254 254 .char2uni = char2uni, 255 255 .charset2lower = charset2lower, 256 256 .charset2upper = charset2upper, 257 - .owner = THIS_MODULE, 258 257 }; 259 258 260 259 static int __init init_nls_iso8859_5(void)
-1
fs/nls/nls_iso8859-6.c
··· 245 245 .char2uni = char2uni, 246 246 .charset2lower = charset2lower, 247 247 .charset2upper = charset2upper, 248 - .owner = THIS_MODULE, 249 248 }; 250 249 251 250 static int __init init_nls_iso8859_6(void)
-1
fs/nls/nls_iso8859-7.c
··· 299 299 .char2uni = char2uni, 300 300 .charset2lower = charset2lower, 301 301 .charset2upper = charset2upper, 302 - .owner = THIS_MODULE, 303 302 }; 304 303 305 304 static int __init init_nls_iso8859_7(void)
-1
fs/nls/nls_iso8859-9.c
··· 254 254 .char2uni = char2uni, 255 255 .charset2lower = charset2lower, 256 256 .charset2upper = charset2upper, 257 - .owner = THIS_MODULE, 258 257 }; 259 258 260 259 static int __init init_nls_iso8859_9(void)
-1
fs/nls/nls_koi8-r.c
··· 305 305 .char2uni = char2uni, 306 306 .charset2lower = charset2lower, 307 307 .charset2upper = charset2upper, 308 - .owner = THIS_MODULE, 309 308 }; 310 309 311 310 static int __init init_nls_koi8_r(void)
-1
fs/nls/nls_koi8-ru.c
··· 55 55 .charset = "koi8-ru", 56 56 .uni2char = uni2char, 57 57 .char2uni = char2uni, 58 - .owner = THIS_MODULE, 59 58 }; 60 59 61 60 static int __init init_nls_koi8_ru(void)
-1
fs/nls/nls_koi8-u.c
··· 312 312 .char2uni = char2uni, 313 313 .charset2lower = charset2lower, 314 314 .charset2upper = charset2upper, 315 - .owner = THIS_MODULE, 316 315 }; 317 316 318 317 static int __init init_nls_koi8_u(void)
-1
fs/nls/nls_utf8.c
··· 46 46 .char2uni = char2uni, 47 47 .charset2lower = identity, /* no conversion */ 48 48 .charset2upper = identity, 49 - .owner = THIS_MODULE, 50 49 }; 51 50 52 51 static int __init init_nls_utf8(void)
+6 -228
fs/ocfs2/acl.c
··· 160 160 return acl; 161 161 } 162 162 163 - 164 - /* 165 - * Get posix acl. 166 - */ 167 - static struct posix_acl *ocfs2_get_acl(struct inode *inode, int type) 168 - { 169 - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 170 - struct buffer_head *di_bh = NULL; 171 - struct posix_acl *acl; 172 - int ret; 173 - 174 - if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) 175 - return NULL; 176 - 177 - ret = ocfs2_inode_lock(inode, &di_bh, 0); 178 - if (ret < 0) { 179 - mlog_errno(ret); 180 - acl = ERR_PTR(ret); 181 - return acl; 182 - } 183 - 184 - acl = ocfs2_get_acl_nolock(inode, type, di_bh); 185 - 186 - ocfs2_inode_unlock(inode, 0); 187 - 188 - brelse(di_bh); 189 - 190 - return acl; 191 - } 192 - 193 163 /* 194 164 * Helper function to set i_mode in memory and disk. Some call paths 195 165 * will not have di_bh or a journal handle to pass, in which case it ··· 220 250 /* 221 251 * Set the access or default ACL of an inode. 222 252 */ 223 - static int ocfs2_set_acl(handle_t *handle, 253 + int ocfs2_set_acl(handle_t *handle, 224 254 struct inode *inode, 225 255 struct buffer_head *di_bh, 226 256 int type, ··· 283 313 return ret; 284 314 } 285 315 316 + int ocfs2_iop_set_acl(struct inode *inode, struct posix_acl *acl, int type) 317 + { 318 + return ocfs2_set_acl(NULL, inode, NULL, type, acl, NULL, NULL); 319 + } 320 + 286 321 struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type) 287 322 { 288 323 struct ocfs2_super *osb; ··· 309 334 310 335 return acl; 311 336 } 312 - 313 - int ocfs2_acl_chmod(struct inode *inode) 314 - { 315 - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 316 - struct posix_acl *acl; 317 - int ret; 318 - 319 - if (S_ISLNK(inode->i_mode)) 320 - return -EOPNOTSUPP; 321 - 322 - if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) 323 - return 0; 324 - 325 - acl = ocfs2_get_acl(inode, ACL_TYPE_ACCESS); 326 - if (IS_ERR(acl) || !acl) 327 - return PTR_ERR(acl); 328 - ret = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode); 329 - if (ret) 330 - return ret; 331 - ret = ocfs2_set_acl(NULL, inode, NULL, ACL_TYPE_ACCESS, 332 - acl, NULL, NULL); 333 - posix_acl_release(acl); 334 - return ret; 335 - } 336 - 337 - /* 338 - * Initialize the ACLs of a new inode. If parent directory has default ACL, 339 - * then clone to new inode. Called from ocfs2_mknod. 340 - */ 341 - int ocfs2_init_acl(handle_t *handle, 342 - struct inode *inode, 343 - struct inode *dir, 344 - struct buffer_head *di_bh, 345 - struct buffer_head *dir_bh, 346 - struct ocfs2_alloc_context *meta_ac, 347 - struct ocfs2_alloc_context *data_ac) 348 - { 349 - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 350 - struct posix_acl *acl = NULL; 351 - int ret = 0, ret2; 352 - umode_t mode; 353 - 354 - if (!S_ISLNK(inode->i_mode)) { 355 - if (osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) { 356 - acl = ocfs2_get_acl_nolock(dir, ACL_TYPE_DEFAULT, 357 - dir_bh); 358 - if (IS_ERR(acl)) 359 - return PTR_ERR(acl); 360 - } 361 - if (!acl) { 362 - mode = inode->i_mode & ~current_umask(); 363 - ret = ocfs2_acl_set_mode(inode, di_bh, handle, mode); 364 - if (ret) { 365 - mlog_errno(ret); 366 - goto cleanup; 367 - } 368 - } 369 - } 370 - if ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) && acl) { 371 - if (S_ISDIR(inode->i_mode)) { 372 - ret = ocfs2_set_acl(handle, inode, di_bh, 373 - ACL_TYPE_DEFAULT, acl, 374 - meta_ac, data_ac); 375 - if (ret) 376 - goto cleanup; 377 - } 378 - mode = inode->i_mode; 379 - ret = posix_acl_create(&acl, GFP_NOFS, &mode); 380 - if (ret < 0) 381 - return ret; 382 - 383 - ret2 = ocfs2_acl_set_mode(inode, di_bh, handle, mode); 384 - if (ret2) { 385 - mlog_errno(ret2); 386 - ret = ret2; 387 - goto cleanup; 388 - } 389 - if (ret > 0) { 390 - ret = ocfs2_set_acl(handle, inode, 391 - di_bh, ACL_TYPE_ACCESS, 392 - acl, meta_ac, data_ac); 393 - } 394 - } 395 - cleanup: 396 - posix_acl_release(acl); 397 - return ret; 398 - } 399 - 400 - static size_t ocfs2_xattr_list_acl_access(struct dentry *dentry, 401 - char *list, 402 - size_t list_len, 403 - const char *name, 404 - size_t name_len, 405 - int type) 406 - { 407 - struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); 408 - const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); 409 - 410 - if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) 411 - return 0; 412 - 413 - if (list && size <= list_len) 414 - memcpy(list, POSIX_ACL_XATTR_ACCESS, size); 415 - return size; 416 - } 417 - 418 - static size_t ocfs2_xattr_list_acl_default(struct dentry *dentry, 419 - char *list, 420 - size_t list_len, 421 - const char *name, 422 - size_t name_len, 423 - int type) 424 - { 425 - struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); 426 - const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); 427 - 428 - if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) 429 - return 0; 430 - 431 - if (list && size <= list_len) 432 - memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); 433 - return size; 434 - } 435 - 436 - static int ocfs2_xattr_get_acl(struct dentry *dentry, const char *name, 437 - void *buffer, size_t size, int type) 438 - { 439 - struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); 440 - struct posix_acl *acl; 441 - int ret; 442 - 443 - if (strcmp(name, "") != 0) 444 - return -EINVAL; 445 - if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) 446 - return -EOPNOTSUPP; 447 - 448 - acl = ocfs2_get_acl(dentry->d_inode, type); 449 - if (IS_ERR(acl)) 450 - return PTR_ERR(acl); 451 - if (acl == NULL) 452 - return -ENODATA; 453 - ret = posix_acl_to_xattr(&init_user_ns, acl, buffer, size); 454 - posix_acl_release(acl); 455 - 456 - return ret; 457 - } 458 - 459 - static int ocfs2_xattr_set_acl(struct dentry *dentry, const char *name, 460 - const void *value, size_t size, int flags, int type) 461 - { 462 - struct inode *inode = dentry->d_inode; 463 - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 464 - struct posix_acl *acl; 465 - int ret = 0; 466 - 467 - if (strcmp(name, "") != 0) 468 - return -EINVAL; 469 - if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) 470 - return -EOPNOTSUPP; 471 - 472 - if (!inode_owner_or_capable(inode)) 473 - return -EPERM; 474 - 475 - if (value) { 476 - acl = posix_acl_from_xattr(&init_user_ns, value, size); 477 - if (IS_ERR(acl)) 478 - return PTR_ERR(acl); 479 - else if (acl) { 480 - ret = posix_acl_valid(acl); 481 - if (ret) 482 - goto cleanup; 483 - } 484 - } else 485 - acl = NULL; 486 - 487 - ret = ocfs2_set_acl(NULL, inode, NULL, type, acl, NULL, NULL); 488 - 489 - cleanup: 490 - posix_acl_release(acl); 491 - return ret; 492 - } 493 - 494 - const struct xattr_handler ocfs2_xattr_acl_access_handler = { 495 - .prefix = POSIX_ACL_XATTR_ACCESS, 496 - .flags = ACL_TYPE_ACCESS, 497 - .list = ocfs2_xattr_list_acl_access, 498 - .get = ocfs2_xattr_get_acl, 499 - .set = ocfs2_xattr_set_acl, 500 - }; 501 - 502 - const struct xattr_handler ocfs2_xattr_acl_default_handler = { 503 - .prefix = POSIX_ACL_XATTR_DEFAULT, 504 - .flags = ACL_TYPE_DEFAULT, 505 - .list = ocfs2_xattr_list_acl_default, 506 - .get = ocfs2_xattr_get_acl, 507 - .set = ocfs2_xattr_set_acl, 508 - };
+8 -5
fs/ocfs2/acl.h
··· 27 27 }; 28 28 29 29 struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type); 30 - extern int ocfs2_acl_chmod(struct inode *); 31 - extern int ocfs2_init_acl(handle_t *, struct inode *, struct inode *, 32 - struct buffer_head *, struct buffer_head *, 33 - struct ocfs2_alloc_context *, 34 - struct ocfs2_alloc_context *); 30 + int ocfs2_iop_set_acl(struct inode *inode, struct posix_acl *acl, int type); 31 + int ocfs2_set_acl(handle_t *handle, 32 + struct inode *inode, 33 + struct buffer_head *di_bh, 34 + int type, 35 + struct posix_acl *acl, 36 + struct ocfs2_alloc_context *meta_ac, 37 + struct ocfs2_alloc_context *data_ac); 35 38 36 39 #endif /* OCFS2_ACL_H */
+3 -1
fs/ocfs2/file.c
··· 1236 1236 dqput(transfer_to[qtype]); 1237 1237 1238 1238 if (!status && attr->ia_valid & ATTR_MODE) { 1239 - status = ocfs2_acl_chmod(inode); 1239 + status = posix_acl_chmod(inode, inode->i_mode); 1240 1240 if (status < 0) 1241 1241 mlog_errno(status); 1242 1242 } ··· 2662 2662 .removexattr = generic_removexattr, 2663 2663 .fiemap = ocfs2_fiemap, 2664 2664 .get_acl = ocfs2_iop_get_acl, 2665 + .set_acl = ocfs2_iop_set_acl, 2665 2666 }; 2666 2667 2667 2668 const struct inode_operations ocfs2_special_file_iops = { ··· 2670 2669 .getattr = ocfs2_getattr, 2671 2670 .permission = ocfs2_permission, 2672 2671 .get_acl = ocfs2_iop_get_acl, 2672 + .set_acl = ocfs2_iop_set_acl, 2673 2673 }; 2674 2674 2675 2675 /*
+23 -2
fs/ocfs2/namei.c
··· 230 230 struct ocfs2_dir_lookup_result lookup = { NULL, }; 231 231 sigset_t oldset; 232 232 int did_block_signals = 0; 233 + struct posix_acl *default_acl = NULL, *acl = NULL; 233 234 234 235 trace_ocfs2_mknod(dir, dentry, dentry->d_name.len, dentry->d_name.name, 235 236 (unsigned long long)OCFS2_I(dir)->ip_blkno, ··· 332 331 goto leave; 333 332 } 334 333 334 + status = posix_acl_create(dir, &mode, &default_acl, &acl); 335 + if (status) { 336 + mlog_errno(status); 337 + goto leave; 338 + } 339 + 335 340 handle = ocfs2_start_trans(osb, ocfs2_mknod_credits(osb->sb, 336 341 S_ISDIR(mode), 337 342 xattr_credits)); ··· 386 379 inc_nlink(dir); 387 380 } 388 381 389 - status = ocfs2_init_acl(handle, inode, dir, new_fe_bh, parent_fe_bh, 390 - meta_ac, data_ac); 382 + if (default_acl) { 383 + status = ocfs2_set_acl(handle, inode, new_fe_bh, 384 + ACL_TYPE_DEFAULT, default_acl, 385 + meta_ac, data_ac); 386 + } 387 + if (!status && acl) { 388 + status = ocfs2_set_acl(handle, inode, new_fe_bh, 389 + ACL_TYPE_ACCESS, acl, 390 + meta_ac, data_ac); 391 + } 392 + 391 393 if (status < 0) { 392 394 mlog_errno(status); 393 395 goto leave; ··· 435 419 d_instantiate(dentry, inode); 436 420 status = 0; 437 421 leave: 422 + if (default_acl) 423 + posix_acl_release(default_acl); 424 + if (acl) 425 + posix_acl_release(acl); 438 426 if (status < 0 && did_quota_inode) 439 427 dquot_free_inode(inode); 440 428 if (handle) ··· 2524 2504 .removexattr = generic_removexattr, 2525 2505 .fiemap = ocfs2_fiemap, 2526 2506 .get_acl = ocfs2_iop_get_acl, 2507 + .set_acl = ocfs2_iop_set_acl, 2527 2508 };
+17 -2
fs/ocfs2/refcounttree.c
··· 46 46 #include <linux/quotaops.h> 47 47 #include <linux/namei.h> 48 48 #include <linux/mount.h> 49 + #include <linux/posix_acl.h> 49 50 50 51 struct ocfs2_cow_context { 51 52 struct inode *inode; ··· 4269 4268 struct inode *inode = old_dentry->d_inode; 4270 4269 struct buffer_head *old_bh = NULL; 4271 4270 struct inode *new_orphan_inode = NULL; 4271 + struct posix_acl *default_acl, *acl; 4272 + umode_t mode; 4272 4273 4273 4274 if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb))) 4274 4275 return -EOPNOTSUPP; 4275 4276 4276 - error = ocfs2_create_inode_in_orphan(dir, inode->i_mode, 4277 + mode = inode->i_mode; 4278 + error = posix_acl_create(dir, &mode, &default_acl, &acl); 4279 + if (error) { 4280 + mlog_errno(error); 4281 + goto out; 4282 + } 4283 + 4284 + error = ocfs2_create_inode_in_orphan(dir, mode, 4277 4285 &new_orphan_inode); 4278 4286 if (error) { 4279 4287 mlog_errno(error); ··· 4313 4303 /* If the security isn't preserved, we need to re-initialize them. */ 4314 4304 if (!preserve) { 4315 4305 error = ocfs2_init_security_and_acl(dir, new_orphan_inode, 4316 - &new_dentry->d_name); 4306 + &new_dentry->d_name, 4307 + default_acl, acl); 4317 4308 if (error) 4318 4309 mlog_errno(error); 4319 4310 } 4320 4311 out: 4312 + if (default_acl) 4313 + posix_acl_release(default_acl); 4314 + if (acl) 4315 + posix_acl_release(acl); 4321 4316 if (!error) { 4322 4317 error = ocfs2_mv_orphaned_inode_to_new(dir, new_orphan_inode, 4323 4318 new_dentry);
+12 -9
fs/ocfs2/xattr.c
··· 99 99 100 100 const struct xattr_handler *ocfs2_xattr_handlers[] = { 101 101 &ocfs2_xattr_user_handler, 102 - &ocfs2_xattr_acl_access_handler, 103 - &ocfs2_xattr_acl_default_handler, 102 + &posix_acl_access_xattr_handler, 103 + &posix_acl_default_xattr_handler, 104 104 &ocfs2_xattr_trusted_handler, 105 105 &ocfs2_xattr_security_handler, 106 106 NULL ··· 109 109 static const struct xattr_handler *ocfs2_xattr_handler_map[OCFS2_XATTR_MAX] = { 110 110 [OCFS2_XATTR_INDEX_USER] = &ocfs2_xattr_user_handler, 111 111 [OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS] 112 - = &ocfs2_xattr_acl_access_handler, 112 + = &posix_acl_access_xattr_handler, 113 113 [OCFS2_XATTR_INDEX_POSIX_ACL_DEFAULT] 114 - = &ocfs2_xattr_acl_default_handler, 114 + = &posix_acl_default_xattr_handler, 115 115 [OCFS2_XATTR_INDEX_TRUSTED] = &ocfs2_xattr_trusted_handler, 116 116 [OCFS2_XATTR_INDEX_SECURITY] = &ocfs2_xattr_security_handler, 117 117 }; ··· 7190 7190 */ 7191 7191 int ocfs2_init_security_and_acl(struct inode *dir, 7192 7192 struct inode *inode, 7193 - const struct qstr *qstr) 7193 + const struct qstr *qstr, 7194 + struct posix_acl *default_acl, 7195 + struct posix_acl *acl) 7194 7196 { 7195 - int ret = 0; 7196 7197 struct buffer_head *dir_bh = NULL; 7198 + int ret = 0; 7197 7199 7198 7200 ret = ocfs2_init_security_get(inode, dir, qstr, NULL); 7199 7201 if (ret) { ··· 7209 7207 goto leave; 7210 7208 } 7211 7209 7212 - ret = ocfs2_init_acl(NULL, inode, dir, NULL, dir_bh, NULL, NULL); 7213 - if (ret) 7214 - mlog_errno(ret); 7210 + if (!ret && default_acl) 7211 + ret = ocfs2_iop_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); 7212 + if (!ret && acl) 7213 + ret = ocfs2_iop_set_acl(inode, acl, ACL_TYPE_ACCESS); 7215 7214 7216 7215 ocfs2_inode_unlock(dir, 0); 7217 7216 brelse(dir_bh);
+3 -3
fs/ocfs2/xattr.h
··· 40 40 extern const struct xattr_handler ocfs2_xattr_user_handler; 41 41 extern const struct xattr_handler ocfs2_xattr_trusted_handler; 42 42 extern const struct xattr_handler ocfs2_xattr_security_handler; 43 - extern const struct xattr_handler ocfs2_xattr_acl_access_handler; 44 - extern const struct xattr_handler ocfs2_xattr_acl_default_handler; 45 43 extern const struct xattr_handler *ocfs2_xattr_handlers[]; 46 44 47 45 ssize_t ocfs2_listxattr(struct dentry *, char *, size_t); ··· 94 96 bool preserve_security); 95 97 int ocfs2_init_security_and_acl(struct inode *dir, 96 98 struct inode *inode, 97 - const struct qstr *qstr); 99 + const struct qstr *qstr, 100 + struct posix_acl *default_acl, 101 + struct posix_acl *acl); 98 102 #endif /* OCFS2_XATTR_H */
+416 -12
fs/posix_acl.c
··· 1 1 /* 2 - * linux/fs/posix_acl.c 2 + * Copyright (C) 2002,2003 by Andreas Gruenbacher <a.gruenbacher@computer.org> 3 3 * 4 - * Copyright (C) 2002 by Andreas Gruenbacher <a.gruenbacher@computer.org> 5 - * 6 - * Fixes from William Schumacher incorporated on 15 March 2001. 7 - * (Reported by Charles Bertsch, <CBertsch@microtest.com>). 4 + * Fixes from William Schumacher incorporated on 15 March 2001. 5 + * (Reported by Charles Bertsch, <CBertsch@microtest.com>). 8 6 */ 9 7 10 8 /* ··· 16 18 #include <linux/fs.h> 17 19 #include <linux/sched.h> 18 20 #include <linux/posix_acl.h> 21 + #include <linux/posix_acl_xattr.h> 22 + #include <linux/xattr.h> 19 23 #include <linux/export.h> 20 - 21 - #include <linux/errno.h> 24 + #include <linux/user_namespace.h> 22 25 23 26 struct posix_acl **acl_by_type(struct inode *inode, int type) 24 27 { ··· 95 96 posix_acl_release(old_default); 96 97 } 97 98 EXPORT_SYMBOL(forget_all_cached_acls); 99 + 100 + struct posix_acl *get_acl(struct inode *inode, int type) 101 + { 102 + struct posix_acl *acl; 103 + 104 + acl = get_cached_acl(inode, type); 105 + if (acl != ACL_NOT_CACHED) 106 + return acl; 107 + 108 + if (!IS_POSIXACL(inode)) 109 + return NULL; 110 + 111 + /* 112 + * A filesystem can force a ACL callback by just never filling the 113 + * ACL cache. But normally you'd fill the cache either at inode 114 + * instantiation time, or on the first ->get_acl call. 115 + * 116 + * If the filesystem doesn't have a get_acl() function at all, we'll 117 + * just create the negative cache entry. 118 + */ 119 + if (!inode->i_op->get_acl) { 120 + set_cached_acl(inode, type, NULL); 121 + return NULL; 122 + } 123 + return inode->i_op->get_acl(inode, type); 124 + } 125 + EXPORT_SYMBOL(get_acl); 98 126 99 127 /* 100 128 * Init a fresh posix_acl ··· 428 402 /* 429 403 * Modify the ACL for the chmod syscall. 430 404 */ 431 - static int posix_acl_chmod_masq(struct posix_acl *acl, umode_t mode) 405 + static int __posix_acl_chmod_masq(struct posix_acl *acl, umode_t mode) 432 406 { 433 407 struct posix_acl_entry *group_obj = NULL, *mask_obj = NULL; 434 408 struct posix_acl_entry *pa, *pe; ··· 474 448 } 475 449 476 450 int 477 - posix_acl_create(struct posix_acl **acl, gfp_t gfp, umode_t *mode_p) 451 + __posix_acl_create(struct posix_acl **acl, gfp_t gfp, umode_t *mode_p) 478 452 { 479 453 struct posix_acl *clone = posix_acl_clone(*acl, gfp); 480 454 int err = -ENOMEM; ··· 489 463 *acl = clone; 490 464 return err; 491 465 } 492 - EXPORT_SYMBOL(posix_acl_create); 466 + EXPORT_SYMBOL(__posix_acl_create); 493 467 494 468 int 495 - posix_acl_chmod(struct posix_acl **acl, gfp_t gfp, umode_t mode) 469 + __posix_acl_chmod(struct posix_acl **acl, gfp_t gfp, umode_t mode) 496 470 { 497 471 struct posix_acl *clone = posix_acl_clone(*acl, gfp); 498 472 int err = -ENOMEM; 499 473 if (clone) { 500 - err = posix_acl_chmod_masq(clone, mode); 474 + err = __posix_acl_chmod_masq(clone, mode); 501 475 if (err) { 502 476 posix_acl_release(clone); 503 477 clone = NULL; ··· 507 481 *acl = clone; 508 482 return err; 509 483 } 484 + EXPORT_SYMBOL(__posix_acl_chmod); 485 + 486 + int 487 + posix_acl_chmod(struct inode *inode, umode_t mode) 488 + { 489 + struct posix_acl *acl; 490 + int ret = 0; 491 + 492 + if (!IS_POSIXACL(inode)) 493 + return 0; 494 + if (!inode->i_op->set_acl) 495 + return -EOPNOTSUPP; 496 + 497 + acl = get_acl(inode, ACL_TYPE_ACCESS); 498 + if (IS_ERR_OR_NULL(acl)) 499 + return PTR_ERR(acl); 500 + 501 + ret = __posix_acl_chmod(&acl, GFP_KERNEL, mode); 502 + if (ret) 503 + return ret; 504 + ret = inode->i_op->set_acl(inode, acl, ACL_TYPE_ACCESS); 505 + posix_acl_release(acl); 506 + return ret; 507 + } 510 508 EXPORT_SYMBOL(posix_acl_chmod); 509 + 510 + int 511 + posix_acl_create(struct inode *dir, umode_t *mode, 512 + struct posix_acl **default_acl, struct posix_acl **acl) 513 + { 514 + struct posix_acl *p; 515 + int ret; 516 + 517 + if (S_ISLNK(*mode) || !IS_POSIXACL(dir)) 518 + goto no_acl; 519 + 520 + p = get_acl(dir, ACL_TYPE_DEFAULT); 521 + if (IS_ERR(p)) 522 + return PTR_ERR(p); 523 + 524 + if (!p) { 525 + *mode &= ~current_umask(); 526 + goto no_acl; 527 + } 528 + 529 + *acl = posix_acl_clone(p, GFP_NOFS); 530 + if (!*acl) 531 + return -ENOMEM; 532 + 533 + ret = posix_acl_create_masq(*acl, mode); 534 + if (ret < 0) { 535 + posix_acl_release(*acl); 536 + return -ENOMEM; 537 + } 538 + 539 + if (ret == 0) { 540 + posix_acl_release(*acl); 541 + *acl = NULL; 542 + } 543 + 544 + if (!S_ISDIR(*mode)) { 545 + posix_acl_release(p); 546 + *default_acl = NULL; 547 + } else { 548 + *default_acl = p; 549 + } 550 + return 0; 551 + 552 + no_acl: 553 + *default_acl = NULL; 554 + *acl = NULL; 555 + return 0; 556 + } 557 + EXPORT_SYMBOL_GPL(posix_acl_create); 558 + 559 + /* 560 + * Fix up the uids and gids in posix acl extended attributes in place. 561 + */ 562 + static void posix_acl_fix_xattr_userns( 563 + struct user_namespace *to, struct user_namespace *from, 564 + void *value, size_t size) 565 + { 566 + posix_acl_xattr_header *header = (posix_acl_xattr_header *)value; 567 + posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end; 568 + int count; 569 + kuid_t uid; 570 + kgid_t gid; 571 + 572 + if (!value) 573 + return; 574 + if (size < sizeof(posix_acl_xattr_header)) 575 + return; 576 + if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION)) 577 + return; 578 + 579 + count = posix_acl_xattr_count(size); 580 + if (count < 0) 581 + return; 582 + if (count == 0) 583 + return; 584 + 585 + for (end = entry + count; entry != end; entry++) { 586 + switch(le16_to_cpu(entry->e_tag)) { 587 + case ACL_USER: 588 + uid = make_kuid(from, le32_to_cpu(entry->e_id)); 589 + entry->e_id = cpu_to_le32(from_kuid(to, uid)); 590 + break; 591 + case ACL_GROUP: 592 + gid = make_kgid(from, le32_to_cpu(entry->e_id)); 593 + entry->e_id = cpu_to_le32(from_kgid(to, gid)); 594 + break; 595 + default: 596 + break; 597 + } 598 + } 599 + } 600 + 601 + void posix_acl_fix_xattr_from_user(void *value, size_t size) 602 + { 603 + struct user_namespace *user_ns = current_user_ns(); 604 + if (user_ns == &init_user_ns) 605 + return; 606 + posix_acl_fix_xattr_userns(&init_user_ns, user_ns, value, size); 607 + } 608 + 609 + void posix_acl_fix_xattr_to_user(void *value, size_t size) 610 + { 611 + struct user_namespace *user_ns = current_user_ns(); 612 + if (user_ns == &init_user_ns) 613 + return; 614 + posix_acl_fix_xattr_userns(user_ns, &init_user_ns, value, size); 615 + } 616 + 617 + /* 618 + * Convert from extended attribute to in-memory representation. 619 + */ 620 + struct posix_acl * 621 + posix_acl_from_xattr(struct user_namespace *user_ns, 622 + const void *value, size_t size) 623 + { 624 + posix_acl_xattr_header *header = (posix_acl_xattr_header *)value; 625 + posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end; 626 + int count; 627 + struct posix_acl *acl; 628 + struct posix_acl_entry *acl_e; 629 + 630 + if (!value) 631 + return NULL; 632 + if (size < sizeof(posix_acl_xattr_header)) 633 + return ERR_PTR(-EINVAL); 634 + if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION)) 635 + return ERR_PTR(-EOPNOTSUPP); 636 + 637 + count = posix_acl_xattr_count(size); 638 + if (count < 0) 639 + return ERR_PTR(-EINVAL); 640 + if (count == 0) 641 + return NULL; 642 + 643 + acl = posix_acl_alloc(count, GFP_NOFS); 644 + if (!acl) 645 + return ERR_PTR(-ENOMEM); 646 + acl_e = acl->a_entries; 647 + 648 + for (end = entry + count; entry != end; acl_e++, entry++) { 649 + acl_e->e_tag = le16_to_cpu(entry->e_tag); 650 + acl_e->e_perm = le16_to_cpu(entry->e_perm); 651 + 652 + switch(acl_e->e_tag) { 653 + case ACL_USER_OBJ: 654 + case ACL_GROUP_OBJ: 655 + case ACL_MASK: 656 + case ACL_OTHER: 657 + break; 658 + 659 + case ACL_USER: 660 + acl_e->e_uid = 661 + make_kuid(user_ns, 662 + le32_to_cpu(entry->e_id)); 663 + if (!uid_valid(acl_e->e_uid)) 664 + goto fail; 665 + break; 666 + case ACL_GROUP: 667 + acl_e->e_gid = 668 + make_kgid(user_ns, 669 + le32_to_cpu(entry->e_id)); 670 + if (!gid_valid(acl_e->e_gid)) 671 + goto fail; 672 + break; 673 + 674 + default: 675 + goto fail; 676 + } 677 + } 678 + return acl; 679 + 680 + fail: 681 + posix_acl_release(acl); 682 + return ERR_PTR(-EINVAL); 683 + } 684 + EXPORT_SYMBOL (posix_acl_from_xattr); 685 + 686 + /* 687 + * Convert from in-memory to extended attribute representation. 688 + */ 689 + int 690 + posix_acl_to_xattr(struct user_namespace *user_ns, const struct posix_acl *acl, 691 + void *buffer, size_t size) 692 + { 693 + posix_acl_xattr_header *ext_acl = (posix_acl_xattr_header *)buffer; 694 + posix_acl_xattr_entry *ext_entry = ext_acl->a_entries; 695 + int real_size, n; 696 + 697 + real_size = posix_acl_xattr_size(acl->a_count); 698 + if (!buffer) 699 + return real_size; 700 + if (real_size > size) 701 + return -ERANGE; 702 + 703 + ext_acl->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION); 704 + 705 + for (n=0; n < acl->a_count; n++, ext_entry++) { 706 + const struct posix_acl_entry *acl_e = &acl->a_entries[n]; 707 + ext_entry->e_tag = cpu_to_le16(acl_e->e_tag); 708 + ext_entry->e_perm = cpu_to_le16(acl_e->e_perm); 709 + switch(acl_e->e_tag) { 710 + case ACL_USER: 711 + ext_entry->e_id = 712 + cpu_to_le32(from_kuid(user_ns, acl_e->e_uid)); 713 + break; 714 + case ACL_GROUP: 715 + ext_entry->e_id = 716 + cpu_to_le32(from_kgid(user_ns, acl_e->e_gid)); 717 + break; 718 + default: 719 + ext_entry->e_id = cpu_to_le32(ACL_UNDEFINED_ID); 720 + break; 721 + } 722 + } 723 + return real_size; 724 + } 725 + EXPORT_SYMBOL (posix_acl_to_xattr); 726 + 727 + static int 728 + posix_acl_xattr_get(struct dentry *dentry, const char *name, 729 + void *value, size_t size, int type) 730 + { 731 + struct posix_acl *acl; 732 + int error; 733 + 734 + if (!IS_POSIXACL(dentry->d_inode)) 735 + return -EOPNOTSUPP; 736 + if (S_ISLNK(dentry->d_inode->i_mode)) 737 + return -EOPNOTSUPP; 738 + 739 + acl = get_acl(dentry->d_inode, type); 740 + if (IS_ERR(acl)) 741 + return PTR_ERR(acl); 742 + if (acl == NULL) 743 + return -ENODATA; 744 + 745 + error = posix_acl_to_xattr(&init_user_ns, acl, value, size); 746 + posix_acl_release(acl); 747 + 748 + return error; 749 + } 750 + 751 + static int 752 + posix_acl_xattr_set(struct dentry *dentry, const char *name, 753 + const void *value, size_t size, int flags, int type) 754 + { 755 + struct inode *inode = dentry->d_inode; 756 + struct posix_acl *acl = NULL; 757 + int ret; 758 + 759 + if (!IS_POSIXACL(inode)) 760 + return -EOPNOTSUPP; 761 + if (!inode->i_op->set_acl) 762 + return -EOPNOTSUPP; 763 + 764 + if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) 765 + return value ? -EACCES : 0; 766 + if (!inode_owner_or_capable(inode)) 767 + return -EPERM; 768 + 769 + if (value) { 770 + acl = posix_acl_from_xattr(&init_user_ns, value, size); 771 + if (IS_ERR(acl)) 772 + return PTR_ERR(acl); 773 + 774 + if (acl) { 775 + ret = posix_acl_valid(acl); 776 + if (ret) 777 + goto out; 778 + } 779 + } 780 + 781 + ret = inode->i_op->set_acl(inode, acl, type); 782 + out: 783 + posix_acl_release(acl); 784 + return ret; 785 + } 786 + 787 + static size_t 788 + posix_acl_xattr_list(struct dentry *dentry, char *list, size_t list_size, 789 + const char *name, size_t name_len, int type) 790 + { 791 + const char *xname; 792 + size_t size; 793 + 794 + if (!IS_POSIXACL(dentry->d_inode)) 795 + return -EOPNOTSUPP; 796 + if (S_ISLNK(dentry->d_inode->i_mode)) 797 + return -EOPNOTSUPP; 798 + 799 + if (type == ACL_TYPE_ACCESS) 800 + xname = POSIX_ACL_XATTR_ACCESS; 801 + else 802 + xname = POSIX_ACL_XATTR_DEFAULT; 803 + 804 + size = strlen(xname) + 1; 805 + if (list && size <= list_size) 806 + memcpy(list, xname, size); 807 + return size; 808 + } 809 + 810 + const struct xattr_handler posix_acl_access_xattr_handler = { 811 + .prefix = POSIX_ACL_XATTR_ACCESS, 812 + .flags = ACL_TYPE_ACCESS, 813 + .list = posix_acl_xattr_list, 814 + .get = posix_acl_xattr_get, 815 + .set = posix_acl_xattr_set, 816 + }; 817 + EXPORT_SYMBOL_GPL(posix_acl_access_xattr_handler); 818 + 819 + const struct xattr_handler posix_acl_default_xattr_handler = { 820 + .prefix = POSIX_ACL_XATTR_DEFAULT, 821 + .flags = ACL_TYPE_DEFAULT, 822 + .list = posix_acl_xattr_list, 823 + .get = posix_acl_xattr_get, 824 + .set = posix_acl_xattr_set, 825 + }; 826 + EXPORT_SYMBOL_GPL(posix_acl_default_xattr_handler); 827 + 828 + int simple_set_acl(struct inode *inode, struct posix_acl *acl, int type) 829 + { 830 + int error; 831 + 832 + if (type == ACL_TYPE_ACCESS) { 833 + error = posix_acl_equiv_mode(acl, &inode->i_mode); 834 + if (error < 0) 835 + return 0; 836 + if (error == 0) 837 + acl = NULL; 838 + } 839 + 840 + inode->i_ctime = CURRENT_TIME; 841 + set_cached_acl(inode, type, acl); 842 + return 0; 843 + } 844 + 845 + int simple_acl_create(struct inode *dir, struct inode *inode) 846 + { 847 + struct posix_acl *default_acl, *acl; 848 + int error; 849 + 850 + error = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl); 851 + if (error) 852 + return error; 853 + 854 + set_cached_acl(inode, ACL_TYPE_DEFAULT, default_acl); 855 + set_cached_acl(inode, ACL_TYPE_ACCESS, acl); 856 + 857 + if (default_acl) 858 + posix_acl_release(default_acl); 859 + if (acl) 860 + posix_acl_release(acl); 861 + return 0; 862 + }
+22 -41
fs/qnx4/inode.c
··· 27 27 28 28 static const struct super_operations qnx4_sops; 29 29 30 - static void qnx4_put_super(struct super_block *sb); 31 30 static struct inode *qnx4_alloc_inode(struct super_block *sb); 32 31 static void qnx4_destroy_inode(struct inode *inode); 33 32 static int qnx4_remount(struct super_block *sb, int *flags, char *data); ··· 36 37 { 37 38 .alloc_inode = qnx4_alloc_inode, 38 39 .destroy_inode = qnx4_destroy_inode, 39 - .put_super = qnx4_put_super, 40 40 .statfs = qnx4_statfs, 41 41 .remount_fs = qnx4_remount, 42 42 }; ··· 146 148 * it really _is_ a qnx4 filesystem, and to check the size 147 149 * of the directory entry. 148 150 */ 149 - static const char *qnx4_checkroot(struct super_block *sb) 151 + static const char *qnx4_checkroot(struct super_block *sb, 152 + struct qnx4_super_block *s) 150 153 { 151 154 struct buffer_head *bh; 152 155 struct qnx4_inode_entry *rootdir; 153 156 int rd, rl; 154 157 int i, j; 155 158 156 - if (*(qnx4_sb(sb)->sb->RootDir.di_fname) != '/') 159 + if (s->RootDir.di_fname[0] != '/' || s->RootDir.di_fname[1] != '\0') 157 160 return "no qnx4 filesystem (no root dir)."; 158 161 QNX4DEBUG((KERN_NOTICE "QNX4 filesystem found on dev %s.\n", sb->s_id)); 159 - rd = le32_to_cpu(qnx4_sb(sb)->sb->RootDir.di_first_xtnt.xtnt_blk) - 1; 160 - rl = le32_to_cpu(qnx4_sb(sb)->sb->RootDir.di_first_xtnt.xtnt_size); 162 + rd = le32_to_cpu(s->RootDir.di_first_xtnt.xtnt_blk) - 1; 163 + rl = le32_to_cpu(s->RootDir.di_first_xtnt.xtnt_size); 161 164 for (j = 0; j < rl; j++) { 162 165 bh = sb_bread(sb, rd + j); /* root dir, first block */ 163 166 if (bh == NULL) ··· 188 189 struct inode *root; 189 190 const char *errmsg; 190 191 struct qnx4_sb_info *qs; 191 - int ret = -EINVAL; 192 192 193 193 qs = kzalloc(sizeof(struct qnx4_sb_info), GFP_KERNEL); 194 194 if (!qs) ··· 196 198 197 199 sb_set_blocksize(s, QNX4_BLOCK_SIZE); 198 200 201 + s->s_op = &qnx4_sops; 202 + s->s_magic = QNX4_SUPER_MAGIC; 203 + s->s_flags |= MS_RDONLY; /* Yup, read-only yet */ 204 + 199 205 /* Check the superblock signature. Since the qnx4 code is 200 206 dangerous, we should leave as quickly as possible 201 207 if we don't belong here... */ 202 208 bh = sb_bread(s, 1); 203 209 if (!bh) { 204 210 printk(KERN_ERR "qnx4: unable to read the superblock\n"); 205 - goto outnobh; 211 + return -EINVAL; 206 212 } 207 - if ( le32_to_cpup((__le32*) bh->b_data) != QNX4_SUPER_MAGIC ) { 208 - if (!silent) 209 - printk(KERN_ERR "qnx4: wrong fsid in superblock.\n"); 210 - goto out; 211 - } 212 - s->s_op = &qnx4_sops; 213 - s->s_magic = QNX4_SUPER_MAGIC; 214 - s->s_flags |= MS_RDONLY; /* Yup, read-only yet */ 215 - qnx4_sb(s)->sb_buf = bh; 216 - qnx4_sb(s)->sb = (struct qnx4_super_block *) bh->b_data; 217 - 218 213 219 214 /* check before allocating dentries, inodes, .. */ 220 - errmsg = qnx4_checkroot(s); 215 + errmsg = qnx4_checkroot(s, (struct qnx4_super_block *) bh->b_data); 216 + brelse(bh); 221 217 if (errmsg != NULL) { 222 218 if (!silent) 223 219 printk(KERN_ERR "qnx4: %s\n", errmsg); 224 - goto out; 220 + return -EINVAL; 225 221 } 226 222 227 223 /* does root not have inode number QNX4_ROOT_INO ?? */ 228 224 root = qnx4_iget(s, QNX4_ROOT_INO * QNX4_INODES_PER_BLOCK); 229 225 if (IS_ERR(root)) { 230 226 printk(KERN_ERR "qnx4: get inode failed\n"); 231 - ret = PTR_ERR(root); 232 - goto outb; 227 + return PTR_ERR(root); 233 228 } 234 229 235 - ret = -ENOMEM; 236 230 s->s_root = d_make_root(root); 237 231 if (s->s_root == NULL) 238 - goto outb; 232 + return -ENOMEM; 239 233 240 - brelse(bh); 241 234 return 0; 242 - 243 - outb: 244 - kfree(qs->BitMap); 245 - out: 246 - brelse(bh); 247 - outnobh: 248 - kfree(qs); 249 - s->s_fs_info = NULL; 250 - return ret; 251 235 } 252 236 253 - static void qnx4_put_super(struct super_block *sb) 237 + static void qnx4_kill_sb(struct super_block *sb) 254 238 { 255 239 struct qnx4_sb_info *qs = qnx4_sb(sb); 256 - kfree( qs->BitMap ); 257 - kfree( qs ); 258 - sb->s_fs_info = NULL; 259 - return; 240 + kill_block_super(sb); 241 + if (qs) { 242 + kfree(qs->BitMap); 243 + kfree(qs); 244 + } 260 245 } 261 246 262 247 static int qnx4_readpage(struct file *file, struct page *page) ··· 390 409 .owner = THIS_MODULE, 391 410 .name = "qnx4", 392 411 .mount = qnx4_mount, 393 - .kill_sb = kill_block_super, 412 + .kill_sb = qnx4_kill_sb, 394 413 .fs_flags = FS_REQUIRES_DEV, 395 414 }; 396 415 MODULE_ALIAS_FS("qnx4");
-2
fs/qnx4/qnx4.h
··· 10 10 #endif 11 11 12 12 struct qnx4_sb_info { 13 - struct buffer_head *sb_buf; /* superblock buffer */ 14 - struct qnx4_super_block *sb; /* our superblock */ 15 13 unsigned int Version; /* may be useful */ 16 14 struct qnx4_inode_entry *BitMap; /* useful */ 17 15 };
+2 -2
fs/reiserfs/acl.h
··· 48 48 49 49 #ifdef CONFIG_REISERFS_FS_POSIX_ACL 50 50 struct posix_acl *reiserfs_get_acl(struct inode *inode, int type); 51 + int reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type); 51 52 int reiserfs_acl_chmod(struct inode *inode); 52 53 int reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th, 53 54 struct inode *dir, struct dentry *dentry, 54 55 struct inode *inode); 55 56 int reiserfs_cache_default_acl(struct inode *dir); 56 - extern const struct xattr_handler reiserfs_posix_acl_default_handler; 57 - extern const struct xattr_handler reiserfs_posix_acl_access_handler; 58 57 59 58 #else 60 59 61 60 #define reiserfs_cache_default_acl(inode) 0 62 61 #define reiserfs_get_acl NULL 62 + #define reiserfs_set_acl NULL 63 63 64 64 static inline int reiserfs_acl_chmod(struct inode *inode) 65 65 {
+1
fs/reiserfs/file.c
··· 260 260 .removexattr = reiserfs_removexattr, 261 261 .permission = reiserfs_permission, 262 262 .get_acl = reiserfs_get_acl, 263 + .set_acl = reiserfs_set_acl, 263 264 };
+2 -2
fs/reiserfs/namei.c
··· 1522 1522 .removexattr = reiserfs_removexattr, 1523 1523 .permission = reiserfs_permission, 1524 1524 .get_acl = reiserfs_get_acl, 1525 + .set_acl = reiserfs_set_acl, 1525 1526 }; 1526 1527 1527 1528 /* ··· 1539 1538 .listxattr = reiserfs_listxattr, 1540 1539 .removexattr = reiserfs_removexattr, 1541 1540 .permission = reiserfs_permission, 1542 - .get_acl = reiserfs_get_acl, 1543 - 1544 1541 }; 1545 1542 1546 1543 /* ··· 1552 1553 .removexattr = reiserfs_removexattr, 1553 1554 .permission = reiserfs_permission, 1554 1555 .get_acl = reiserfs_get_acl, 1556 + .set_acl = reiserfs_set_acl, 1555 1557 };
+2 -2
fs/reiserfs/procfs.c
··· 419 419 char *s; 420 420 421 421 /* Some block devices use /'s */ 422 - strlcpy(b, reiserfs_bdevname(sb), BDEVNAME_SIZE); 422 + strlcpy(b, sb->s_id, BDEVNAME_SIZE); 423 423 s = strchr(b, '/'); 424 424 if (s) 425 425 *s = '!'; ··· 449 449 char *s; 450 450 451 451 /* Some block devices use /'s */ 452 - strlcpy(b, reiserfs_bdevname(sb), BDEVNAME_SIZE); 452 + strlcpy(b, sb->s_id, BDEVNAME_SIZE); 453 453 s = strchr(b, '/'); 454 454 if (s) 455 455 *s = '!';
-8
fs/reiserfs/reiserfs.h
··· 608 608 609 609 #define SB_DISK_JOURNAL_HEAD(s) (SB_JOURNAL(s)->j_header_bh->) 610 610 611 - /* A safe version of the "bdevname", which returns the "s_id" field of 612 - * a superblock or else "Null superblock" if the super block is NULL. 613 - */ 614 - static inline char *reiserfs_bdevname(struct super_block *s) 615 - { 616 - return (s == NULL) ? "Null superblock" : s->s_id; 617 - } 618 - 619 611 #define reiserfs_is_journal_aborted(journal) (unlikely (__reiserfs_is_journal_aborted (journal))) 620 612 static inline int __reiserfs_is_journal_aborted(struct reiserfs_journal 621 613 *journal)
+4 -4
fs/reiserfs/super.c
··· 1479 1479 if (!bh) { 1480 1480 reiserfs_warning(s, "sh-2006", 1481 1481 "bread failed (dev %s, block %lu, size %lu)", 1482 - reiserfs_bdevname(s), offset / s->s_blocksize, 1482 + s->s_id, offset / s->s_blocksize, 1483 1483 s->s_blocksize); 1484 1484 return 1; 1485 1485 } ··· 1500 1500 if (!bh) { 1501 1501 reiserfs_warning(s, "sh-2007", 1502 1502 "bread failed (dev %s, block %lu, size %lu)", 1503 - reiserfs_bdevname(s), offset / s->s_blocksize, 1503 + s->s_id, offset / s->s_blocksize, 1504 1504 s->s_blocksize); 1505 1505 return 1; 1506 1506 } ··· 1509 1509 if (sb_blocksize(rs) != s->s_blocksize) { 1510 1510 reiserfs_warning(s, "sh-2011", "can't find a reiserfs " 1511 1511 "filesystem on (dev %s, block %Lu, size %lu)", 1512 - reiserfs_bdevname(s), 1512 + s->s_id, 1513 1513 (unsigned long long)bh->b_blocknr, 1514 1514 s->s_blocksize); 1515 1515 brelse(bh); ··· 1825 1825 /* try new format (64-th 1k block), which can contain reiserfs super block */ 1826 1826 else if (read_super_block(s, REISERFS_DISK_OFFSET_IN_BYTES)) { 1827 1827 SWARN(silent, s, "sh-2021", "can not find reiserfs on %s", 1828 - reiserfs_bdevname(s)); 1828 + s->s_id); 1829 1829 goto error_unlocked; 1830 1830 } 1831 1831
+3 -2
fs/reiserfs/xattr.c
··· 50 50 #include <linux/stat.h> 51 51 #include <linux/quotaops.h> 52 52 #include <linux/security.h> 53 + #include <linux/posix_acl_xattr.h> 53 54 54 55 #define PRIVROOT_NAME ".reiserfs_priv" 55 56 #define XAROOT_NAME "xattrs" ··· 905 904 &reiserfs_xattr_security_handler, 906 905 #endif 907 906 #ifdef CONFIG_REISERFS_FS_POSIX_ACL 908 - &reiserfs_posix_acl_access_handler, 909 - &reiserfs_posix_acl_default_handler, 907 + &posix_acl_access_xattr_handler, 908 + &posix_acl_default_xattr_handler, 910 909 #endif 911 910 NULL 912 911 };
+30 -158
fs/reiserfs/xattr_acl.c
··· 11 11 #include "acl.h" 12 12 #include <asm/uaccess.h> 13 13 14 - static int reiserfs_set_acl(struct reiserfs_transaction_handle *th, 14 + static int __reiserfs_set_acl(struct reiserfs_transaction_handle *th, 15 15 struct inode *inode, int type, 16 16 struct posix_acl *acl); 17 17 18 - static int 19 - posix_acl_set(struct dentry *dentry, const char *name, const void *value, 20 - size_t size, int flags, int type) 18 + 19 + int 20 + reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) 21 21 { 22 - struct inode *inode = dentry->d_inode; 23 - struct posix_acl *acl; 24 22 int error, error2; 25 23 struct reiserfs_transaction_handle th; 26 24 size_t jcreate_blocks; 27 - if (!reiserfs_posixacl(inode->i_sb)) 28 - return -EOPNOTSUPP; 29 - if (!inode_owner_or_capable(inode)) 30 - return -EPERM; 25 + int size = acl ? posix_acl_xattr_size(acl->a_count) : 0; 31 26 32 - if (value) { 33 - acl = posix_acl_from_xattr(&init_user_ns, value, size); 34 - if (IS_ERR(acl)) { 35 - return PTR_ERR(acl); 36 - } else if (acl) { 37 - error = posix_acl_valid(acl); 38 - if (error) 39 - goto release_and_out; 40 - } 41 - } else 42 - acl = NULL; 43 27 44 28 /* Pessimism: We can't assume that anything from the xattr root up 45 29 * has been created. */ ··· 35 51 error = journal_begin(&th, inode->i_sb, jcreate_blocks); 36 52 reiserfs_write_unlock(inode->i_sb); 37 53 if (error == 0) { 38 - error = reiserfs_set_acl(&th, inode, type, acl); 54 + error = __reiserfs_set_acl(&th, inode, type, acl); 39 55 reiserfs_write_lock(inode->i_sb); 40 56 error2 = journal_end(&th, inode->i_sb, jcreate_blocks); 41 57 reiserfs_write_unlock(inode->i_sb); ··· 43 59 error = error2; 44 60 } 45 61 46 - release_and_out: 47 - posix_acl_release(acl); 48 - return error; 49 - } 50 - 51 - static int 52 - posix_acl_get(struct dentry *dentry, const char *name, void *buffer, 53 - size_t size, int type) 54 - { 55 - struct posix_acl *acl; 56 - int error; 57 - 58 - if (!reiserfs_posixacl(dentry->d_sb)) 59 - return -EOPNOTSUPP; 60 - 61 - acl = reiserfs_get_acl(dentry->d_inode, type); 62 - if (IS_ERR(acl)) 63 - return PTR_ERR(acl); 64 - if (acl == NULL) 65 - return -ENODATA; 66 - error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size); 67 - posix_acl_release(acl); 68 - 69 62 return error; 70 63 } 71 64 72 65 /* 73 66 * Convert from filesystem to in-memory representation. 74 67 */ 75 - static struct posix_acl *posix_acl_from_disk(const void *value, size_t size) 68 + static struct posix_acl *reiserfs_posix_acl_from_disk(const void *value, size_t size) 76 69 { 77 70 const char *end = (char *)value + size; 78 71 int n, count; ··· 119 158 /* 120 159 * Convert from in-memory to filesystem representation. 121 160 */ 122 - static void *posix_acl_to_disk(const struct posix_acl *acl, size_t * size) 161 + static void *reiserfs_posix_acl_to_disk(const struct posix_acl *acl, size_t * size) 123 162 { 124 163 reiserfs_acl_header *ext_acl; 125 164 char *e; ··· 182 221 int size; 183 222 int retval; 184 223 185 - acl = get_cached_acl(inode, type); 186 - if (acl != ACL_NOT_CACHED) 187 - return acl; 188 - 189 224 switch (type) { 190 225 case ACL_TYPE_ACCESS: 191 226 name = POSIX_ACL_XATTR_ACCESS; ··· 214 257 } else if (retval < 0) { 215 258 acl = ERR_PTR(retval); 216 259 } else { 217 - acl = posix_acl_from_disk(value, retval); 260 + acl = reiserfs_posix_acl_from_disk(value, retval); 218 261 } 219 262 if (!IS_ERR(acl)) 220 263 set_cached_acl(inode, type, acl); ··· 230 273 * BKL held [before 2.5.x] 231 274 */ 232 275 static int 233 - reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode, 276 + __reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode, 234 277 int type, struct posix_acl *acl) 235 278 { 236 279 char *name; 237 280 void *value = NULL; 238 281 size_t size = 0; 239 282 int error; 240 - 241 - if (S_ISLNK(inode->i_mode)) 242 - return -EOPNOTSUPP; 243 283 244 284 switch (type) { 245 285 case ACL_TYPE_ACCESS: ··· 261 307 } 262 308 263 309 if (acl) { 264 - value = posix_acl_to_disk(acl, &size); 310 + value = reiserfs_posix_acl_to_disk(acl, &size); 265 311 if (IS_ERR(value)) 266 312 return (int)PTR_ERR(value); 267 313 } ··· 297 343 struct inode *dir, struct dentry *dentry, 298 344 struct inode *inode) 299 345 { 300 - struct posix_acl *acl; 346 + struct posix_acl *default_acl, *acl; 301 347 int err = 0; 302 348 303 349 /* ACLs only get applied to files and directories */ ··· 317 363 goto apply_umask; 318 364 } 319 365 320 - acl = reiserfs_get_acl(dir, ACL_TYPE_DEFAULT); 321 - if (IS_ERR(acl)) 322 - return PTR_ERR(acl); 366 + err = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl); 367 + if (err) 368 + return err; 323 369 370 + if (default_acl) { 371 + err = __reiserfs_set_acl(th, inode, ACL_TYPE_DEFAULT, 372 + default_acl); 373 + posix_acl_release(default_acl); 374 + } 324 375 if (acl) { 325 - /* Copy the default ACL to the default ACL of a new directory */ 326 - if (S_ISDIR(inode->i_mode)) { 327 - err = reiserfs_set_acl(th, inode, ACL_TYPE_DEFAULT, 328 - acl); 329 - if (err) 330 - goto cleanup; 331 - } 332 - 333 - /* Now we reconcile the new ACL and the mode, 334 - potentially modifying both */ 335 - err = posix_acl_create(&acl, GFP_NOFS, &inode->i_mode); 336 - if (err < 0) 337 - return err; 338 - 339 - /* If we need an ACL.. */ 340 - if (err > 0) 341 - err = reiserfs_set_acl(th, inode, ACL_TYPE_ACCESS, acl); 342 - cleanup: 376 + if (!err) 377 + err = __reiserfs_set_acl(th, inode, ACL_TYPE_ACCESS, 378 + acl); 343 379 posix_acl_release(acl); 344 - } else { 345 - apply_umask: 346 - /* no ACL, apply umask */ 347 - inode->i_mode &= ~current_umask(); 348 380 } 349 381 382 + return err; 383 + 384 + apply_umask: 385 + /* no ACL, apply umask */ 386 + inode->i_mode &= ~current_umask(); 350 387 return err; 351 388 } 352 389 ··· 387 442 */ 388 443 int reiserfs_acl_chmod(struct inode *inode) 389 444 { 390 - struct reiserfs_transaction_handle th; 391 - struct posix_acl *acl; 392 - size_t size; 393 - int error; 394 - 395 445 if (IS_PRIVATE(inode)) 396 446 return 0; 397 - 398 - if (S_ISLNK(inode->i_mode)) 399 - return -EOPNOTSUPP; 400 - 401 447 if (get_inode_sd_version(inode) == STAT_DATA_V1 || 402 - !reiserfs_posixacl(inode->i_sb)) { 448 + !reiserfs_posixacl(inode->i_sb)) 403 449 return 0; 404 - } 405 450 406 - acl = reiserfs_get_acl(inode, ACL_TYPE_ACCESS); 407 - if (!acl) 408 - return 0; 409 - if (IS_ERR(acl)) 410 - return PTR_ERR(acl); 411 - error = posix_acl_chmod(&acl, GFP_NOFS, inode->i_mode); 412 - if (error) 413 - return error; 414 - 415 - size = reiserfs_xattr_nblocks(inode, reiserfs_acl_size(acl->a_count)); 416 - reiserfs_write_lock(inode->i_sb); 417 - error = journal_begin(&th, inode->i_sb, size * 2); 418 - reiserfs_write_unlock(inode->i_sb); 419 - if (!error) { 420 - int error2; 421 - error = reiserfs_set_acl(&th, inode, ACL_TYPE_ACCESS, acl); 422 - reiserfs_write_lock(inode->i_sb); 423 - error2 = journal_end(&th, inode->i_sb, size * 2); 424 - reiserfs_write_unlock(inode->i_sb); 425 - if (error2) 426 - error = error2; 427 - } 428 - posix_acl_release(acl); 429 - return error; 451 + return posix_acl_chmod(inode, inode->i_mode); 430 452 } 431 - 432 - static size_t posix_acl_access_list(struct dentry *dentry, char *list, 433 - size_t list_size, const char *name, 434 - size_t name_len, int type) 435 - { 436 - const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); 437 - if (!reiserfs_posixacl(dentry->d_sb)) 438 - return 0; 439 - if (list && size <= list_size) 440 - memcpy(list, POSIX_ACL_XATTR_ACCESS, size); 441 - return size; 442 - } 443 - 444 - const struct xattr_handler reiserfs_posix_acl_access_handler = { 445 - .prefix = POSIX_ACL_XATTR_ACCESS, 446 - .flags = ACL_TYPE_ACCESS, 447 - .get = posix_acl_get, 448 - .set = posix_acl_set, 449 - .list = posix_acl_access_list, 450 - }; 451 - 452 - static size_t posix_acl_default_list(struct dentry *dentry, char *list, 453 - size_t list_size, const char *name, 454 - size_t name_len, int type) 455 - { 456 - const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); 457 - if (!reiserfs_posixacl(dentry->d_sb)) 458 - return 0; 459 - if (list && size <= list_size) 460 - memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); 461 - return size; 462 - } 463 - 464 - const struct xattr_handler reiserfs_posix_acl_default_handler = { 465 - .prefix = POSIX_ACL_XATTR_DEFAULT, 466 - .flags = ACL_TYPE_DEFAULT, 467 - .get = posix_acl_get, 468 - .set = posix_acl_set, 469 - .list = posix_acl_default_list, 470 - };
-180
fs/xattr_acl.c
··· 1 - /* 2 - * linux/fs/xattr_acl.c 3 - * 4 - * Almost all from linux/fs/ext2/acl.c: 5 - * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org> 6 - */ 7 - 8 - #include <linux/export.h> 9 - #include <linux/fs.h> 10 - #include <linux/posix_acl_xattr.h> 11 - #include <linux/gfp.h> 12 - #include <linux/user_namespace.h> 13 - 14 - /* 15 - * Fix up the uids and gids in posix acl extended attributes in place. 16 - */ 17 - static void posix_acl_fix_xattr_userns( 18 - struct user_namespace *to, struct user_namespace *from, 19 - void *value, size_t size) 20 - { 21 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value; 22 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end; 23 - int count; 24 - kuid_t uid; 25 - kgid_t gid; 26 - 27 - if (!value) 28 - return; 29 - if (size < sizeof(posix_acl_xattr_header)) 30 - return; 31 - if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION)) 32 - return; 33 - 34 - count = posix_acl_xattr_count(size); 35 - if (count < 0) 36 - return; 37 - if (count == 0) 38 - return; 39 - 40 - for (end = entry + count; entry != end; entry++) { 41 - switch(le16_to_cpu(entry->e_tag)) { 42 - case ACL_USER: 43 - uid = make_kuid(from, le32_to_cpu(entry->e_id)); 44 - entry->e_id = cpu_to_le32(from_kuid(to, uid)); 45 - break; 46 - case ACL_GROUP: 47 - gid = make_kgid(from, le32_to_cpu(entry->e_id)); 48 - entry->e_id = cpu_to_le32(from_kgid(to, gid)); 49 - break; 50 - default: 51 - break; 52 - } 53 - } 54 - } 55 - 56 - void posix_acl_fix_xattr_from_user(void *value, size_t size) 57 - { 58 - struct user_namespace *user_ns = current_user_ns(); 59 - if (user_ns == &init_user_ns) 60 - return; 61 - posix_acl_fix_xattr_userns(&init_user_ns, user_ns, value, size); 62 - } 63 - 64 - void posix_acl_fix_xattr_to_user(void *value, size_t size) 65 - { 66 - struct user_namespace *user_ns = current_user_ns(); 67 - if (user_ns == &init_user_ns) 68 - return; 69 - posix_acl_fix_xattr_userns(user_ns, &init_user_ns, value, size); 70 - } 71 - 72 - /* 73 - * Convert from extended attribute to in-memory representation. 74 - */ 75 - struct posix_acl * 76 - posix_acl_from_xattr(struct user_namespace *user_ns, 77 - const void *value, size_t size) 78 - { 79 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value; 80 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end; 81 - int count; 82 - struct posix_acl *acl; 83 - struct posix_acl_entry *acl_e; 84 - 85 - if (!value) 86 - return NULL; 87 - if (size < sizeof(posix_acl_xattr_header)) 88 - return ERR_PTR(-EINVAL); 89 - if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION)) 90 - return ERR_PTR(-EOPNOTSUPP); 91 - 92 - count = posix_acl_xattr_count(size); 93 - if (count < 0) 94 - return ERR_PTR(-EINVAL); 95 - if (count == 0) 96 - return NULL; 97 - 98 - acl = posix_acl_alloc(count, GFP_NOFS); 99 - if (!acl) 100 - return ERR_PTR(-ENOMEM); 101 - acl_e = acl->a_entries; 102 - 103 - for (end = entry + count; entry != end; acl_e++, entry++) { 104 - acl_e->e_tag = le16_to_cpu(entry->e_tag); 105 - acl_e->e_perm = le16_to_cpu(entry->e_perm); 106 - 107 - switch(acl_e->e_tag) { 108 - case ACL_USER_OBJ: 109 - case ACL_GROUP_OBJ: 110 - case ACL_MASK: 111 - case ACL_OTHER: 112 - break; 113 - 114 - case ACL_USER: 115 - acl_e->e_uid = 116 - make_kuid(user_ns, 117 - le32_to_cpu(entry->e_id)); 118 - if (!uid_valid(acl_e->e_uid)) 119 - goto fail; 120 - break; 121 - case ACL_GROUP: 122 - acl_e->e_gid = 123 - make_kgid(user_ns, 124 - le32_to_cpu(entry->e_id)); 125 - if (!gid_valid(acl_e->e_gid)) 126 - goto fail; 127 - break; 128 - 129 - default: 130 - goto fail; 131 - } 132 - } 133 - return acl; 134 - 135 - fail: 136 - posix_acl_release(acl); 137 - return ERR_PTR(-EINVAL); 138 - } 139 - EXPORT_SYMBOL (posix_acl_from_xattr); 140 - 141 - /* 142 - * Convert from in-memory to extended attribute representation. 143 - */ 144 - int 145 - posix_acl_to_xattr(struct user_namespace *user_ns, const struct posix_acl *acl, 146 - void *buffer, size_t size) 147 - { 148 - posix_acl_xattr_header *ext_acl = (posix_acl_xattr_header *)buffer; 149 - posix_acl_xattr_entry *ext_entry = ext_acl->a_entries; 150 - int real_size, n; 151 - 152 - real_size = posix_acl_xattr_size(acl->a_count); 153 - if (!buffer) 154 - return real_size; 155 - if (real_size > size) 156 - return -ERANGE; 157 - 158 - ext_acl->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION); 159 - 160 - for (n=0; n < acl->a_count; n++, ext_entry++) { 161 - const struct posix_acl_entry *acl_e = &acl->a_entries[n]; 162 - ext_entry->e_tag = cpu_to_le16(acl_e->e_tag); 163 - ext_entry->e_perm = cpu_to_le16(acl_e->e_perm); 164 - switch(acl_e->e_tag) { 165 - case ACL_USER: 166 - ext_entry->e_id = 167 - cpu_to_le32(from_kuid(user_ns, acl_e->e_uid)); 168 - break; 169 - case ACL_GROUP: 170 - ext_entry->e_id = 171 - cpu_to_le32(from_kgid(user_ns, acl_e->e_gid)); 172 - break; 173 - default: 174 - ext_entry->e_id = cpu_to_le32(ACL_UNDEFINED_ID); 175 - break; 176 - } 177 - } 178 - return real_size; 179 - } 180 - EXPORT_SYMBOL (posix_acl_to_xattr);
+8 -143
fs/xfs/xfs_acl.c
··· 124 124 xfs_get_acl(struct inode *inode, int type) 125 125 { 126 126 struct xfs_inode *ip = XFS_I(inode); 127 - struct posix_acl *acl; 127 + struct posix_acl *acl = NULL; 128 128 struct xfs_acl *xfs_acl; 129 129 unsigned char *ea_name; 130 130 int error; 131 131 int len; 132 - 133 - acl = get_cached_acl(inode, type); 134 - if (acl != ACL_NOT_CACHED) 135 - return acl; 136 132 137 133 trace_xfs_get_acl(ip); 138 134 ··· 160 164 * cache entry, for any other error assume it is transient and 161 165 * leave the cache entry as ACL_NOT_CACHED. 162 166 */ 163 - if (error == -ENOATTR) { 164 - acl = NULL; 167 + if (error == -ENOATTR) 165 168 goto out_update_cache; 166 - } 167 169 goto out; 168 170 } 169 171 ··· 177 183 } 178 184 179 185 STATIC int 180 - xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl) 186 + __xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl) 181 187 { 182 188 struct xfs_inode *ip = XFS_I(inode); 183 189 unsigned char *ea_name; 184 190 int error; 185 - 186 - if (S_ISLNK(inode->i_mode)) 187 - return -EOPNOTSUPP; 188 191 189 192 switch (type) { 190 193 case ACL_TYPE_ACCESS: ··· 273 282 return xfs_acl_exists(inode, SGI_ACL_DEFAULT); 274 283 } 275 284 276 - /* 277 - * No need for i_mutex because the inode is not yet exposed to the VFS. 278 - */ 279 285 int 280 - xfs_inherit_acl(struct inode *inode, struct posix_acl *acl) 286 + xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) 281 287 { 282 - umode_t mode = inode->i_mode; 283 - int error = 0, inherit = 0; 284 - 285 - if (S_ISDIR(inode->i_mode)) { 286 - error = xfs_set_acl(inode, ACL_TYPE_DEFAULT, acl); 287 - if (error) 288 - goto out; 289 - } 290 - 291 - error = posix_acl_create(&acl, GFP_KERNEL, &mode); 292 - if (error < 0) 293 - return error; 294 - 295 - /* 296 - * If posix_acl_create returns a positive value we need to 297 - * inherit a permission that can't be represented using the Unix 298 - * mode bits and we actually need to set an ACL. 299 - */ 300 - if (error > 0) 301 - inherit = 1; 302 - 303 - error = xfs_set_mode(inode, mode); 304 - if (error) 305 - goto out; 306 - 307 - if (inherit) 308 - error = xfs_set_acl(inode, ACL_TYPE_ACCESS, acl); 309 - 310 - out: 311 - posix_acl_release(acl); 312 - return error; 313 - } 314 - 315 - int 316 - xfs_acl_chmod(struct inode *inode) 317 - { 318 - struct posix_acl *acl; 319 - int error; 320 - 321 - if (S_ISLNK(inode->i_mode)) 322 - return -EOPNOTSUPP; 323 - 324 - acl = xfs_get_acl(inode, ACL_TYPE_ACCESS); 325 - if (IS_ERR(acl) || !acl) 326 - return PTR_ERR(acl); 327 - 328 - error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode); 329 - if (error) 330 - return error; 331 - 332 - error = xfs_set_acl(inode, ACL_TYPE_ACCESS, acl); 333 - posix_acl_release(acl); 334 - return error; 335 - } 336 - 337 - static int 338 - xfs_xattr_acl_get(struct dentry *dentry, const char *name, 339 - void *value, size_t size, int type) 340 - { 341 - struct posix_acl *acl; 342 - int error; 343 - 344 - acl = xfs_get_acl(dentry->d_inode, type); 345 - if (IS_ERR(acl)) 346 - return PTR_ERR(acl); 347 - if (acl == NULL) 348 - return -ENODATA; 349 - 350 - error = posix_acl_to_xattr(&init_user_ns, acl, value, size); 351 - posix_acl_release(acl); 352 - 353 - return error; 354 - } 355 - 356 - static int 357 - xfs_xattr_acl_set(struct dentry *dentry, const char *name, 358 - const void *value, size_t size, int flags, int type) 359 - { 360 - struct inode *inode = dentry->d_inode; 361 - struct posix_acl *acl = NULL; 362 288 int error = 0; 363 289 364 - if (flags & XATTR_CREATE) 365 - return -EINVAL; 366 - if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) 367 - return value ? -EACCES : 0; 368 - if (!inode_owner_or_capable(inode)) 369 - return -EPERM; 370 - 371 - if (!value) 290 + if (!acl) 372 291 goto set_acl; 373 - 374 - acl = posix_acl_from_xattr(&init_user_ns, value, size); 375 - if (!acl) { 376 - /* 377 - * acl_set_file(3) may request that we set default ACLs with 378 - * zero length -- defend (gracefully) against that here. 379 - */ 380 - goto out; 381 - } 382 - if (IS_ERR(acl)) { 383 - error = PTR_ERR(acl); 384 - goto out; 385 - } 386 - 387 - error = posix_acl_valid(acl); 388 - if (error) 389 - goto out_release; 390 292 391 293 error = -EINVAL; 392 294 if (acl->a_count > XFS_ACL_MAX_ENTRIES(XFS_M(inode->i_sb))) 393 - goto out_release; 295 + return error; 394 296 395 297 if (type == ACL_TYPE_ACCESS) { 396 298 umode_t mode = inode->i_mode; 397 299 error = posix_acl_equiv_mode(acl, &mode); 398 300 399 301 if (error <= 0) { 400 - posix_acl_release(acl); 401 302 acl = NULL; 402 303 403 304 if (error < 0) ··· 298 415 299 416 error = xfs_set_mode(inode, mode); 300 417 if (error) 301 - goto out_release; 418 + return error; 302 419 } 303 420 304 421 set_acl: 305 - error = xfs_set_acl(inode, type, acl); 306 - out_release: 307 - posix_acl_release(acl); 308 - out: 309 - return error; 422 + return __xfs_set_acl(inode, type, acl); 310 423 } 311 - 312 - const struct xattr_handler xfs_xattr_acl_access_handler = { 313 - .prefix = POSIX_ACL_XATTR_ACCESS, 314 - .flags = ACL_TYPE_ACCESS, 315 - .get = xfs_xattr_acl_get, 316 - .set = xfs_xattr_acl_set, 317 - }; 318 - 319 - const struct xattr_handler xfs_xattr_acl_default_handler = { 320 - .prefix = POSIX_ACL_XATTR_DEFAULT, 321 - .flags = ACL_TYPE_DEFAULT, 322 - .get = xfs_xattr_acl_get, 323 - .set = xfs_xattr_acl_set, 324 - };
+2 -7
fs/xfs/xfs_acl.h
··· 60 60 61 61 #ifdef CONFIG_XFS_POSIX_ACL 62 62 extern struct posix_acl *xfs_get_acl(struct inode *inode, int type); 63 - extern int xfs_inherit_acl(struct inode *inode, struct posix_acl *default_acl); 64 - extern int xfs_acl_chmod(struct inode *inode); 63 + extern int xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type); 65 64 extern int posix_acl_access_exists(struct inode *inode); 66 65 extern int posix_acl_default_exists(struct inode *inode); 67 - 68 - extern const struct xattr_handler xfs_xattr_acl_access_handler; 69 - extern const struct xattr_handler xfs_xattr_acl_default_handler; 70 66 #else 71 67 static inline struct posix_acl *xfs_get_acl(struct inode *inode, int type) 72 68 { 73 69 return NULL; 74 70 } 75 - # define xfs_inherit_acl(inode, default_acl) 0 76 - # define xfs_acl_chmod(inode) 0 71 + # define xfs_set_acl NULL 77 72 # define posix_acl_access_exists(inode) 0 78 73 # define posix_acl_default_exists(inode) 0 79 74 #endif /* CONFIG_XFS_POSIX_ACL */
+24 -31
fs/xfs/xfs_iops.c
··· 123 123 { 124 124 struct inode *inode; 125 125 struct xfs_inode *ip = NULL; 126 - struct posix_acl *default_acl = NULL; 126 + struct posix_acl *default_acl, *acl; 127 127 struct xfs_name name; 128 128 int error; 129 129 ··· 139 139 rdev = 0; 140 140 } 141 141 142 - if (IS_POSIXACL(dir)) { 143 - default_acl = xfs_get_acl(dir, ACL_TYPE_DEFAULT); 144 - if (IS_ERR(default_acl)) 145 - return PTR_ERR(default_acl); 146 - 147 - if (!default_acl) 148 - mode &= ~current_umask(); 149 - } 142 + error = posix_acl_create(dir, &mode, &default_acl, &acl); 143 + if (error) 144 + return error; 150 145 151 146 xfs_dentry_to_name(&name, dentry, mode); 152 147 error = xfs_create(XFS_I(dir), &name, mode, rdev, &ip); ··· 154 159 if (unlikely(error)) 155 160 goto out_cleanup_inode; 156 161 162 + #ifdef CONFIG_XFS_POSIX_ACL 157 163 if (default_acl) { 158 - error = -xfs_inherit_acl(inode, default_acl); 159 - default_acl = NULL; 160 - if (unlikely(error)) 164 + error = xfs_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); 165 + if (error) 161 166 goto out_cleanup_inode; 162 167 } 163 - 168 + if (acl) { 169 + error = xfs_set_acl(inode, acl, ACL_TYPE_ACCESS); 170 + if (error) 171 + goto out_cleanup_inode; 172 + } 173 + #endif 164 174 165 175 d_instantiate(dentry, inode); 176 + out_free_acl: 177 + if (default_acl) 178 + posix_acl_release(default_acl); 179 + if (acl) 180 + posix_acl_release(acl); 166 181 return -error; 167 182 168 183 out_cleanup_inode: 169 184 xfs_cleanup_inode(dir, inode, dentry); 170 - out_free_acl: 171 - posix_acl_release(default_acl); 172 - return -error; 185 + goto out_free_acl; 173 186 } 174 187 175 188 STATIC int ··· 392 389 out_err: 393 390 nd_set_link(nd, ERR_PTR(error)); 394 391 return NULL; 395 - } 396 - 397 - STATIC void 398 - xfs_vn_put_link( 399 - struct dentry *dentry, 400 - struct nameidata *nd, 401 - void *p) 402 - { 403 - char *s = nd_get_link(nd); 404 - 405 - if (!IS_ERR(s)) 406 - kfree(s); 407 392 } 408 393 409 394 STATIC int ··· 679 688 * Posix ACL code seems to care about this issue either. 680 689 */ 681 690 if ((mask & ATTR_MODE) && !(flags & XFS_ATTR_NOACL)) { 682 - error = -xfs_acl_chmod(inode); 691 + error = -posix_acl_chmod(inode, inode->i_mode); 683 692 if (error) 684 693 return XFS_ERROR(error); 685 694 } ··· 1036 1045 1037 1046 static const struct inode_operations xfs_inode_operations = { 1038 1047 .get_acl = xfs_get_acl, 1048 + .set_acl = xfs_set_acl, 1039 1049 .getattr = xfs_vn_getattr, 1040 1050 .setattr = xfs_vn_setattr, 1041 1051 .setxattr = generic_setxattr, ··· 1064 1072 .mknod = xfs_vn_mknod, 1065 1073 .rename = xfs_vn_rename, 1066 1074 .get_acl = xfs_get_acl, 1075 + .set_acl = xfs_set_acl, 1067 1076 .getattr = xfs_vn_getattr, 1068 1077 .setattr = xfs_vn_setattr, 1069 1078 .setxattr = generic_setxattr, ··· 1091 1098 .mknod = xfs_vn_mknod, 1092 1099 .rename = xfs_vn_rename, 1093 1100 .get_acl = xfs_get_acl, 1101 + .set_acl = xfs_set_acl, 1094 1102 .getattr = xfs_vn_getattr, 1095 1103 .setattr = xfs_vn_setattr, 1096 1104 .setxattr = generic_setxattr, ··· 1104 1110 static const struct inode_operations xfs_symlink_inode_operations = { 1105 1111 .readlink = generic_readlink, 1106 1112 .follow_link = xfs_vn_follow_link, 1107 - .put_link = xfs_vn_put_link, 1108 - .get_acl = xfs_get_acl, 1113 + .put_link = kfree_put_link, 1109 1114 .getattr = xfs_vn_getattr, 1110 1115 .setattr = xfs_vn_setattr, 1111 1116 .setxattr = generic_setxattr,
+1 -1
fs/xfs/xfs_iops.h
··· 30 30 /* 31 31 * Internal setattr interfaces. 32 32 */ 33 - #define XFS_ATTR_NOACL 0x01 /* Don't call xfs_acl_chmod */ 33 + #define XFS_ATTR_NOACL 0x01 /* Don't call posix_acl_chmod */ 34 34 35 35 extern int xfs_setattr_nonsize(struct xfs_inode *ip, struct iattr *vap, 36 36 int flags);
+2 -2
fs/xfs/xfs_xattr.c
··· 102 102 &xfs_xattr_trusted_handler, 103 103 &xfs_xattr_security_handler, 104 104 #ifdef CONFIG_XFS_POSIX_ACL 105 - &xfs_xattr_acl_access_handler, 106 - &xfs_xattr_acl_default_handler, 105 + &posix_acl_access_xattr_handler, 106 + &posix_acl_default_xattr_handler, 107 107 #endif 108 108 NULL 109 109 };
-6
include/linux/cramfs_fs.h fs/cramfs/internal.h
··· 1 - #ifndef __CRAMFS_H 2 - #define __CRAMFS_H 3 - 4 - #include <uapi/linux/cramfs_fs.h> 5 - 6 1 /* Uncompression interfaces to the underlying zlib */ 7 2 int cramfs_uncompress_block(void *dst, int dstlen, void *src, int srclen); 8 3 int cramfs_uncompress_init(void); 9 4 void cramfs_uncompress_exit(void); 10 - #endif
-20
include/linux/cramfs_fs_sb.h
··· 1 - #ifndef _CRAMFS_FS_SB 2 - #define _CRAMFS_FS_SB 3 - 4 - /* 5 - * cramfs super-block data in memory 6 - */ 7 - struct cramfs_sb_info { 8 - unsigned long magic; 9 - unsigned long size; 10 - unsigned long blocks; 11 - unsigned long files; 12 - unsigned long flags; 13 - }; 14 - 15 - static inline struct cramfs_sb_info *CRAMFS_SB(struct super_block *sb) 16 - { 17 - return sb->s_fs_info; 18 - } 19 - 20 - #endif
+21 -14
include/linux/fdtable.h
··· 59 59 struct file __rcu * fd_array[NR_OPEN_DEFAULT]; 60 60 }; 61 61 62 - #define rcu_dereference_check_fdtable(files, fdtfd) \ 63 - (rcu_dereference_check((fdtfd), \ 64 - lockdep_is_held(&(files)->file_lock) || \ 65 - atomic_read(&(files)->count) == 1 || \ 66 - rcu_my_thread_group_empty())) 67 - 68 - #define files_fdtable(files) \ 69 - (rcu_dereference_check_fdtable((files), (files)->fdt)) 70 - 71 62 struct file_operations; 72 63 struct vfsmount; 73 64 struct dentry; 74 65 75 66 extern void __init files_defer_init(void); 76 67 77 - static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd) 68 + #define rcu_dereference_check_fdtable(files, fdtfd) \ 69 + rcu_dereference_check((fdtfd), lockdep_is_held(&(files)->file_lock)) 70 + 71 + #define files_fdtable(files) \ 72 + rcu_dereference_check_fdtable((files), (files)->fdt) 73 + 74 + /* 75 + * The caller must ensure that fd table isn't shared or hold rcu or file lock 76 + */ 77 + static inline struct file *__fcheck_files(struct files_struct *files, unsigned int fd) 78 78 { 79 - struct file * file = NULL; 80 - struct fdtable *fdt = files_fdtable(files); 79 + struct fdtable *fdt = rcu_dereference_raw(files->fdt); 81 80 82 81 if (fd < fdt->max_fds) 83 - file = rcu_dereference_check_fdtable(files, fdt->fd[fd]); 84 - return file; 82 + return rcu_dereference_raw(fdt->fd[fd]); 83 + return NULL; 84 + } 85 + 86 + static inline struct file *fcheck_files(struct files_struct *files, unsigned int fd) 87 + { 88 + rcu_lockdep_assert(rcu_read_lock_held() || 89 + lockdep_is_held(&files->file_lock), 90 + "suspicious rcu_dereference_check() usage"); 91 + return __fcheck_files(files, fd); 85 92 } 86 93 87 94 /*
+1
include/linux/fs.h
··· 1580 1580 struct file *, unsigned open_flag, 1581 1581 umode_t create_mode, int *opened); 1582 1582 int (*tmpfile) (struct inode *, struct dentry *, umode_t); 1583 + int (*set_acl)(struct inode *, struct posix_acl *, int); 1583 1584 } ____cacheline_aligned; 1584 1585 1585 1586 ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
-14
include/linux/generic_acl.h
··· 1 - #ifndef LINUX_GENERIC_ACL_H 2 - #define LINUX_GENERIC_ACL_H 3 - 4 - #include <linux/xattr.h> 5 - 6 - struct inode; 7 - 8 - extern const struct xattr_handler generic_acl_access_handler; 9 - extern const struct xattr_handler generic_acl_default_handler; 10 - 11 - int generic_acl_init(struct inode *, struct inode *); 12 - int generic_acl_chmod(struct inode *); 13 - 14 - #endif /* LINUX_GENERIC_ACL_H */
+7 -17
include/linux/nfs_fs.h
··· 154 154 struct rb_root access_cache; 155 155 struct list_head access_cache_entry_lru; 156 156 struct list_head access_cache_inode_lru; 157 - #ifdef CONFIG_NFS_V3_ACL 158 - struct posix_acl *acl_access; 159 - struct posix_acl *acl_default; 160 - #endif 161 157 162 158 /* 163 159 * This is the cookie verifier used for NFSv3 readdir ··· 560 564 * linux/fs/nfs3proc.c 561 565 */ 562 566 #ifdef CONFIG_NFS_V3_ACL 563 - extern struct posix_acl *nfs3_proc_getacl(struct inode *inode, int type); 564 - extern int nfs3_proc_setacl(struct inode *inode, int type, 565 - struct posix_acl *acl); 566 - extern int nfs3_proc_set_default_acl(struct inode *dir, struct inode *inode, 567 - umode_t mode); 568 - extern void nfs3_forget_cached_acls(struct inode *inode); 567 + extern struct posix_acl *nfs3_get_acl(struct inode *inode, int type); 568 + extern int nfs3_set_acl(struct inode *inode, struct posix_acl *acl, int type); 569 + extern int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl, 570 + struct posix_acl *dfacl); 571 + extern const struct xattr_handler *nfs3_xattr_handlers[]; 569 572 #else 570 - static inline int nfs3_proc_set_default_acl(struct inode *dir, 571 - struct inode *inode, 572 - umode_t mode) 573 + static inline int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl, 574 + struct posix_acl *dfacl) 573 575 { 574 576 return 0; 575 - } 576 - 577 - static inline void nfs3_forget_cached_acls(struct inode *inode) 578 - { 579 577 } 580 578 #endif /* CONFIG_NFS_V3_ACL */ 581 579
+2 -1
include/linux/nls.h
··· 44 44 }; 45 45 46 46 /* nls_base.c */ 47 - extern int register_nls(struct nls_table *); 47 + extern int __register_nls(struct nls_table *, struct module *); 48 48 extern int unregister_nls(struct nls_table *); 49 49 extern struct nls_table *load_nls(char *); 50 50 extern void unload_nls(struct nls_table *); 51 51 extern struct nls_table *load_nls_default(void); 52 + #define register_nls(nls) __register_nls((nls), THIS_MODULE) 52 53 53 54 extern int utf8_to_utf32(const u8 *s, int len, unicode_t *pu); 54 55 extern int utf32_to_utf8(unicode_t u, u8 *s, int maxlen);
+39 -4
include/linux/posix_acl.h
··· 85 85 extern int posix_acl_permission(struct inode *, const struct posix_acl *, int); 86 86 extern struct posix_acl *posix_acl_from_mode(umode_t, gfp_t); 87 87 extern int posix_acl_equiv_mode(const struct posix_acl *, umode_t *); 88 - extern int posix_acl_create(struct posix_acl **, gfp_t, umode_t *); 89 - extern int posix_acl_chmod(struct posix_acl **, gfp_t, umode_t); 88 + extern int __posix_acl_create(struct posix_acl **, gfp_t, umode_t *); 89 + extern int __posix_acl_chmod(struct posix_acl **, gfp_t, umode_t); 90 90 91 91 extern struct posix_acl *get_posix_acl(struct inode *, int); 92 92 extern int set_posix_acl(struct inode *, int, struct posix_acl *); 93 + 94 + #ifdef CONFIG_FS_POSIX_ACL 95 + extern int posix_acl_chmod(struct inode *, umode_t); 96 + extern int posix_acl_create(struct inode *, umode_t *, struct posix_acl **, 97 + struct posix_acl **); 98 + 99 + extern int simple_set_acl(struct inode *, struct posix_acl *, int); 100 + extern int simple_acl_create(struct inode *, struct inode *); 93 101 94 102 struct posix_acl **acl_by_type(struct inode *inode, int type); 95 103 struct posix_acl *get_cached_acl(struct inode *inode, int type); ··· 108 100 109 101 static inline void cache_no_acl(struct inode *inode) 110 102 { 111 - #ifdef CONFIG_FS_POSIX_ACL 112 103 inode->i_acl = NULL; 113 104 inode->i_default_acl = NULL; 114 - #endif 115 105 } 106 + #else 107 + static inline int posix_acl_chmod(struct inode *inode, umode_t mode) 108 + { 109 + return 0; 110 + } 111 + 112 + #define simple_set_acl NULL 113 + 114 + static inline int simple_acl_create(struct inode *dir, struct inode *inode) 115 + { 116 + return 0; 117 + } 118 + static inline void cache_no_acl(struct inode *inode) 119 + { 120 + } 121 + 122 + static inline int posix_acl_create(struct inode *inode, umode_t *mode, 123 + struct posix_acl **default_acl, struct posix_acl **acl) 124 + { 125 + *default_acl = *acl = NULL; 126 + return 0; 127 + } 128 + 129 + static inline void forget_all_cached_acls(struct inode *inode) 130 + { 131 + } 132 + #endif /* CONFIG_FS_POSIX_ACL */ 133 + 134 + struct posix_acl *get_acl(struct inode *inode, int type); 116 135 117 136 #endif /* __LINUX_POSIX_ACL_H */
+3
include/linux/posix_acl_xattr.h
··· 69 69 int posix_acl_to_xattr(struct user_namespace *user_ns, 70 70 const struct posix_acl *acl, void *buffer, size_t size); 71 71 72 + extern const struct xattr_handler posix_acl_access_xattr_handler; 73 + extern const struct xattr_handler posix_acl_default_xattr_handler; 74 + 72 75 #endif /* _POSIX_ACL_XATTR_H */
-2
include/linux/rcupdate.h
··· 449 449 450 450 #ifdef CONFIG_PROVE_RCU 451 451 452 - int rcu_my_thread_group_empty(void); 453 - 454 452 /** 455 453 * rcu_lockdep_assert - emit lockdep splat if specified condition not met 456 454 * @c: condition to check
+1 -1
init/do_mounts_rd.c
··· 13 13 #include <linux/minix_fs.h> 14 14 #include <linux/ext2_fs.h> 15 15 #include <linux/romfs_fs.h> 16 - #include <linux/cramfs_fs.h> 16 + #include <uapi/linux/cramfs_fs.h> 17 17 #include <linux/initrd.h> 18 18 #include <linux/string.h> 19 19 #include <linux/slab.h>
-11
kernel/rcu/update.c
··· 200 200 } 201 201 EXPORT_SYMBOL_GPL(wait_rcu_gp); 202 202 203 - #ifdef CONFIG_PROVE_RCU 204 - /* 205 - * wrapper function to avoid #include problems. 206 - */ 207 - int rcu_my_thread_group_empty(void) 208 - { 209 - return thread_group_empty(current); 210 - } 211 - EXPORT_SYMBOL_GPL(rcu_my_thread_group_empty); 212 - #endif /* #ifdef CONFIG_PROVE_RCU */ 213 - 214 203 #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD 215 204 static inline void debug_init_rcu_head(struct rcu_head *head) 216 205 {
+20 -22
mm/filemap.c
··· 1428 1428 if (!count) 1429 1429 goto out; /* skip atime */ 1430 1430 size = i_size_read(inode); 1431 - if (pos < size) { 1432 - retval = filemap_write_and_wait_range(mapping, pos, 1431 + retval = filemap_write_and_wait_range(mapping, pos, 1433 1432 pos + iov_length(iov, nr_segs) - 1); 1434 - if (!retval) { 1435 - retval = mapping->a_ops->direct_IO(READ, iocb, 1436 - iov, pos, nr_segs); 1437 - } 1438 - if (retval > 0) { 1439 - *ppos = pos + retval; 1440 - count -= retval; 1441 - } 1433 + if (!retval) { 1434 + retval = mapping->a_ops->direct_IO(READ, iocb, 1435 + iov, pos, nr_segs); 1436 + } 1437 + if (retval > 0) { 1438 + *ppos = pos + retval; 1439 + count -= retval; 1440 + } 1442 1441 1443 - /* 1444 - * Btrfs can have a short DIO read if we encounter 1445 - * compressed extents, so if there was an error, or if 1446 - * we've already read everything we wanted to, or if 1447 - * there was a short read because we hit EOF, go ahead 1448 - * and return. Otherwise fallthrough to buffered io for 1449 - * the rest of the read. 1450 - */ 1451 - if (retval < 0 || !count || *ppos >= size) { 1452 - file_accessed(filp); 1453 - goto out; 1454 - } 1442 + /* 1443 + * Btrfs can have a short DIO read if we encounter 1444 + * compressed extents, so if there was an error, or if 1445 + * we've already read everything we wanted to, or if 1446 + * there was a short read because we hit EOF, go ahead 1447 + * and return. Otherwise fallthrough to buffered io for 1448 + * the rest of the read. 1449 + */ 1450 + if (retval < 0 || !count || *ppos >= size) { 1451 + file_accessed(filp); 1452 + goto out; 1455 1453 } 1456 1454 } 1457 1455
+23 -34
mm/shmem.c
··· 45 45 #include <linux/xattr.h> 46 46 #include <linux/exportfs.h> 47 47 #include <linux/posix_acl.h> 48 - #include <linux/generic_acl.h> 48 + #include <linux/posix_acl_xattr.h> 49 49 #include <linux/mman.h> 50 50 #include <linux/string.h> 51 51 #include <linux/slab.h> ··· 620 620 } 621 621 622 622 setattr_copy(inode, attr); 623 - #ifdef CONFIG_TMPFS_POSIX_ACL 624 623 if (attr->ia_valid & ATTR_MODE) 625 - error = generic_acl_chmod(inode); 626 - #endif 624 + error = posix_acl_chmod(inode, inode->i_mode); 627 625 return error; 628 626 } 629 627 ··· 1935 1937 1936 1938 inode = shmem_get_inode(dir->i_sb, dir, mode, dev, VM_NORESERVE); 1937 1939 if (inode) { 1938 - #ifdef CONFIG_TMPFS_POSIX_ACL 1939 - error = generic_acl_init(inode, dir); 1940 - if (error) { 1941 - iput(inode); 1942 - return error; 1943 - } 1944 - #endif 1940 + error = simple_acl_create(dir, inode); 1941 + if (error) 1942 + goto out_iput; 1945 1943 error = security_inode_init_security(inode, dir, 1946 1944 &dentry->d_name, 1947 1945 shmem_initxattrs, NULL); 1948 - if (error) { 1949 - if (error != -EOPNOTSUPP) { 1950 - iput(inode); 1951 - return error; 1952 - } 1953 - } 1946 + if (error && error != -EOPNOTSUPP) 1947 + goto out_iput; 1954 1948 1955 1949 error = 0; 1956 1950 dir->i_size += BOGO_DIRENT_SIZE; ··· 1950 1960 d_instantiate(dentry, inode); 1951 1961 dget(dentry); /* Extra count - pin the dentry in core */ 1952 1962 } 1963 + return error; 1964 + out_iput: 1965 + iput(inode); 1953 1966 return error; 1954 1967 } 1955 1968 ··· 1967 1974 error = security_inode_init_security(inode, dir, 1968 1975 NULL, 1969 1976 shmem_initxattrs, NULL); 1970 - if (error) { 1971 - if (error != -EOPNOTSUPP) { 1972 - iput(inode); 1973 - return error; 1974 - } 1975 - } 1976 - #ifdef CONFIG_TMPFS_POSIX_ACL 1977 - error = generic_acl_init(inode, dir); 1978 - if (error) { 1979 - iput(inode); 1980 - return error; 1981 - } 1982 - #else 1983 - error = 0; 1984 - #endif 1977 + if (error && error != -EOPNOTSUPP) 1978 + goto out_iput; 1979 + error = simple_acl_create(dir, inode); 1980 + if (error) 1981 + goto out_iput; 1985 1982 d_tmpfile(dentry, inode); 1986 1983 } 1984 + return error; 1985 + out_iput: 1986 + iput(inode); 1987 1987 return error; 1988 1988 } 1989 1989 ··· 2209 2223 2210 2224 static const struct xattr_handler *shmem_xattr_handlers[] = { 2211 2225 #ifdef CONFIG_TMPFS_POSIX_ACL 2212 - &generic_acl_access_handler, 2213 - &generic_acl_default_handler, 2226 + &posix_acl_access_xattr_handler, 2227 + &posix_acl_default_xattr_handler, 2214 2228 #endif 2215 2229 NULL 2216 2230 }; ··· 2726 2740 .getxattr = shmem_getxattr, 2727 2741 .listxattr = shmem_listxattr, 2728 2742 .removexattr = shmem_removexattr, 2743 + .set_acl = simple_set_acl, 2729 2744 #endif 2730 2745 }; 2731 2746 ··· 2751 2764 #endif 2752 2765 #ifdef CONFIG_TMPFS_POSIX_ACL 2753 2766 .setattr = shmem_setattr, 2767 + .set_acl = simple_set_acl, 2754 2768 #endif 2755 2769 }; 2756 2770 ··· 2764 2776 #endif 2765 2777 #ifdef CONFIG_TMPFS_POSIX_ACL 2766 2778 .setattr = shmem_setattr, 2779 + .set_acl = simple_set_acl, 2767 2780 #endif 2768 2781 }; 2769 2782