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

* 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6: (38 commits)
direct I/O fallback sync simplification
ocfs: stop using do_sync_mapping_range
cleanup blockdev_direct_IO locking
make generic_acl slightly more generic
sanitize xattr handler prototypes
libfs: move EXPORT_SYMBOL for d_alloc_name
vfs: force reval of target when following LAST_BIND symlinks (try #7)
ima: limit imbalance msg
Untangling ima mess, part 3: kill dead code in ima
Untangling ima mess, part 2: deal with counters
Untangling ima mess, part 1: alloc_file()
O_TRUNC open shouldn't fail after file truncation
ima: call ima_inode_free ima_inode_free
IMA: clean up the IMA counts updating code
ima: only insert at inode creation time
ima: valid return code from ima_inode_alloc
fs: move get_empty_filp() deffinition to internal.h
Sanitize exec_permission_lite()
Kill cached_lookup() and real_lookup()
Kill path_lookup_open()
...

Trivial conflicts in fs/direct-io.c

+1173 -1832
+8 -7
arch/ia64/kernel/perfmon.c
··· 2200 2200 { 2201 2201 struct file *file; 2202 2202 struct inode *inode; 2203 - struct dentry *dentry; 2203 + struct path path; 2204 2204 char name[32]; 2205 2205 struct qstr this; 2206 2206 ··· 2225 2225 /* 2226 2226 * allocate a new dcache entry 2227 2227 */ 2228 - dentry = d_alloc(pfmfs_mnt->mnt_sb->s_root, &this); 2229 - if (!dentry) { 2228 + path.dentry = d_alloc(pfmfs_mnt->mnt_sb->s_root, &this); 2229 + if (!path.dentry) { 2230 2230 iput(inode); 2231 2231 return ERR_PTR(-ENOMEM); 2232 2232 } 2233 + path.mnt = mntget(pfmfs_mnt); 2233 2234 2234 - dentry->d_op = &pfmfs_dentry_operations; 2235 - d_add(dentry, inode); 2235 + path.dentry->d_op = &pfmfs_dentry_operations; 2236 + d_add(path.dentry, inode); 2236 2237 2237 - file = alloc_file(pfmfs_mnt, dentry, FMODE_READ, &pfm_file_ops); 2238 + file = alloc_file(&path, FMODE_READ, &pfm_file_ops); 2238 2239 if (!file) { 2239 - dput(dentry); 2240 + path_put(&path); 2240 2241 return ERR_PTR(-ENFILE); 2241 2242 } 2242 2243
+1 -6
arch/parisc/hpux/sys_hpux.c
··· 445 445 446 446 int hpux_pipe(int *kstack_fildes) 447 447 { 448 - int error; 449 - 450 - lock_kernel(); 451 - error = do_pipe_flags(kstack_fildes, 0); 452 - unlock_kernel(); 453 - return error; 448 + return do_pipe_flags(kstack_fildes, 0); 454 449 } 455 450 456 451 /* lies - says it works, but it really didn't lock anything */
-1
arch/x86/include/asm/sys_ia32.h
··· 30 30 asmlinkage long sys32_mmap(struct mmap_arg_struct __user *); 31 31 asmlinkage long sys32_mprotect(unsigned long, size_t, unsigned long); 32 32 33 - asmlinkage long sys32_pipe(int __user *); 34 33 struct sigaction32; 35 34 struct old_sigaction32; 36 35 asmlinkage long sys32_rt_sigaction(int, struct sigaction32 __user *,
-1
arch/xtensa/include/asm/syscall.h
··· 12 12 struct sigaction; 13 13 asmlinkage long xtensa_execve(char*, char**, char**, struct pt_regs*); 14 14 asmlinkage long xtensa_clone(unsigned long, unsigned long, struct pt_regs*); 15 - asmlinkage long xtensa_pipe(int __user *); 16 15 asmlinkage long xtensa_ptrace(long, long, long, long); 17 16 asmlinkage long xtensa_sigreturn(struct pt_regs*); 18 17 asmlinkage long xtensa_rt_sigreturn(struct pt_regs*);
+1 -1
arch/xtensa/include/asm/unistd.h
··· 94 94 #define __NR_mknod 36 95 95 __SYSCALL( 36, sys_mknod, 3) 96 96 #define __NR_pipe 37 97 - __SYSCALL( 37, xtensa_pipe, 1) 97 + __SYSCALL( 37, sys_pipe, 1) 98 98 #define __NR_unlink 38 99 99 __SYSCALL( 38, sys_unlink, 1) 100 100 #define __NR_rmdir 39
-18
arch/xtensa/kernel/syscall.c
··· 39 39 #include <asm/unistd.h> 40 40 }; 41 41 42 - /* 43 - * xtensa_pipe() is the normal C calling standard for creating a pipe. It's not 44 - * the way unix traditional does this, though. 45 - */ 46 - 47 - asmlinkage long xtensa_pipe(int __user *userfds) 48 - { 49 - int fd[2]; 50 - int error; 51 - 52 - error = do_pipe_flags(fd, 0); 53 - if (!error) { 54 - if (copy_to_user(userfds, fd, 2 * sizeof(int))) 55 - error = -EFAULT; 56 - } 57 - return error; 58 - } 59 - 60 42 asmlinkage long xtensa_shmat(int shmid, char __user *shmaddr, int shmflg) 61 43 { 62 44 unsigned long ret;
+7 -2
drivers/infiniband/core/uverbs_main.c
··· 492 492 int is_async, int *fd) 493 493 { 494 494 struct ib_uverbs_event_file *ev_file; 495 + struct path path; 495 496 struct file *filp; 496 497 int ret; 497 498 ··· 520 519 * system call on a uverbs file, which will already have a 521 520 * module reference. 522 521 */ 523 - filp = alloc_file(uverbs_event_mnt, dget(uverbs_event_mnt->mnt_root), 524 - FMODE_READ, fops_get(&uverbs_event_fops)); 522 + path.mnt = uverbs_event_mnt; 523 + path.dentry = uverbs_event_mnt->mnt_root; 524 + path_get(&path); 525 + filp = alloc_file(&path, FMODE_READ, fops_get(&uverbs_event_fops)); 525 526 if (!filp) { 526 527 ret = -ENFILE; 527 528 goto err_fd; ··· 534 531 return filp; 535 532 536 533 err_fd: 534 + fops_put(&uverbs_event_fops); 535 + path_put(&path); 537 536 put_unused_fd(*fd); 538 537 539 538 err:
+5 -41
drivers/staging/dst/dcore.c
··· 403 403 404 404 if (n->bdev) { 405 405 sync_blockdev(n->bdev); 406 - blkdev_put(n->bdev, FMODE_READ|FMODE_WRITE); 406 + close_bdev_exclusive(n->bdev, FMODE_READ|FMODE_WRITE); 407 407 } 408 408 409 409 dst_state_lock(st); ··· 464 464 } 465 465 466 466 /* 467 - * This function finds devices major/minor numbers for given pathname. 468 - */ 469 - static int dst_lookup_device(const char *path, dev_t *dev) 470 - { 471 - int err; 472 - struct nameidata nd; 473 - struct inode *inode; 474 - 475 - err = path_lookup(path, LOOKUP_FOLLOW, &nd); 476 - if (err) 477 - return err; 478 - 479 - inode = nd.path.dentry->d_inode; 480 - if (!inode) { 481 - err = -ENOENT; 482 - goto out; 483 - } 484 - 485 - if (!S_ISBLK(inode->i_mode)) { 486 - err = -ENOTBLK; 487 - goto out; 488 - } 489 - 490 - *dev = inode->i_rdev; 491 - 492 - out: 493 - path_put(&nd.path); 494 - return err; 495 - } 496 - 497 - /* 498 467 * Setting up export device: lookup by the name, get its size 499 468 * and setup listening socket, which will accept clients, which 500 469 * will submit IO for given storage. ··· 472 503 struct dst_export_ctl *le) 473 504 { 474 505 int err; 475 - dev_t dev = 0; /* gcc likes to scream here */ 476 506 477 507 snprintf(n->info->local, sizeof(n->info->local), "%s", le->device); 478 508 479 - err = dst_lookup_device(le->device, &dev); 480 - if (err) 481 - return err; 482 - 483 - n->bdev = open_by_devnum(dev, FMODE_READ|FMODE_WRITE); 484 - if (!n->bdev) 485 - return -ENODEV; 509 + n->bdev = open_bdev_exclusive(le->device, FMODE_READ|FMODE_WRITE, NULL); 510 + if (IS_ERR(n->bdev)) 511 + return PTR_ERR(n->bdev); 486 512 487 513 if (n->size != 0) 488 514 n->size = min_t(loff_t, n->bdev->bd_inode->i_size, n->size); ··· 492 528 return 0; 493 529 494 530 err_out_cleanup: 495 - blkdev_put(n->bdev, FMODE_READ|FMODE_WRITE); 531 + close_bdev_exclusive(n->bdev, FMODE_READ|FMODE_WRITE); 496 532 n->bdev = NULL; 497 533 498 534 return err;
+9 -9
fs/anon_inodes.c
··· 88 88 void *priv, int flags) 89 89 { 90 90 struct qstr this; 91 - struct dentry *dentry; 91 + struct path path; 92 92 struct file *file; 93 93 int error; 94 94 ··· 106 106 this.name = name; 107 107 this.len = strlen(name); 108 108 this.hash = 0; 109 - dentry = d_alloc(anon_inode_mnt->mnt_sb->s_root, &this); 110 - if (!dentry) 109 + path.dentry = d_alloc(anon_inode_mnt->mnt_sb->s_root, &this); 110 + if (!path.dentry) 111 111 goto err_module; 112 112 113 + path.mnt = mntget(anon_inode_mnt); 113 114 /* 114 115 * We know the anon_inode inode count is always greater than zero, 115 116 * so we can avoid doing an igrab() and we can use an open-coded ··· 118 117 */ 119 118 atomic_inc(&anon_inode_inode->i_count); 120 119 121 - dentry->d_op = &anon_inodefs_dentry_operations; 120 + path.dentry->d_op = &anon_inodefs_dentry_operations; 122 121 /* Do not publish this dentry inside the global dentry hash table */ 123 - dentry->d_flags &= ~DCACHE_UNHASHED; 124 - d_instantiate(dentry, anon_inode_inode); 122 + path.dentry->d_flags &= ~DCACHE_UNHASHED; 123 + d_instantiate(path.dentry, anon_inode_inode); 125 124 126 125 error = -ENFILE; 127 - file = alloc_file(anon_inode_mnt, dentry, 128 - FMODE_READ | FMODE_WRITE, fops); 126 + file = alloc_file(&path, FMODE_READ | FMODE_WRITE, fops); 129 127 if (!file) 130 128 goto err_dput; 131 129 file->f_mapping = anon_inode_inode->i_mapping; ··· 137 137 return file; 138 138 139 139 err_dput: 140 - dput(dentry); 140 + path_put(&path); 141 141 err_module: 142 142 module_put(fops->owner); 143 143 return ERR_PTR(error);
+12 -35
fs/btrfs/acl.c
··· 73 73 return acl; 74 74 } 75 75 76 - static int btrfs_xattr_get_acl(struct inode *inode, int type, 77 - void *value, size_t size) 76 + static int btrfs_xattr_acl_get(struct dentry *dentry, const char *name, 77 + void *value, size_t size, int type) 78 78 { 79 79 struct posix_acl *acl; 80 80 int ret = 0; 81 81 82 - acl = btrfs_get_acl(inode, type); 82 + acl = btrfs_get_acl(dentry->d_inode, type); 83 83 84 84 if (IS_ERR(acl)) 85 85 return PTR_ERR(acl); ··· 151 151 return ret; 152 152 } 153 153 154 - static int btrfs_xattr_set_acl(struct inode *inode, int type, 155 - const void *value, size_t size) 154 + static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name, 155 + const void *value, size_t size, int flags, int type) 156 156 { 157 157 int ret = 0; 158 158 struct posix_acl *acl = NULL; ··· 167 167 } 168 168 } 169 169 170 - ret = btrfs_set_acl(inode, acl, type); 170 + ret = btrfs_set_acl(dentry->d_inode, acl, type); 171 171 172 172 posix_acl_release(acl); 173 173 174 174 return ret; 175 - } 176 - 177 - 178 - static int btrfs_xattr_acl_access_get(struct inode *inode, const char *name, 179 - void *value, size_t size) 180 - { 181 - return btrfs_xattr_get_acl(inode, ACL_TYPE_ACCESS, value, size); 182 - } 183 - 184 - static int btrfs_xattr_acl_access_set(struct inode *inode, const char *name, 185 - const void *value, size_t size, int flags) 186 - { 187 - return btrfs_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); 188 - } 189 - 190 - static int btrfs_xattr_acl_default_get(struct inode *inode, const char *name, 191 - void *value, size_t size) 192 - { 193 - return btrfs_xattr_get_acl(inode, ACL_TYPE_DEFAULT, value, size); 194 - } 195 - 196 - static int btrfs_xattr_acl_default_set(struct inode *inode, const char *name, 197 - const void *value, size_t size, int flags) 198 - { 199 - return btrfs_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); 200 175 } 201 176 202 177 int btrfs_check_acl(struct inode *inode, int mask) ··· 278 303 279 304 struct xattr_handler btrfs_xattr_acl_default_handler = { 280 305 .prefix = POSIX_ACL_XATTR_DEFAULT, 281 - .get = btrfs_xattr_acl_default_get, 282 - .set = btrfs_xattr_acl_default_set, 306 + .flags = ACL_TYPE_DEFAULT, 307 + .get = btrfs_xattr_acl_get, 308 + .set = btrfs_xattr_acl_set, 283 309 }; 284 310 285 311 struct xattr_handler btrfs_xattr_acl_access_handler = { 286 312 .prefix = POSIX_ACL_XATTR_ACCESS, 287 - .get = btrfs_xattr_acl_access_get, 288 - .set = btrfs_xattr_acl_access_set, 313 + .flags = ACL_TYPE_ACCESS, 314 + .get = btrfs_xattr_acl_get, 315 + .set = btrfs_xattr_acl_set, 289 316 }; 290 317 291 318 #else /* CONFIG_BTRFS_FS_POSIX_ACL */
+4 -7
fs/cachefiles/bind.c
··· 84 84 static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache) 85 85 { 86 86 struct cachefiles_object *fsdef; 87 - struct nameidata nd; 87 + struct path path; 88 88 struct kstatfs stats; 89 89 struct dentry *graveyard, *cachedir, *root; 90 90 const struct cred *saved_cred; ··· 114 114 _debug("- fsdef %p", fsdef); 115 115 116 116 /* look up the directory at the root of the cache */ 117 - memset(&nd, 0, sizeof(nd)); 118 - 119 - ret = path_lookup(cache->rootdirname, LOOKUP_DIRECTORY, &nd); 117 + ret = kern_path(cache->rootdirname, LOOKUP_DIRECTORY, &path); 120 118 if (ret < 0) 121 119 goto error_open_root; 122 120 123 - cache->mnt = mntget(nd.path.mnt); 124 - root = dget(nd.path.dentry); 125 - path_put(&nd.path); 121 + cache->mnt = path.mnt; 122 + root = path.dentry; 126 123 127 124 /* check parameters */ 128 125 ret = -EOPNOTSUPP;
-2
fs/cachefiles/rdwr.c
··· 11 11 12 12 #include <linux/mount.h> 13 13 #include <linux/file.h> 14 - #include <linux/ima.h> 15 14 #include "internal.h" 16 15 17 16 /* ··· 922 923 if (IS_ERR(file)) { 923 924 ret = PTR_ERR(file); 924 925 } else { 925 - ima_counts_get(file); 926 926 ret = -EIO; 927 927 if (file->f_op->write) { 928 928 pos = (loff_t) page->index << PAGE_SHIFT;
+1
fs/dcache.c
··· 978 978 q.hash = full_name_hash(q.name, q.len); 979 979 return d_alloc(parent, &q); 980 980 } 981 + EXPORT_SYMBOL(d_alloc_name); 981 982 982 983 /* the caller must hold dcache_lock */ 983 984 static void __d_instantiate(struct dentry *dentry, struct inode *inode)
+1 -6
fs/ecryptfs/main.c
··· 35 35 #include <linux/key.h> 36 36 #include <linux/parser.h> 37 37 #include <linux/fs_stack.h> 38 - #include <linux/ima.h> 39 38 #include "ecryptfs_kernel.h" 40 39 41 40 /** ··· 118 119 const struct cred *cred = current_cred(); 119 120 struct ecryptfs_inode_info *inode_info = 120 121 ecryptfs_inode_to_private(ecryptfs_dentry->d_inode); 121 - int opened_lower_file = 0; 122 122 int rc = 0; 123 123 124 124 mutex_lock(&inode_info->lower_file_mutex); ··· 134 136 "for lower_dentry [0x%p] and lower_mnt [0x%p]; " 135 137 "rc = [%d]\n", lower_dentry, lower_mnt, rc); 136 138 inode_info->lower_file = NULL; 137 - } else 138 - opened_lower_file = 1; 139 + } 139 140 } 140 141 mutex_unlock(&inode_info->lower_file_mutex); 141 - if (opened_lower_file) 142 - ima_counts_get(inode_info->lower_file); 143 142 return rc; 144 143 } 145 144
+25 -54
fs/ext2/acl.c
··· 339 339 * Extended attribut handlers 340 340 */ 341 341 static size_t 342 - ext2_xattr_list_acl_access(struct inode *inode, char *list, size_t list_size, 343 - const char *name, size_t name_len) 342 + ext2_xattr_list_acl_access(struct dentry *dentry, char *list, size_t list_size, 343 + const char *name, size_t name_len, int type) 344 344 { 345 345 const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); 346 346 347 - if (!test_opt(inode->i_sb, POSIX_ACL)) 347 + if (!test_opt(dentry->d_sb, POSIX_ACL)) 348 348 return 0; 349 349 if (list && size <= list_size) 350 350 memcpy(list, POSIX_ACL_XATTR_ACCESS, size); ··· 352 352 } 353 353 354 354 static size_t 355 - ext2_xattr_list_acl_default(struct inode *inode, char *list, size_t list_size, 356 - const char *name, size_t name_len) 355 + ext2_xattr_list_acl_default(struct dentry *dentry, char *list, size_t list_size, 356 + const char *name, size_t name_len, int type) 357 357 { 358 358 const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); 359 359 360 - if (!test_opt(inode->i_sb, POSIX_ACL)) 360 + if (!test_opt(dentry->d_sb, POSIX_ACL)) 361 361 return 0; 362 362 if (list && size <= list_size) 363 363 memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); ··· 365 365 } 366 366 367 367 static int 368 - ext2_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size) 368 + ext2_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer, 369 + size_t size, int type) 369 370 { 370 371 struct posix_acl *acl; 371 372 int error; 372 373 373 - if (!test_opt(inode->i_sb, POSIX_ACL)) 374 + if (strcmp(name, "") != 0) 375 + return -EINVAL; 376 + if (!test_opt(dentry->d_sb, POSIX_ACL)) 374 377 return -EOPNOTSUPP; 375 378 376 - acl = ext2_get_acl(inode, type); 379 + acl = ext2_get_acl(dentry->d_inode, type); 377 380 if (IS_ERR(acl)) 378 381 return PTR_ERR(acl); 379 382 if (acl == NULL) ··· 388 385 } 389 386 390 387 static int 391 - ext2_xattr_get_acl_access(struct inode *inode, const char *name, 392 - void *buffer, size_t size) 393 - { 394 - if (strcmp(name, "") != 0) 395 - return -EINVAL; 396 - return ext2_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size); 397 - } 398 - 399 - static int 400 - ext2_xattr_get_acl_default(struct inode *inode, const char *name, 401 - void *buffer, size_t size) 402 - { 403 - if (strcmp(name, "") != 0) 404 - return -EINVAL; 405 - return ext2_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size); 406 - } 407 - 408 - static int 409 - ext2_xattr_set_acl(struct inode *inode, int type, const void *value, 410 - size_t size) 388 + ext2_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, 389 + size_t size, int flags, int type) 411 390 { 412 391 struct posix_acl *acl; 413 392 int error; 414 393 415 - if (!test_opt(inode->i_sb, POSIX_ACL)) 394 + if (strcmp(name, "") != 0) 395 + return -EINVAL; 396 + if (!test_opt(dentry->d_sb, POSIX_ACL)) 416 397 return -EOPNOTSUPP; 417 - if (!is_owner_or_cap(inode)) 398 + if (!is_owner_or_cap(dentry->d_inode)) 418 399 return -EPERM; 419 400 420 401 if (value) { ··· 413 426 } else 414 427 acl = NULL; 415 428 416 - error = ext2_set_acl(inode, type, acl); 429 + error = ext2_set_acl(dentry->d_inode, type, acl); 417 430 418 431 release_and_out: 419 432 posix_acl_release(acl); 420 433 return error; 421 434 } 422 435 423 - static int 424 - ext2_xattr_set_acl_access(struct inode *inode, const char *name, 425 - const void *value, size_t size, int flags) 426 - { 427 - if (strcmp(name, "") != 0) 428 - return -EINVAL; 429 - return ext2_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); 430 - } 431 - 432 - static int 433 - ext2_xattr_set_acl_default(struct inode *inode, const char *name, 434 - const void *value, size_t size, int flags) 435 - { 436 - if (strcmp(name, "") != 0) 437 - return -EINVAL; 438 - return ext2_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); 439 - } 440 - 441 436 struct xattr_handler ext2_xattr_acl_access_handler = { 442 437 .prefix = POSIX_ACL_XATTR_ACCESS, 438 + .flags = ACL_TYPE_ACCESS, 443 439 .list = ext2_xattr_list_acl_access, 444 - .get = ext2_xattr_get_acl_access, 445 - .set = ext2_xattr_set_acl_access, 440 + .get = ext2_xattr_get_acl, 441 + .set = ext2_xattr_set_acl, 446 442 }; 447 443 448 444 struct xattr_handler ext2_xattr_acl_default_handler = { 449 445 .prefix = POSIX_ACL_XATTR_DEFAULT, 446 + .flags = ACL_TYPE_DEFAULT, 450 447 .list = ext2_xattr_list_acl_default, 451 - .get = ext2_xattr_get_acl_default, 452 - .set = ext2_xattr_set_acl_default, 448 + .get = ext2_xattr_get_acl, 449 + .set = ext2_xattr_set_acl, 453 450 };
+7 -4
fs/ext2/xattr.c
··· 60 60 #include <linux/mbcache.h> 61 61 #include <linux/quotaops.h> 62 62 #include <linux/rwsem.h> 63 + #include <linux/security.h> 63 64 #include "ext2.h" 64 65 #include "xattr.h" 65 66 #include "acl.h" ··· 250 249 * used / required on success. 251 250 */ 252 251 static int 253 - ext2_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) 252 + ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size) 254 253 { 254 + struct inode *inode = dentry->d_inode; 255 255 struct buffer_head *bh = NULL; 256 256 struct ext2_xattr_entry *entry; 257 257 char *end; ··· 302 300 ext2_xattr_handler(entry->e_name_index); 303 301 304 302 if (handler) { 305 - size_t size = handler->list(inode, buffer, rest, 303 + size_t size = handler->list(dentry, buffer, rest, 306 304 entry->e_name, 307 - entry->e_name_len); 305 + entry->e_name_len, 306 + handler->flags); 308 307 if (buffer) { 309 308 if (size > rest) { 310 309 error = -ERANGE; ··· 333 330 ssize_t 334 331 ext2_listxattr(struct dentry *dentry, char *buffer, size_t size) 335 332 { 336 - return ext2_xattr_list(dentry->d_inode, buffer, size); 333 + return ext2_xattr_list(dentry, buffer, size); 337 334 } 338 335 339 336 /*
+8 -8
fs/ext2/xattr_security.c
··· 11 11 #include "xattr.h" 12 12 13 13 static size_t 14 - ext2_xattr_security_list(struct inode *inode, char *list, size_t list_size, 15 - const char *name, size_t name_len) 14 + ext2_xattr_security_list(struct dentry *dentry, char *list, size_t list_size, 15 + const char *name, size_t name_len, int type) 16 16 { 17 17 const int prefix_len = XATTR_SECURITY_PREFIX_LEN; 18 18 const size_t total_len = prefix_len + name_len + 1; ··· 26 26 } 27 27 28 28 static int 29 - ext2_xattr_security_get(struct inode *inode, const char *name, 30 - void *buffer, size_t size) 29 + ext2_xattr_security_get(struct dentry *dentry, const char *name, 30 + void *buffer, size_t size, int type) 31 31 { 32 32 if (strcmp(name, "") == 0) 33 33 return -EINVAL; 34 - return ext2_xattr_get(inode, EXT2_XATTR_INDEX_SECURITY, name, 34 + return ext2_xattr_get(dentry->d_inode, EXT2_XATTR_INDEX_SECURITY, name, 35 35 buffer, size); 36 36 } 37 37 38 38 static int 39 - ext2_xattr_security_set(struct inode *inode, const char *name, 40 - const void *value, size_t size, int flags) 39 + ext2_xattr_security_set(struct dentry *dentry, const char *name, 40 + const void *value, size_t size, int flags, int type) 41 41 { 42 42 if (strcmp(name, "") == 0) 43 43 return -EINVAL; 44 - return ext2_xattr_set(inode, EXT2_XATTR_INDEX_SECURITY, name, 44 + return ext2_xattr_set(dentry->d_inode, EXT2_XATTR_INDEX_SECURITY, name, 45 45 value, size, flags); 46 46 } 47 47
+8 -8
fs/ext2/xattr_trusted.c
··· 13 13 #include "xattr.h" 14 14 15 15 static size_t 16 - ext2_xattr_trusted_list(struct inode *inode, char *list, size_t list_size, 17 - const char *name, size_t name_len) 16 + ext2_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size, 17 + const char *name, size_t name_len, int type) 18 18 { 19 19 const int prefix_len = XATTR_TRUSTED_PREFIX_LEN; 20 20 const size_t total_len = prefix_len + name_len + 1; ··· 31 31 } 32 32 33 33 static int 34 - ext2_xattr_trusted_get(struct inode *inode, const char *name, 35 - void *buffer, size_t size) 34 + ext2_xattr_trusted_get(struct dentry *dentry, const char *name, 35 + void *buffer, size_t size, int type) 36 36 { 37 37 if (strcmp(name, "") == 0) 38 38 return -EINVAL; 39 - return ext2_xattr_get(inode, EXT2_XATTR_INDEX_TRUSTED, name, 39 + return ext2_xattr_get(dentry->d_inode, EXT2_XATTR_INDEX_TRUSTED, name, 40 40 buffer, size); 41 41 } 42 42 43 43 static int 44 - ext2_xattr_trusted_set(struct inode *inode, const char *name, 45 - const void *value, size_t size, int flags) 44 + ext2_xattr_trusted_set(struct dentry *dentry, const char *name, 45 + const void *value, size_t size, int flags, int type) 46 46 { 47 47 if (strcmp(name, "") == 0) 48 48 return -EINVAL; 49 - return ext2_xattr_set(inode, EXT2_XATTR_INDEX_TRUSTED, name, 49 + return ext2_xattr_set(dentry->d_inode, EXT2_XATTR_INDEX_TRUSTED, name, 50 50 value, size, flags); 51 51 } 52 52
+13 -12
fs/ext2/xattr_user.c
··· 12 12 #include "xattr.h" 13 13 14 14 static size_t 15 - ext2_xattr_user_list(struct inode *inode, char *list, size_t list_size, 16 - const char *name, size_t name_len) 15 + ext2_xattr_user_list(struct dentry *dentry, char *list, size_t list_size, 16 + const char *name, size_t name_len, int type) 17 17 { 18 18 const size_t prefix_len = XATTR_USER_PREFIX_LEN; 19 19 const size_t total_len = prefix_len + name_len + 1; 20 20 21 - if (!test_opt(inode->i_sb, XATTR_USER)) 21 + if (!test_opt(dentry->d_sb, XATTR_USER)) 22 22 return 0; 23 23 24 24 if (list && total_len <= list_size) { ··· 30 30 } 31 31 32 32 static int 33 - ext2_xattr_user_get(struct inode *inode, const char *name, 34 - void *buffer, size_t size) 33 + ext2_xattr_user_get(struct dentry *dentry, const char *name, 34 + void *buffer, size_t size, int type) 35 35 { 36 36 if (strcmp(name, "") == 0) 37 37 return -EINVAL; 38 - if (!test_opt(inode->i_sb, XATTR_USER)) 38 + if (!test_opt(dentry->d_sb, XATTR_USER)) 39 39 return -EOPNOTSUPP; 40 - return ext2_xattr_get(inode, EXT2_XATTR_INDEX_USER, name, buffer, size); 40 + return ext2_xattr_get(dentry->d_inode, EXT2_XATTR_INDEX_USER, 41 + name, buffer, size); 41 42 } 42 43 43 44 static int 44 - ext2_xattr_user_set(struct inode *inode, const char *name, 45 - const void *value, size_t size, int flags) 45 + ext2_xattr_user_set(struct dentry *dentry, const char *name, 46 + const void *value, size_t size, int flags, int type) 46 47 { 47 48 if (strcmp(name, "") == 0) 48 49 return -EINVAL; 49 - if (!test_opt(inode->i_sb, XATTR_USER)) 50 + if (!test_opt(dentry->d_sb, XATTR_USER)) 50 51 return -EOPNOTSUPP; 51 52 52 - return ext2_xattr_set(inode, EXT2_XATTR_INDEX_USER, name, 53 - value, size, flags); 53 + return ext2_xattr_set(dentry->d_inode, EXT2_XATTR_INDEX_USER, 54 + name, value, size, flags); 54 55 } 55 56 56 57 struct xattr_handler ext2_xattr_user_handler = {
+23 -51
fs/ext3/acl.c
··· 366 366 * Extended attribute handlers 367 367 */ 368 368 static size_t 369 - ext3_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len, 370 - const char *name, size_t name_len) 369 + ext3_xattr_list_acl_access(struct dentry *dentry, char *list, size_t list_len, 370 + const char *name, size_t name_len, int type) 371 371 { 372 372 const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); 373 373 374 - if (!test_opt(inode->i_sb, POSIX_ACL)) 374 + if (!test_opt(dentry->d_sb, POSIX_ACL)) 375 375 return 0; 376 376 if (list && size <= list_len) 377 377 memcpy(list, POSIX_ACL_XATTR_ACCESS, size); ··· 379 379 } 380 380 381 381 static size_t 382 - ext3_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len, 383 - const char *name, size_t name_len) 382 + ext3_xattr_list_acl_default(struct dentry *dentry, char *list, size_t list_len, 383 + const char *name, size_t name_len, int type) 384 384 { 385 385 const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); 386 386 387 - if (!test_opt(inode->i_sb, POSIX_ACL)) 387 + if (!test_opt(dentry->d_sb, POSIX_ACL)) 388 388 return 0; 389 389 if (list && size <= list_len) 390 390 memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); ··· 392 392 } 393 393 394 394 static int 395 - ext3_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size) 395 + ext3_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer, 396 + size_t size, int type) 396 397 { 397 398 struct posix_acl *acl; 398 399 int error; 399 400 400 - if (!test_opt(inode->i_sb, POSIX_ACL)) 401 + if (strcmp(name, "") != 0) 402 + return -EINVAL; 403 + if (!test_opt(dentry->d_sb, POSIX_ACL)) 401 404 return -EOPNOTSUPP; 402 405 403 - acl = ext3_get_acl(inode, type); 406 + acl = ext3_get_acl(dentry->d_inode, type); 404 407 if (IS_ERR(acl)) 405 408 return PTR_ERR(acl); 406 409 if (acl == NULL) ··· 415 412 } 416 413 417 414 static int 418 - ext3_xattr_get_acl_access(struct inode *inode, const char *name, 419 - void *buffer, size_t size) 415 + ext3_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, 416 + size_t size, int flags, int type) 420 417 { 421 - if (strcmp(name, "") != 0) 422 - return -EINVAL; 423 - return ext3_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size); 424 - } 425 - 426 - static int 427 - ext3_xattr_get_acl_default(struct inode *inode, const char *name, 428 - void *buffer, size_t size) 429 - { 430 - if (strcmp(name, "") != 0) 431 - return -EINVAL; 432 - return ext3_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size); 433 - } 434 - 435 - static int 436 - ext3_xattr_set_acl(struct inode *inode, int type, const void *value, 437 - size_t size) 438 - { 418 + struct inode *inode = dentry->d_inode; 439 419 handle_t *handle; 440 420 struct posix_acl *acl; 441 421 int error, retries = 0; 442 422 423 + if (strcmp(name, "") != 0) 424 + return -EINVAL; 443 425 if (!test_opt(inode->i_sb, POSIX_ACL)) 444 426 return -EOPNOTSUPP; 445 427 if (!is_owner_or_cap(inode)) ··· 456 468 return error; 457 469 } 458 470 459 - static int 460 - ext3_xattr_set_acl_access(struct inode *inode, const char *name, 461 - const void *value, size_t size, int flags) 462 - { 463 - if (strcmp(name, "") != 0) 464 - return -EINVAL; 465 - return ext3_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); 466 - } 467 - 468 - static int 469 - ext3_xattr_set_acl_default(struct inode *inode, const char *name, 470 - const void *value, size_t size, int flags) 471 - { 472 - if (strcmp(name, "") != 0) 473 - return -EINVAL; 474 - return ext3_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); 475 - } 476 - 477 471 struct xattr_handler ext3_xattr_acl_access_handler = { 478 472 .prefix = POSIX_ACL_XATTR_ACCESS, 473 + .flags = ACL_TYPE_ACCESS, 479 474 .list = ext3_xattr_list_acl_access, 480 - .get = ext3_xattr_get_acl_access, 481 - .set = ext3_xattr_set_acl_access, 475 + .get = ext3_xattr_get_acl, 476 + .set = ext3_xattr_set_acl, 482 477 }; 483 478 484 479 struct xattr_handler ext3_xattr_acl_default_handler = { 485 480 .prefix = POSIX_ACL_XATTR_DEFAULT, 481 + .flags = ACL_TYPE_DEFAULT, 486 482 .list = ext3_xattr_list_acl_default, 487 - .get = ext3_xattr_get_acl_default, 488 - .set = ext3_xattr_set_acl_default, 483 + .get = ext3_xattr_get_acl, 484 + .set = ext3_xattr_set_acl, 489 485 };
+17 -14
fs/ext3/xattr.c
··· 99 99 struct mb_cache_entry **); 100 100 static void ext3_xattr_rehash(struct ext3_xattr_header *, 101 101 struct ext3_xattr_entry *); 102 - static int ext3_xattr_list(struct inode *inode, char *buffer, 102 + static int ext3_xattr_list(struct dentry *dentry, char *buffer, 103 103 size_t buffer_size); 104 104 105 105 static struct mb_cache *ext3_xattr_cache; ··· 147 147 ssize_t 148 148 ext3_listxattr(struct dentry *dentry, char *buffer, size_t size) 149 149 { 150 - return ext3_xattr_list(dentry->d_inode, buffer, size); 150 + return ext3_xattr_list(dentry, buffer, size); 151 151 } 152 152 153 153 static int ··· 332 332 } 333 333 334 334 static int 335 - ext3_xattr_list_entries(struct inode *inode, struct ext3_xattr_entry *entry, 335 + ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry, 336 336 char *buffer, size_t buffer_size) 337 337 { 338 338 size_t rest = buffer_size; ··· 342 342 ext3_xattr_handler(entry->e_name_index); 343 343 344 344 if (handler) { 345 - size_t size = handler->list(inode, buffer, rest, 345 + size_t size = handler->list(dentry, buffer, rest, 346 346 entry->e_name, 347 - entry->e_name_len); 347 + entry->e_name_len, 348 + handler->flags); 348 349 if (buffer) { 349 350 if (size > rest) 350 351 return -ERANGE; ··· 358 357 } 359 358 360 359 static int 361 - ext3_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size) 360 + ext3_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size) 362 361 { 362 + struct inode *inode = dentry->d_inode; 363 363 struct buffer_head *bh = NULL; 364 364 int error; 365 365 ··· 385 383 goto cleanup; 386 384 } 387 385 ext3_xattr_cache_insert(bh); 388 - error = ext3_xattr_list_entries(inode, BFIRST(bh), buffer, buffer_size); 386 + error = ext3_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size); 389 387 390 388 cleanup: 391 389 brelse(bh); ··· 394 392 } 395 393 396 394 static int 397 - ext3_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size) 395 + ext3_xattr_ibody_list(struct dentry *dentry, char *buffer, size_t buffer_size) 398 396 { 397 + struct inode *inode = dentry->d_inode; 399 398 struct ext3_xattr_ibody_header *header; 400 399 struct ext3_inode *raw_inode; 401 400 struct ext3_iloc iloc; ··· 414 411 error = ext3_xattr_check_names(IFIRST(header), end); 415 412 if (error) 416 413 goto cleanup; 417 - error = ext3_xattr_list_entries(inode, IFIRST(header), 414 + error = ext3_xattr_list_entries(dentry, IFIRST(header), 418 415 buffer, buffer_size); 419 416 420 417 cleanup: ··· 433 430 * used / required on success. 434 431 */ 435 432 static int 436 - ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) 433 + ext3_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size) 437 434 { 438 435 int i_error, b_error; 439 436 440 - down_read(&EXT3_I(inode)->xattr_sem); 441 - i_error = ext3_xattr_ibody_list(inode, buffer, buffer_size); 437 + down_read(&EXT3_I(dentry->d_inode)->xattr_sem); 438 + i_error = ext3_xattr_ibody_list(dentry, buffer, buffer_size); 442 439 if (i_error < 0) { 443 440 b_error = 0; 444 441 } else { ··· 446 443 buffer += i_error; 447 444 buffer_size -= i_error; 448 445 } 449 - b_error = ext3_xattr_block_list(inode, buffer, buffer_size); 446 + b_error = ext3_xattr_block_list(dentry, buffer, buffer_size); 450 447 if (b_error < 0) 451 448 i_error = 0; 452 449 } 453 - up_read(&EXT3_I(inode)->xattr_sem); 450 + up_read(&EXT3_I(dentry->d_inode)->xattr_sem); 454 451 return i_error + b_error; 455 452 } 456 453
+10 -10
fs/ext3/xattr_security.c
··· 12 12 #include "xattr.h" 13 13 14 14 static size_t 15 - ext3_xattr_security_list(struct inode *inode, char *list, size_t list_size, 16 - const char *name, size_t name_len) 15 + ext3_xattr_security_list(struct dentry *dentry, char *list, size_t list_size, 16 + const char *name, size_t name_len, int type) 17 17 { 18 18 const size_t prefix_len = XATTR_SECURITY_PREFIX_LEN; 19 19 const size_t total_len = prefix_len + name_len + 1; ··· 28 28 } 29 29 30 30 static int 31 - ext3_xattr_security_get(struct inode *inode, const char *name, 32 - void *buffer, size_t size) 31 + ext3_xattr_security_get(struct dentry *dentry, const char *name, 32 + void *buffer, size_t size, int type) 33 33 { 34 34 if (strcmp(name, "") == 0) 35 35 return -EINVAL; 36 - return ext3_xattr_get(inode, EXT3_XATTR_INDEX_SECURITY, name, 37 - buffer, size); 36 + return ext3_xattr_get(dentry->d_inode, EXT3_XATTR_INDEX_SECURITY, 37 + name, buffer, size); 38 38 } 39 39 40 40 static int 41 - ext3_xattr_security_set(struct inode *inode, const char *name, 42 - const void *value, size_t size, int flags) 41 + ext3_xattr_security_set(struct dentry *dentry, const char *name, 42 + const void *value, size_t size, int flags, int type) 43 43 { 44 44 if (strcmp(name, "") == 0) 45 45 return -EINVAL; 46 - return ext3_xattr_set(inode, EXT3_XATTR_INDEX_SECURITY, name, 47 - value, size, flags); 46 + return ext3_xattr_set(dentry->d_inode, EXT3_XATTR_INDEX_SECURITY, 47 + name, value, size, flags); 48 48 } 49 49 50 50 int
+9 -9
fs/ext3/xattr_trusted.c
··· 14 14 #include "xattr.h" 15 15 16 16 static size_t 17 - ext3_xattr_trusted_list(struct inode *inode, char *list, size_t list_size, 18 - const char *name, size_t name_len) 17 + ext3_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size, 18 + const char *name, size_t name_len, int type) 19 19 { 20 20 const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN; 21 21 const size_t total_len = prefix_len + name_len + 1; ··· 32 32 } 33 33 34 34 static int 35 - ext3_xattr_trusted_get(struct inode *inode, const char *name, 36 - void *buffer, size_t size) 35 + ext3_xattr_trusted_get(struct dentry *dentry, const char *name, 36 + void *buffer, size_t size, int type) 37 37 { 38 38 if (strcmp(name, "") == 0) 39 39 return -EINVAL; 40 - return ext3_xattr_get(inode, EXT3_XATTR_INDEX_TRUSTED, name, 41 - buffer, size); 40 + return ext3_xattr_get(dentry->d_inode, EXT3_XATTR_INDEX_TRUSTED, 41 + name, buffer, size); 42 42 } 43 43 44 44 static int 45 - ext3_xattr_trusted_set(struct inode *inode, const char *name, 46 - const void *value, size_t size, int flags) 45 + ext3_xattr_trusted_set(struct dentry *dentry, const char *name, 46 + const void *value, size_t size, int flags, int type) 47 47 { 48 48 if (strcmp(name, "") == 0) 49 49 return -EINVAL; 50 - return ext3_xattr_set(inode, EXT3_XATTR_INDEX_TRUSTED, name, 50 + return ext3_xattr_set(dentry->d_inode, EXT3_XATTR_INDEX_TRUSTED, name, 51 51 value, size, flags); 52 52 } 53 53
+13 -12
fs/ext3/xattr_user.c
··· 13 13 #include "xattr.h" 14 14 15 15 static size_t 16 - ext3_xattr_user_list(struct inode *inode, char *list, size_t list_size, 17 - const char *name, size_t name_len) 16 + ext3_xattr_user_list(struct dentry *dentry, char *list, size_t list_size, 17 + const char *name, size_t name_len, int type) 18 18 { 19 19 const size_t prefix_len = XATTR_USER_PREFIX_LEN; 20 20 const size_t total_len = prefix_len + name_len + 1; 21 21 22 - if (!test_opt(inode->i_sb, XATTR_USER)) 22 + if (!test_opt(dentry->d_sb, XATTR_USER)) 23 23 return 0; 24 24 25 25 if (list && total_len <= list_size) { ··· 31 31 } 32 32 33 33 static int 34 - ext3_xattr_user_get(struct inode *inode, const char *name, 35 - void *buffer, size_t size) 34 + ext3_xattr_user_get(struct dentry *dentry, const char *name, void *buffer, 35 + size_t size, int type) 36 36 { 37 37 if (strcmp(name, "") == 0) 38 38 return -EINVAL; 39 - if (!test_opt(inode->i_sb, XATTR_USER)) 39 + if (!test_opt(dentry->d_sb, XATTR_USER)) 40 40 return -EOPNOTSUPP; 41 - return ext3_xattr_get(inode, EXT3_XATTR_INDEX_USER, name, buffer, size); 41 + return ext3_xattr_get(dentry->d_inode, EXT3_XATTR_INDEX_USER, 42 + name, buffer, size); 42 43 } 43 44 44 45 static int 45 - ext3_xattr_user_set(struct inode *inode, const char *name, 46 - const void *value, size_t size, int flags) 46 + ext3_xattr_user_set(struct dentry *dentry, const char *name, 47 + const void *value, size_t size, int flags, int type) 47 48 { 48 49 if (strcmp(name, "") == 0) 49 50 return -EINVAL; 50 - if (!test_opt(inode->i_sb, XATTR_USER)) 51 + if (!test_opt(dentry->d_sb, XATTR_USER)) 51 52 return -EOPNOTSUPP; 52 - return ext3_xattr_set(inode, EXT3_XATTR_INDEX_USER, name, 53 - value, size, flags); 53 + return ext3_xattr_set(dentry->d_inode, EXT3_XATTR_INDEX_USER, 54 + name, value, size, flags); 54 55 } 55 56 56 57 struct xattr_handler ext3_xattr_user_handler = {
+23 -51
fs/ext4/acl.c
··· 364 364 * Extended attribute handlers 365 365 */ 366 366 static size_t 367 - ext4_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len, 368 - const char *name, size_t name_len) 367 + ext4_xattr_list_acl_access(struct dentry *dentry, char *list, size_t list_len, 368 + const char *name, size_t name_len, int type) 369 369 { 370 370 const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); 371 371 372 - if (!test_opt(inode->i_sb, POSIX_ACL)) 372 + if (!test_opt(dentry->d_sb, POSIX_ACL)) 373 373 return 0; 374 374 if (list && size <= list_len) 375 375 memcpy(list, POSIX_ACL_XATTR_ACCESS, size); ··· 377 377 } 378 378 379 379 static size_t 380 - ext4_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len, 381 - const char *name, size_t name_len) 380 + ext4_xattr_list_acl_default(struct dentry *dentry, char *list, size_t list_len, 381 + const char *name, size_t name_len, int type) 382 382 { 383 383 const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); 384 384 385 - if (!test_opt(inode->i_sb, POSIX_ACL)) 385 + if (!test_opt(dentry->d_sb, POSIX_ACL)) 386 386 return 0; 387 387 if (list && size <= list_len) 388 388 memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); ··· 390 390 } 391 391 392 392 static int 393 - ext4_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size) 393 + ext4_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer, 394 + size_t size, int type) 394 395 { 395 396 struct posix_acl *acl; 396 397 int error; 397 398 398 - if (!test_opt(inode->i_sb, POSIX_ACL)) 399 + if (strcmp(name, "") != 0) 400 + return -EINVAL; 401 + if (!test_opt(dentry->d_sb, POSIX_ACL)) 399 402 return -EOPNOTSUPP; 400 403 401 - acl = ext4_get_acl(inode, type); 404 + acl = ext4_get_acl(dentry->d_inode, type); 402 405 if (IS_ERR(acl)) 403 406 return PTR_ERR(acl); 404 407 if (acl == NULL) ··· 413 410 } 414 411 415 412 static int 416 - ext4_xattr_get_acl_access(struct inode *inode, const char *name, 417 - void *buffer, size_t size) 413 + ext4_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, 414 + size_t size, int flags, int type) 418 415 { 419 - if (strcmp(name, "") != 0) 420 - return -EINVAL; 421 - return ext4_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size); 422 - } 423 - 424 - static int 425 - ext4_xattr_get_acl_default(struct inode *inode, const char *name, 426 - void *buffer, size_t size) 427 - { 428 - if (strcmp(name, "") != 0) 429 - return -EINVAL; 430 - return ext4_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size); 431 - } 432 - 433 - static int 434 - ext4_xattr_set_acl(struct inode *inode, int type, const void *value, 435 - size_t size) 436 - { 416 + struct inode *inode = dentry->d_inode; 437 417 handle_t *handle; 438 418 struct posix_acl *acl; 439 419 int error, retries = 0; 440 420 421 + if (strcmp(name, "") != 0) 422 + return -EINVAL; 441 423 if (!test_opt(inode->i_sb, POSIX_ACL)) 442 424 return -EOPNOTSUPP; 443 425 if (!is_owner_or_cap(inode)) ··· 454 466 return error; 455 467 } 456 468 457 - static int 458 - ext4_xattr_set_acl_access(struct inode *inode, const char *name, 459 - const void *value, size_t size, int flags) 460 - { 461 - if (strcmp(name, "") != 0) 462 - return -EINVAL; 463 - return ext4_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); 464 - } 465 - 466 - static int 467 - ext4_xattr_set_acl_default(struct inode *inode, const char *name, 468 - const void *value, size_t size, int flags) 469 - { 470 - if (strcmp(name, "") != 0) 471 - return -EINVAL; 472 - return ext4_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); 473 - } 474 - 475 469 struct xattr_handler ext4_xattr_acl_access_handler = { 476 470 .prefix = POSIX_ACL_XATTR_ACCESS, 471 + .flags = ACL_TYPE_ACCESS, 477 472 .list = ext4_xattr_list_acl_access, 478 - .get = ext4_xattr_get_acl_access, 479 - .set = ext4_xattr_set_acl_access, 473 + .get = ext4_xattr_get_acl, 474 + .set = ext4_xattr_set_acl, 480 475 }; 481 476 482 477 struct xattr_handler ext4_xattr_acl_default_handler = { 483 478 .prefix = POSIX_ACL_XATTR_DEFAULT, 479 + .flags = ACL_TYPE_DEFAULT, 484 480 .list = ext4_xattr_list_acl_default, 485 - .get = ext4_xattr_get_acl_default, 486 - .set = ext4_xattr_set_acl_default, 481 + .get = ext4_xattr_get_acl, 482 + .set = ext4_xattr_set_acl, 487 483 };
+17 -14
fs/ext4/xattr.c
··· 92 92 struct mb_cache_entry **); 93 93 static void ext4_xattr_rehash(struct ext4_xattr_header *, 94 94 struct ext4_xattr_entry *); 95 - static int ext4_xattr_list(struct inode *inode, char *buffer, 95 + static int ext4_xattr_list(struct dentry *dentry, char *buffer, 96 96 size_t buffer_size); 97 97 98 98 static struct mb_cache *ext4_xattr_cache; ··· 140 140 ssize_t 141 141 ext4_listxattr(struct dentry *dentry, char *buffer, size_t size) 142 142 { 143 - return ext4_xattr_list(dentry->d_inode, buffer, size); 143 + return ext4_xattr_list(dentry, buffer, size); 144 144 } 145 145 146 146 static int ··· 325 325 } 326 326 327 327 static int 328 - ext4_xattr_list_entries(struct inode *inode, struct ext4_xattr_entry *entry, 328 + ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry, 329 329 char *buffer, size_t buffer_size) 330 330 { 331 331 size_t rest = buffer_size; ··· 335 335 ext4_xattr_handler(entry->e_name_index); 336 336 337 337 if (handler) { 338 - size_t size = handler->list(inode, buffer, rest, 338 + size_t size = handler->list(dentry, buffer, rest, 339 339 entry->e_name, 340 - entry->e_name_len); 340 + entry->e_name_len, 341 + handler->flags); 341 342 if (buffer) { 342 343 if (size > rest) 343 344 return -ERANGE; ··· 351 350 } 352 351 353 352 static int 354 - ext4_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size) 353 + ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size) 355 354 { 355 + struct inode *inode = dentry->d_inode; 356 356 struct buffer_head *bh = NULL; 357 357 int error; 358 358 ··· 378 376 goto cleanup; 379 377 } 380 378 ext4_xattr_cache_insert(bh); 381 - error = ext4_xattr_list_entries(inode, BFIRST(bh), buffer, buffer_size); 379 + error = ext4_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size); 382 380 383 381 cleanup: 384 382 brelse(bh); ··· 387 385 } 388 386 389 387 static int 390 - ext4_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size) 388 + ext4_xattr_ibody_list(struct dentry *dentry, char *buffer, size_t buffer_size) 391 389 { 390 + struct inode *inode = dentry->d_inode; 392 391 struct ext4_xattr_ibody_header *header; 393 392 struct ext4_inode *raw_inode; 394 393 struct ext4_iloc iloc; ··· 407 404 error = ext4_xattr_check_names(IFIRST(header), end); 408 405 if (error) 409 406 goto cleanup; 410 - error = ext4_xattr_list_entries(inode, IFIRST(header), 407 + error = ext4_xattr_list_entries(dentry, IFIRST(header), 411 408 buffer, buffer_size); 412 409 413 410 cleanup: ··· 426 423 * used / required on success. 427 424 */ 428 425 static int 429 - ext4_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) 426 + ext4_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size) 430 427 { 431 428 int i_error, b_error; 432 429 433 - down_read(&EXT4_I(inode)->xattr_sem); 434 - i_error = ext4_xattr_ibody_list(inode, buffer, buffer_size); 430 + down_read(&EXT4_I(dentry->d_inode)->xattr_sem); 431 + i_error = ext4_xattr_ibody_list(dentry, buffer, buffer_size); 435 432 if (i_error < 0) { 436 433 b_error = 0; 437 434 } else { ··· 439 436 buffer += i_error; 440 437 buffer_size -= i_error; 441 438 } 442 - b_error = ext4_xattr_block_list(inode, buffer, buffer_size); 439 + b_error = ext4_xattr_block_list(dentry, buffer, buffer_size); 443 440 if (b_error < 0) 444 441 i_error = 0; 445 442 } 446 - up_read(&EXT4_I(inode)->xattr_sem); 443 + up_read(&EXT4_I(dentry->d_inode)->xattr_sem); 447 444 return i_error + b_error; 448 445 } 449 446
+10 -10
fs/ext4/xattr_security.c
··· 12 12 #include "xattr.h" 13 13 14 14 static size_t 15 - ext4_xattr_security_list(struct inode *inode, char *list, size_t list_size, 16 - const char *name, size_t name_len) 15 + ext4_xattr_security_list(struct dentry *dentry, char *list, size_t list_size, 16 + const char *name, size_t name_len, int type) 17 17 { 18 18 const size_t prefix_len = sizeof(XATTR_SECURITY_PREFIX)-1; 19 19 const size_t total_len = prefix_len + name_len + 1; ··· 28 28 } 29 29 30 30 static int 31 - ext4_xattr_security_get(struct inode *inode, const char *name, 32 - void *buffer, size_t size) 31 + ext4_xattr_security_get(struct dentry *dentry, const char *name, 32 + void *buffer, size_t size, int type) 33 33 { 34 34 if (strcmp(name, "") == 0) 35 35 return -EINVAL; 36 - return ext4_xattr_get(inode, EXT4_XATTR_INDEX_SECURITY, name, 37 - buffer, size); 36 + return ext4_xattr_get(dentry->d_inode, EXT4_XATTR_INDEX_SECURITY, 37 + name, buffer, size); 38 38 } 39 39 40 40 static int 41 - ext4_xattr_security_set(struct inode *inode, const char *name, 42 - const void *value, size_t size, int flags) 41 + ext4_xattr_security_set(struct dentry *dentry, const char *name, 42 + const void *value, size_t size, int flags, int type) 43 43 { 44 44 if (strcmp(name, "") == 0) 45 45 return -EINVAL; 46 - return ext4_xattr_set(inode, EXT4_XATTR_INDEX_SECURITY, name, 47 - value, size, flags); 46 + return ext4_xattr_set(dentry->d_inode, EXT4_XATTR_INDEX_SECURITY, 47 + name, value, size, flags); 48 48 } 49 49 50 50 int
+10 -10
fs/ext4/xattr_trusted.c
··· 14 14 #include "xattr.h" 15 15 16 16 static size_t 17 - ext4_xattr_trusted_list(struct inode *inode, char *list, size_t list_size, 18 - const char *name, size_t name_len) 17 + ext4_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size, 18 + const char *name, size_t name_len, int type) 19 19 { 20 20 const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN; 21 21 const size_t total_len = prefix_len + name_len + 1; ··· 32 32 } 33 33 34 34 static int 35 - ext4_xattr_trusted_get(struct inode *inode, const char *name, 36 - void *buffer, size_t size) 35 + ext4_xattr_trusted_get(struct dentry *dentry, const char *name, void *buffer, 36 + size_t size, int type) 37 37 { 38 38 if (strcmp(name, "") == 0) 39 39 return -EINVAL; 40 - return ext4_xattr_get(inode, EXT4_XATTR_INDEX_TRUSTED, name, 41 - buffer, size); 40 + return ext4_xattr_get(dentry->d_inode, EXT4_XATTR_INDEX_TRUSTED, 41 + name, buffer, size); 42 42 } 43 43 44 44 static int 45 - ext4_xattr_trusted_set(struct inode *inode, const char *name, 46 - const void *value, size_t size, int flags) 45 + ext4_xattr_trusted_set(struct dentry *dentry, const char *name, 46 + const void *value, size_t size, int flags, int type) 47 47 { 48 48 if (strcmp(name, "") == 0) 49 49 return -EINVAL; 50 - return ext4_xattr_set(inode, EXT4_XATTR_INDEX_TRUSTED, name, 51 - value, size, flags); 50 + return ext4_xattr_set(dentry->d_inode, EXT4_XATTR_INDEX_TRUSTED, 51 + name, value, size, flags); 52 52 } 53 53 54 54 struct xattr_handler ext4_xattr_trusted_handler = {
+13 -12
fs/ext4/xattr_user.c
··· 13 13 #include "xattr.h" 14 14 15 15 static size_t 16 - ext4_xattr_user_list(struct inode *inode, char *list, size_t list_size, 17 - const char *name, size_t name_len) 16 + ext4_xattr_user_list(struct dentry *dentry, char *list, size_t list_size, 17 + const char *name, size_t name_len, int type) 18 18 { 19 19 const size_t prefix_len = XATTR_USER_PREFIX_LEN; 20 20 const size_t total_len = prefix_len + name_len + 1; 21 21 22 - if (!test_opt(inode->i_sb, XATTR_USER)) 22 + if (!test_opt(dentry->d_sb, XATTR_USER)) 23 23 return 0; 24 24 25 25 if (list && total_len <= list_size) { ··· 31 31 } 32 32 33 33 static int 34 - ext4_xattr_user_get(struct inode *inode, const char *name, 35 - void *buffer, size_t size) 34 + ext4_xattr_user_get(struct dentry *dentry, const char *name, 35 + void *buffer, size_t size, int type) 36 36 { 37 37 if (strcmp(name, "") == 0) 38 38 return -EINVAL; 39 - if (!test_opt(inode->i_sb, XATTR_USER)) 39 + if (!test_opt(dentry->d_sb, XATTR_USER)) 40 40 return -EOPNOTSUPP; 41 - return ext4_xattr_get(inode, EXT4_XATTR_INDEX_USER, name, buffer, size); 41 + return ext4_xattr_get(dentry->d_inode, EXT4_XATTR_INDEX_USER, 42 + name, buffer, size); 42 43 } 43 44 44 45 static int 45 - ext4_xattr_user_set(struct inode *inode, const char *name, 46 - const void *value, size_t size, int flags) 46 + ext4_xattr_user_set(struct dentry *dentry, const char *name, 47 + const void *value, size_t size, int flags, int type) 47 48 { 48 49 if (strcmp(name, "") == 0) 49 50 return -EINVAL; 50 - if (!test_opt(inode->i_sb, XATTR_USER)) 51 + if (!test_opt(dentry->d_sb, XATTR_USER)) 51 52 return -EOPNOTSUPP; 52 - return ext4_xattr_set(inode, EXT4_XATTR_INDEX_USER, name, 53 - value, size, flags); 53 + return ext4_xattr_set(dentry->d_inode, EXT4_XATTR_INDEX_USER, 54 + name, value, size, flags); 54 55 } 55 56 56 57 struct xattr_handler ext4_xattr_user_handler = {
+12 -37
fs/file_table.c
··· 21 21 #include <linux/fsnotify.h> 22 22 #include <linux/sysctl.h> 23 23 #include <linux/percpu_counter.h> 24 + #include <linux/ima.h> 24 25 25 26 #include <asm/atomic.h> 27 + 28 + #include "internal.h" 26 29 27 30 /* sysctl tunables... */ 28 31 struct files_stat_struct files_stat = { ··· 150 147 return NULL; 151 148 } 152 149 153 - EXPORT_SYMBOL(get_empty_filp); 154 - 155 150 /** 156 151 * alloc_file - allocate and initialize a 'struct file' 157 152 * @mnt: the vfsmount on which the file will reside ··· 165 164 * If all the callers of init_file() are eliminated, its 166 165 * code should be moved into this function. 167 166 */ 168 - struct file *alloc_file(struct vfsmount *mnt, struct dentry *dentry, 169 - fmode_t mode, const struct file_operations *fop) 167 + struct file *alloc_file(struct path *path, fmode_t mode, 168 + const struct file_operations *fop) 170 169 { 171 170 struct file *file; 172 171 ··· 174 173 if (!file) 175 174 return NULL; 176 175 177 - init_file(file, mnt, dentry, mode, fop); 178 - return file; 179 - } 180 - EXPORT_SYMBOL(alloc_file); 181 - 182 - /** 183 - * init_file - initialize a 'struct file' 184 - * @file: the already allocated 'struct file' to initialized 185 - * @mnt: the vfsmount on which the file resides 186 - * @dentry: the dentry representing this file 187 - * @mode: the mode the file is opened with 188 - * @fop: the 'struct file_operations' for this file 189 - * 190 - * Use this instead of setting the members directly. Doing so 191 - * avoids making mistakes like forgetting the mntget() or 192 - * forgetting to take a write on the mnt. 193 - * 194 - * Note: This is a crappy interface. It is here to make 195 - * merging with the existing users of get_empty_filp() 196 - * who have complex failure logic easier. All users 197 - * of this should be moving to alloc_file(). 198 - */ 199 - int init_file(struct file *file, struct vfsmount *mnt, struct dentry *dentry, 200 - fmode_t mode, const struct file_operations *fop) 201 - { 202 - int error = 0; 203 - file->f_path.dentry = dentry; 204 - file->f_path.mnt = mntget(mnt); 205 - file->f_mapping = dentry->d_inode->i_mapping; 176 + file->f_path = *path; 177 + file->f_mapping = path->dentry->d_inode->i_mapping; 206 178 file->f_mode = mode; 207 179 file->f_op = fop; 208 180 ··· 185 211 * visible. We do this for consistency, and so 186 212 * that we can do debugging checks at __fput() 187 213 */ 188 - if ((mode & FMODE_WRITE) && !special_file(dentry->d_inode->i_mode)) { 214 + if ((mode & FMODE_WRITE) && !special_file(path->dentry->d_inode->i_mode)) { 215 + int error = 0; 189 216 file_take_write(file); 190 - error = mnt_clone_write(mnt); 217 + error = mnt_clone_write(path->mnt); 191 218 WARN_ON(error); 192 219 } 193 - return error; 220 + ima_counts_get(file); 221 + return file; 194 222 } 195 - EXPORT_SYMBOL(init_file); 196 223 197 224 void fput(struct file *file) 198 225 {
+89 -69
fs/generic_acl.c
··· 1 1 /* 2 - * fs/generic_acl.c 3 - * 4 2 * (C) 2005 Andreas Gruenbacher <agruen@suse.de> 5 3 * 6 4 * This file is released under the GPL. 5 + * 6 + * Generic ACL support for in-memory filesystems. 7 7 */ 8 8 9 9 #include <linux/sched.h> 10 10 #include <linux/fs.h> 11 11 #include <linux/generic_acl.h> 12 + #include <linux/posix_acl.h> 13 + #include <linux/posix_acl_xattr.h> 12 14 13 - /** 14 - * generic_acl_list - Generic xattr_handler->list() operation 15 - * @ops: Filesystem specific getacl and setacl callbacks 16 - */ 17 - size_t 18 - generic_acl_list(struct inode *inode, struct generic_acl_operations *ops, 19 - int type, char *list, size_t list_size) 15 + 16 + static size_t 17 + generic_acl_list(struct dentry *dentry, char *list, size_t list_size, 18 + const char *name, size_t name_len, int type) 20 19 { 21 20 struct posix_acl *acl; 22 - const char *name; 21 + const char *xname; 23 22 size_t size; 24 23 25 - acl = ops->getacl(inode, type); 24 + acl = get_cached_acl(dentry->d_inode, type); 26 25 if (!acl) 27 26 return 0; 28 27 posix_acl_release(acl); 29 28 30 - switch(type) { 31 - case ACL_TYPE_ACCESS: 32 - name = POSIX_ACL_XATTR_ACCESS; 33 - break; 34 - 35 - case ACL_TYPE_DEFAULT: 36 - name = POSIX_ACL_XATTR_DEFAULT; 37 - break; 38 - 39 - default: 40 - return 0; 29 + switch (type) { 30 + case ACL_TYPE_ACCESS: 31 + xname = POSIX_ACL_XATTR_ACCESS; 32 + break; 33 + case ACL_TYPE_DEFAULT: 34 + xname = POSIX_ACL_XATTR_DEFAULT; 35 + break; 36 + default: 37 + return 0; 41 38 } 42 - size = strlen(name) + 1; 39 + size = strlen(xname) + 1; 43 40 if (list && size <= list_size) 44 - memcpy(list, name, size); 41 + memcpy(list, xname, size); 45 42 return size; 46 43 } 47 44 48 - /** 49 - * generic_acl_get - Generic xattr_handler->get() operation 50 - * @ops: Filesystem specific getacl and setacl callbacks 51 - */ 52 - int 53 - generic_acl_get(struct inode *inode, struct generic_acl_operations *ops, 54 - int type, void *buffer, size_t size) 45 + static int 46 + generic_acl_get(struct dentry *dentry, const char *name, void *buffer, 47 + size_t size, int type) 55 48 { 56 49 struct posix_acl *acl; 57 50 int error; 58 51 59 - acl = ops->getacl(inode, type); 52 + if (strcmp(name, "") != 0) 53 + return -EINVAL; 54 + 55 + acl = get_cached_acl(dentry->d_inode, type); 60 56 if (!acl) 61 57 return -ENODATA; 62 58 error = posix_acl_to_xattr(acl, buffer, size); ··· 61 65 return error; 62 66 } 63 67 64 - /** 65 - * generic_acl_set - Generic xattr_handler->set() operation 66 - * @ops: Filesystem specific getacl and setacl callbacks 67 - */ 68 - int 69 - generic_acl_set(struct inode *inode, struct generic_acl_operations *ops, 70 - int type, const void *value, size_t size) 68 + static int 69 + generic_acl_set(struct dentry *dentry, const char *name, const void *value, 70 + size_t size, int flags, int type) 71 71 { 72 + struct inode *inode = dentry->d_inode; 72 73 struct posix_acl *acl = NULL; 73 74 int error; 74 75 76 + if (strcmp(name, "") != 0) 77 + return -EINVAL; 75 78 if (S_ISLNK(inode->i_mode)) 76 79 return -EOPNOTSUPP; 77 80 if (!is_owner_or_cap(inode)) ··· 86 91 error = posix_acl_valid(acl); 87 92 if (error) 88 93 goto failed; 89 - switch(type) { 90 - case ACL_TYPE_ACCESS: 91 - mode = inode->i_mode; 92 - error = posix_acl_equiv_mode(acl, &mode); 93 - if (error < 0) 94 - goto failed; 95 - inode->i_mode = mode; 96 - if (error == 0) { 97 - posix_acl_release(acl); 98 - acl = NULL; 99 - } 100 - break; 101 - 102 - case ACL_TYPE_DEFAULT: 103 - if (!S_ISDIR(inode->i_mode)) { 104 - error = -EINVAL; 105 - goto failed; 106 - } 107 - break; 94 + switch (type) { 95 + case ACL_TYPE_ACCESS: 96 + mode = inode->i_mode; 97 + error = posix_acl_equiv_mode(acl, &mode); 98 + if (error < 0) 99 + goto failed; 100 + inode->i_mode = mode; 101 + if (error == 0) { 102 + posix_acl_release(acl); 103 + acl = NULL; 104 + } 105 + break; 106 + case ACL_TYPE_DEFAULT: 107 + if (!S_ISDIR(inode->i_mode)) { 108 + error = -EINVAL; 109 + goto failed; 110 + } 111 + break; 108 112 } 109 113 } 110 - ops->setacl(inode, type, acl); 114 + set_cached_acl(inode, type, acl); 111 115 error = 0; 112 116 failed: 113 117 posix_acl_release(acl); ··· 115 121 116 122 /** 117 123 * generic_acl_init - Take care of acl inheritance at @inode create time 118 - * @ops: Filesystem specific getacl and setacl callbacks 119 124 * 120 125 * Files created inside a directory with a default ACL inherit the 121 126 * directory's default ACL. 122 127 */ 123 128 int 124 - generic_acl_init(struct inode *inode, struct inode *dir, 125 - struct generic_acl_operations *ops) 129 + generic_acl_init(struct inode *inode, struct inode *dir) 126 130 { 127 131 struct posix_acl *acl = NULL; 128 132 mode_t mode = inode->i_mode; ··· 128 136 129 137 inode->i_mode = mode & ~current_umask(); 130 138 if (!S_ISLNK(inode->i_mode)) 131 - acl = ops->getacl(dir, ACL_TYPE_DEFAULT); 139 + acl = get_cached_acl(dir, ACL_TYPE_DEFAULT); 132 140 if (acl) { 133 141 struct posix_acl *clone; 134 142 ··· 137 145 error = -ENOMEM; 138 146 if (!clone) 139 147 goto cleanup; 140 - ops->setacl(inode, ACL_TYPE_DEFAULT, clone); 148 + set_cached_acl(inode, ACL_TYPE_DEFAULT, clone); 141 149 posix_acl_release(clone); 142 150 } 143 151 clone = posix_acl_clone(acl, GFP_KERNEL); ··· 148 156 if (error >= 0) { 149 157 inode->i_mode = mode; 150 158 if (error > 0) 151 - ops->setacl(inode, ACL_TYPE_ACCESS, clone); 159 + set_cached_acl(inode, ACL_TYPE_ACCESS, clone); 152 160 } 153 161 posix_acl_release(clone); 154 162 } ··· 161 169 162 170 /** 163 171 * generic_acl_chmod - change the access acl of @inode upon chmod() 164 - * @ops: FIlesystem specific getacl and setacl callbacks 165 172 * 166 173 * A chmod also changes the permissions of the owner, group/mask, and 167 174 * other ACL entries. 168 175 */ 169 176 int 170 - generic_acl_chmod(struct inode *inode, struct generic_acl_operations *ops) 177 + generic_acl_chmod(struct inode *inode) 171 178 { 172 179 struct posix_acl *acl, *clone; 173 180 int error = 0; 174 181 175 182 if (S_ISLNK(inode->i_mode)) 176 183 return -EOPNOTSUPP; 177 - acl = ops->getacl(inode, ACL_TYPE_ACCESS); 184 + acl = get_cached_acl(inode, ACL_TYPE_ACCESS); 178 185 if (acl) { 179 186 clone = posix_acl_clone(acl, GFP_KERNEL); 180 187 posix_acl_release(acl); ··· 181 190 return -ENOMEM; 182 191 error = posix_acl_chmod_masq(clone, inode->i_mode); 183 192 if (!error) 184 - ops->setacl(inode, ACL_TYPE_ACCESS, clone); 193 + set_cached_acl(inode, ACL_TYPE_ACCESS, clone); 185 194 posix_acl_release(clone); 186 195 } 187 196 return error; 188 197 } 198 + 199 + int 200 + generic_check_acl(struct inode *inode, int mask) 201 + { 202 + struct posix_acl *acl = get_cached_acl(inode, ACL_TYPE_ACCESS); 203 + 204 + if (acl) { 205 + int error = posix_acl_permission(inode, acl, mask); 206 + posix_acl_release(acl); 207 + return error; 208 + } 209 + return -EAGAIN; 210 + } 211 + 212 + struct xattr_handler generic_acl_access_handler = { 213 + .prefix = POSIX_ACL_XATTR_ACCESS, 214 + .flags = ACL_TYPE_ACCESS, 215 + .list = generic_acl_list, 216 + .get = generic_acl_get, 217 + .set = generic_acl_set, 218 + }; 219 + 220 + struct xattr_handler generic_acl_default_handler = { 221 + .prefix = POSIX_ACL_XATTR_DEFAULT, 222 + .flags = ACL_TYPE_DEFAULT, 223 + .list = generic_acl_list, 224 + .get = generic_acl_get, 225 + .set = generic_acl_set, 226 + };
+10 -6
fs/gfs2/acl.c
··· 126 126 error = posix_acl_to_xattr(acl, data, len); 127 127 if (error < 0) 128 128 goto out; 129 - error = gfs2_xattr_set(inode, GFS2_EATYPE_SYS, name, data, len, 0); 129 + error = __gfs2_xattr_set(inode, name, data, len, 0, GFS2_EATYPE_SYS); 130 130 if (!error) 131 131 set_cached_acl(inode, type, acl); 132 132 out: ··· 232 232 return -EINVAL; 233 233 } 234 234 235 - static int gfs2_xattr_system_get(struct inode *inode, const char *name, 236 - void *buffer, size_t size) 235 + static int gfs2_xattr_system_get(struct dentry *dentry, const char *name, 236 + void *buffer, size_t size, int xtype) 237 237 { 238 + struct inode *inode = dentry->d_inode; 238 239 struct posix_acl *acl; 239 240 int type; 240 241 int error; ··· 256 255 return error; 257 256 } 258 257 259 - static int gfs2_xattr_system_set(struct inode *inode, const char *name, 260 - const void *value, size_t size, int flags) 258 + static int gfs2_xattr_system_set(struct dentry *dentry, const char *name, 259 + const void *value, size_t size, int flags, 260 + int xtype) 261 261 { 262 + struct inode *inode = dentry->d_inode; 262 263 struct gfs2_sbd *sdp = GFS2_SB(inode); 263 264 struct posix_acl *acl = NULL; 264 265 int error = 0, type; ··· 322 319 } 323 320 324 321 set_acl: 325 - error = gfs2_xattr_set(inode, GFS2_EATYPE_SYS, name, value, size, 0); 322 + error = __gfs2_xattr_set(inode, name, value, size, 0, GFS2_EATYPE_SYS); 326 323 if (!error) { 327 324 if (acl) 328 325 set_cached_acl(inode, type, acl); ··· 337 334 338 335 struct xattr_handler gfs2_xattr_system_handler = { 339 336 .prefix = XATTR_SYSTEM_PREFIX, 337 + .flags = GFS2_EATYPE_SYS, 340 338 .get = gfs2_xattr_system_get, 341 339 .set = gfs2_xattr_system_set, 342 340 };
+2 -1
fs/gfs2/inode.c
··· 801 801 return err; 802 802 } 803 803 804 - err = gfs2_xattr_set(&ip->i_inode, GFS2_EATYPE_SECURITY, name, value, len, 0); 804 + err = __gfs2_xattr_set(&ip->i_inode, name, value, len, 0, 805 + GFS2_EATYPE_SECURITY); 805 806 kfree(value); 806 807 kfree(name); 807 808
+26 -43
fs/gfs2/xattr.c
··· 567 567 /** 568 568 * gfs2_xattr_get - Get a GFS2 extended attribute 569 569 * @inode: The inode 570 - * @type: The type of extended attribute 571 570 * @name: The name of the extended attribute 572 571 * @buffer: The buffer to write the result into 573 572 * @size: The size of the buffer 573 + * @type: The type of extended attribute 574 574 * 575 575 * Returns: actual size of data on success, -errno on error 576 576 */ 577 - 578 - int gfs2_xattr_get(struct inode *inode, int type, const char *name, 579 - void *buffer, size_t size) 577 + static int gfs2_xattr_get(struct dentry *dentry, const char *name, 578 + void *buffer, size_t size, int type) 580 579 { 581 - struct gfs2_inode *ip = GFS2_I(inode); 580 + struct gfs2_inode *ip = GFS2_I(dentry->d_inode); 582 581 struct gfs2_ea_location el; 583 582 int error; 584 583 ··· 1118 1119 1119 1120 /** 1120 1121 * gfs2_xattr_remove - Remove a GFS2 extended attribute 1121 - * @inode: The inode 1122 + * @ip: The inode 1122 1123 * @type: The type of the extended attribute 1123 1124 * @name: The name of the extended attribute 1124 1125 * ··· 1129 1130 * Returns: 0, or errno on failure 1130 1131 */ 1131 1132 1132 - static int gfs2_xattr_remove(struct inode *inode, int type, const char *name) 1133 + static int gfs2_xattr_remove(struct gfs2_inode *ip, int type, const char *name) 1133 1134 { 1134 - struct gfs2_inode *ip = GFS2_I(inode); 1135 1135 struct gfs2_ea_location el; 1136 1136 int error; 1137 1137 ··· 1154 1156 } 1155 1157 1156 1158 /** 1157 - * gfs2_xattr_set - Set (or remove) a GFS2 extended attribute 1158 - * @inode: The inode 1159 - * @type: The type of the extended attribute 1159 + * __gfs2_xattr_set - Set (or remove) a GFS2 extended attribute 1160 + * @ip: The inode 1160 1161 * @name: The name of the extended attribute 1161 1162 * @value: The value of the extended attribute (NULL for remove) 1162 1163 * @size: The size of the @value argument 1163 1164 * @flags: Create or Replace 1165 + * @type: The type of the extended attribute 1164 1166 * 1165 1167 * See gfs2_xattr_remove() for details of the removal of xattrs. 1166 1168 * 1167 1169 * Returns: 0 or errno on failure 1168 1170 */ 1169 1171 1170 - int gfs2_xattr_set(struct inode *inode, int type, const char *name, 1171 - const void *value, size_t size, int flags) 1172 + int __gfs2_xattr_set(struct inode *inode, const char *name, 1173 + const void *value, size_t size, int flags, int type) 1172 1174 { 1173 - struct gfs2_sbd *sdp = GFS2_SB(inode); 1174 1175 struct gfs2_inode *ip = GFS2_I(inode); 1176 + struct gfs2_sbd *sdp = GFS2_SB(inode); 1175 1177 struct gfs2_ea_location el; 1176 1178 unsigned int namel = strlen(name); 1177 1179 int error; ··· 1182 1184 return -ERANGE; 1183 1185 1184 1186 if (value == NULL) 1185 - return gfs2_xattr_remove(inode, type, name); 1187 + return gfs2_xattr_remove(ip, type, name); 1186 1188 1187 1189 if (ea_check_size(sdp, namel, size)) 1188 1190 return -ERANGE; ··· 1220 1222 error = ea_set_i(ip, type, name, value, size, NULL); 1221 1223 1222 1224 return error; 1225 + } 1226 + 1227 + static int gfs2_xattr_set(struct dentry *dentry, const char *name, 1228 + const void *value, size_t size, int flags, int type) 1229 + { 1230 + return __gfs2_xattr_set(dentry->d_inode, name, value, 1231 + size, flags, type); 1223 1232 } 1224 1233 1225 1234 static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip, ··· 1534 1529 return error; 1535 1530 } 1536 1531 1537 - static int gfs2_xattr_user_get(struct inode *inode, const char *name, 1538 - void *buffer, size_t size) 1539 - { 1540 - return gfs2_xattr_get(inode, GFS2_EATYPE_USR, name, buffer, size); 1541 - } 1542 - 1543 - static int gfs2_xattr_user_set(struct inode *inode, const char *name, 1544 - const void *value, size_t size, int flags) 1545 - { 1546 - return gfs2_xattr_set(inode, GFS2_EATYPE_USR, name, value, size, flags); 1547 - } 1548 - 1549 - static int gfs2_xattr_security_get(struct inode *inode, const char *name, 1550 - void *buffer, size_t size) 1551 - { 1552 - return gfs2_xattr_get(inode, GFS2_EATYPE_SECURITY, name, buffer, size); 1553 - } 1554 - 1555 - static int gfs2_xattr_security_set(struct inode *inode, const char *name, 1556 - const void *value, size_t size, int flags) 1557 - { 1558 - return gfs2_xattr_set(inode, GFS2_EATYPE_SECURITY, name, value, size, flags); 1559 - } 1560 - 1561 1532 static struct xattr_handler gfs2_xattr_user_handler = { 1562 1533 .prefix = XATTR_USER_PREFIX, 1563 - .get = gfs2_xattr_user_get, 1564 - .set = gfs2_xattr_user_set, 1534 + .flags = GFS2_EATYPE_USR, 1535 + .get = gfs2_xattr_get, 1536 + .set = gfs2_xattr_set, 1565 1537 }; 1566 1538 1567 1539 static struct xattr_handler gfs2_xattr_security_handler = { 1568 1540 .prefix = XATTR_SECURITY_PREFIX, 1569 - .get = gfs2_xattr_security_get, 1570 - .set = gfs2_xattr_security_set, 1541 + .flags = GFS2_EATYPE_SECURITY, 1542 + .get = gfs2_xattr_get, 1543 + .set = gfs2_xattr_set, 1571 1544 }; 1572 1545 1573 1546 struct xattr_handler *gfs2_xattr_handlers[] = {
+3 -4
fs/gfs2/xattr.h
··· 53 53 struct gfs2_ea_header *el_prev; 54 54 }; 55 55 56 - extern int gfs2_xattr_get(struct inode *inode, int type, const char *name, 57 - void *buffer, size_t size); 58 - extern int gfs2_xattr_set(struct inode *inode, int type, const char *name, 59 - const void *value, size_t size, int flags); 56 + extern int __gfs2_xattr_set(struct inode *inode, const char *name, 57 + const void *value, size_t size, 58 + int flags, int type); 60 59 extern ssize_t gfs2_listxattr(struct dentry *dentry, char *buffer, size_t size); 61 60 extern int gfs2_ea_dealloc(struct gfs2_inode *ip); 62 61
+8 -9
fs/hugetlbfs/inode.c
··· 30 30 #include <linux/dnotify.h> 31 31 #include <linux/statfs.h> 32 32 #include <linux/security.h> 33 - #include <linux/ima.h> 34 33 #include <linux/magic.h> 35 34 36 35 #include <asm/uaccess.h> ··· 921 922 int error = -ENOMEM; 922 923 struct file *file; 923 924 struct inode *inode; 924 - struct dentry *dentry, *root; 925 + struct path path; 926 + struct dentry *root; 925 927 struct qstr quick_string; 926 928 927 929 *user = NULL; ··· 944 944 quick_string.name = name; 945 945 quick_string.len = strlen(quick_string.name); 946 946 quick_string.hash = 0; 947 - dentry = d_alloc(root, &quick_string); 948 - if (!dentry) 947 + path.dentry = d_alloc(root, &quick_string); 948 + if (!path.dentry) 949 949 goto out_shm_unlock; 950 950 951 + path.mnt = mntget(hugetlbfs_vfsmount); 951 952 error = -ENOSPC; 952 953 inode = hugetlbfs_get_inode(root->d_sb, current_fsuid(), 953 954 current_fsgid(), S_IFREG | S_IRWXUGO, 0); ··· 961 960 acctflag)) 962 961 goto out_inode; 963 962 964 - d_instantiate(dentry, inode); 963 + d_instantiate(path.dentry, inode); 965 964 inode->i_size = size; 966 965 inode->i_nlink = 0; 967 966 968 967 error = -ENFILE; 969 - file = alloc_file(hugetlbfs_vfsmount, dentry, 970 - FMODE_WRITE | FMODE_READ, 968 + file = alloc_file(&path, FMODE_WRITE | FMODE_READ, 971 969 &hugetlbfs_file_operations); 972 970 if (!file) 973 971 goto out_dentry; /* inode is already attached */ 974 - ima_counts_get(file); 975 972 976 973 return file; 977 974 978 975 out_inode: 979 976 iput(inode); 980 977 out_dentry: 981 - dput(dentry); 978 + path_put(&path); 982 979 out_shm_unlock: 983 980 if (*user) { 984 981 user_shm_unlock(size, *user);
+1
fs/internal.h
··· 79 79 * file_table.c 80 80 */ 81 81 extern void mark_files_ro(struct super_block *); 82 + extern struct file *get_empty_filp(void); 82 83 83 84 /* 84 85 * super.c
+22 -43
fs/jffs2/acl.c
··· 350 350 return rc; 351 351 } 352 352 353 - static size_t jffs2_acl_access_listxattr(struct inode *inode, char *list, size_t list_size, 354 - const char *name, size_t name_len) 353 + static size_t jffs2_acl_access_listxattr(struct dentry *dentry, char *list, 354 + size_t list_size, const char *name, size_t name_len, int type) 355 355 { 356 356 const int retlen = sizeof(POSIX_ACL_XATTR_ACCESS); 357 357 ··· 360 360 return retlen; 361 361 } 362 362 363 - static size_t jffs2_acl_default_listxattr(struct inode *inode, char *list, size_t list_size, 364 - const char *name, size_t name_len) 363 + static size_t jffs2_acl_default_listxattr(struct dentry *dentry, char *list, 364 + size_t list_size, const char *name, size_t name_len, int type) 365 365 { 366 366 const int retlen = sizeof(POSIX_ACL_XATTR_DEFAULT); 367 367 ··· 370 370 return retlen; 371 371 } 372 372 373 - static int jffs2_acl_getxattr(struct inode *inode, int type, void *buffer, size_t size) 373 + static int jffs2_acl_getxattr(struct dentry *dentry, const char *name, 374 + void *buffer, size_t size, int type) 374 375 { 375 376 struct posix_acl *acl; 376 377 int rc; 377 378 378 - acl = jffs2_get_acl(inode, type); 379 + if (name[0] != '\0') 380 + return -EINVAL; 381 + 382 + acl = jffs2_get_acl(dentry->d_inode, type); 379 383 if (IS_ERR(acl)) 380 384 return PTR_ERR(acl); 381 385 if (!acl) ··· 390 386 return rc; 391 387 } 392 388 393 - static int jffs2_acl_access_getxattr(struct inode *inode, const char *name, void *buffer, size_t size) 394 - { 395 - if (name[0] != '\0') 396 - return -EINVAL; 397 - return jffs2_acl_getxattr(inode, ACL_TYPE_ACCESS, buffer, size); 398 - } 399 - 400 - static int jffs2_acl_default_getxattr(struct inode *inode, const char *name, void *buffer, size_t size) 401 - { 402 - if (name[0] != '\0') 403 - return -EINVAL; 404 - return jffs2_acl_getxattr(inode, ACL_TYPE_DEFAULT, buffer, size); 405 - } 406 - 407 - static int jffs2_acl_setxattr(struct inode *inode, int type, const void *value, size_t size) 389 + static int jffs2_acl_setxattr(struct dentry *dentry, const char *name, 390 + const void *value, size_t size, int flags, int type) 408 391 { 409 392 struct posix_acl *acl; 410 393 int rc; 411 394 412 - if (!is_owner_or_cap(inode)) 395 + if (name[0] != '\0') 396 + return -EINVAL; 397 + if (!is_owner_or_cap(dentry->d_inode)) 413 398 return -EPERM; 414 399 415 400 if (value) { ··· 413 420 } else { 414 421 acl = NULL; 415 422 } 416 - rc = jffs2_set_acl(inode, type, acl); 423 + rc = jffs2_set_acl(dentry->d_inode, type, acl); 417 424 out: 418 425 posix_acl_release(acl); 419 426 return rc; 420 427 } 421 428 422 - static int jffs2_acl_access_setxattr(struct inode *inode, const char *name, 423 - const void *buffer, size_t size, int flags) 424 - { 425 - if (name[0] != '\0') 426 - return -EINVAL; 427 - return jffs2_acl_setxattr(inode, ACL_TYPE_ACCESS, buffer, size); 428 - } 429 - 430 - static int jffs2_acl_default_setxattr(struct inode *inode, const char *name, 431 - const void *buffer, size_t size, int flags) 432 - { 433 - if (name[0] != '\0') 434 - return -EINVAL; 435 - return jffs2_acl_setxattr(inode, ACL_TYPE_DEFAULT, buffer, size); 436 - } 437 - 438 429 struct xattr_handler jffs2_acl_access_xattr_handler = { 439 430 .prefix = POSIX_ACL_XATTR_ACCESS, 431 + .flags = ACL_TYPE_DEFAULT, 440 432 .list = jffs2_acl_access_listxattr, 441 - .get = jffs2_acl_access_getxattr, 442 - .set = jffs2_acl_access_setxattr, 433 + .get = jffs2_acl_getxattr, 434 + .set = jffs2_acl_setxattr, 443 435 }; 444 436 445 437 struct xattr_handler jffs2_acl_default_xattr_handler = { 446 438 .prefix = POSIX_ACL_XATTR_DEFAULT, 439 + .flags = ACL_TYPE_DEFAULT, 447 440 .list = jffs2_acl_default_listxattr, 448 - .get = jffs2_acl_default_getxattr, 449 - .set = jffs2_acl_default_setxattr, 441 + .get = jffs2_acl_getxattr, 442 + .set = jffs2_acl_setxattr, 450 443 };
+10 -8
fs/jffs2/security.c
··· 44 44 } 45 45 46 46 /* ---- XATTR Handler for "security.*" ----------------- */ 47 - static int jffs2_security_getxattr(struct inode *inode, const char *name, 48 - void *buffer, size_t size) 47 + static int jffs2_security_getxattr(struct dentry *dentry, const char *name, 48 + void *buffer, size_t size, int type) 49 49 { 50 50 if (!strcmp(name, "")) 51 51 return -EINVAL; 52 52 53 - return do_jffs2_getxattr(inode, JFFS2_XPREFIX_SECURITY, name, buffer, size); 53 + return do_jffs2_getxattr(dentry->d_inode, JFFS2_XPREFIX_SECURITY, 54 + name, buffer, size); 54 55 } 55 56 56 - static int jffs2_security_setxattr(struct inode *inode, const char *name, const void *buffer, 57 - size_t size, int flags) 57 + static int jffs2_security_setxattr(struct dentry *dentry, const char *name, 58 + const void *buffer, size_t size, int flags, int type) 58 59 { 59 60 if (!strcmp(name, "")) 60 61 return -EINVAL; 61 62 62 - return do_jffs2_setxattr(inode, JFFS2_XPREFIX_SECURITY, name, buffer, size, flags); 63 + return do_jffs2_setxattr(dentry->d_inode, JFFS2_XPREFIX_SECURITY, 64 + name, buffer, size, flags); 63 65 } 64 66 65 - static size_t jffs2_security_listxattr(struct inode *inode, char *list, size_t list_size, 66 - const char *name, size_t name_len) 67 + static size_t jffs2_security_listxattr(struct dentry *dentry, char *list, 68 + size_t list_size, const char *name, size_t name_len, int type) 67 69 { 68 70 size_t retlen = XATTR_SECURITY_PREFIX_LEN + name_len + 1; 69 71
+4 -2
fs/jffs2/xattr.c
··· 990 990 if (!xhandle) 991 991 continue; 992 992 if (buffer) { 993 - rc = xhandle->list(inode, buffer+len, size-len, xd->xname, xd->name_len); 993 + rc = xhandle->list(dentry, buffer+len, size-len, 994 + xd->xname, xd->name_len, xd->flags); 994 995 } else { 995 - rc = xhandle->list(inode, NULL, 0, xd->xname, xd->name_len); 996 + rc = xhandle->list(dentry, NULL, 0, xd->xname, 997 + xd->name_len, xd->flags); 996 998 } 997 999 if (rc < 0) 998 1000 goto out;
+10 -8
fs/jffs2/xattr_trusted.c
··· 16 16 #include <linux/mtd/mtd.h> 17 17 #include "nodelist.h" 18 18 19 - static int jffs2_trusted_getxattr(struct inode *inode, const char *name, 20 - void *buffer, size_t size) 19 + static int jffs2_trusted_getxattr(struct dentry *dentry, const char *name, 20 + void *buffer, size_t size, int type) 21 21 { 22 22 if (!strcmp(name, "")) 23 23 return -EINVAL; 24 - return do_jffs2_getxattr(inode, JFFS2_XPREFIX_TRUSTED, name, buffer, size); 24 + return do_jffs2_getxattr(dentry->d_inode, JFFS2_XPREFIX_TRUSTED, 25 + name, buffer, size); 25 26 } 26 27 27 - static int jffs2_trusted_setxattr(struct inode *inode, const char *name, const void *buffer, 28 - size_t size, int flags) 28 + static int jffs2_trusted_setxattr(struct dentry *dentry, const char *name, 29 + const void *buffer, size_t size, int flags, int type) 29 30 { 30 31 if (!strcmp(name, "")) 31 32 return -EINVAL; 32 - return do_jffs2_setxattr(inode, JFFS2_XPREFIX_TRUSTED, name, buffer, size, flags); 33 + return do_jffs2_setxattr(dentry->d_inode, JFFS2_XPREFIX_TRUSTED, 34 + name, buffer, size, flags); 33 35 } 34 36 35 - static size_t jffs2_trusted_listxattr(struct inode *inode, char *list, size_t list_size, 36 - const char *name, size_t name_len) 37 + static size_t jffs2_trusted_listxattr(struct dentry *dentry, char *list, 38 + size_t list_size, const char *name, size_t name_len, int type) 37 39 { 38 40 size_t retlen = XATTR_TRUSTED_PREFIX_LEN + name_len + 1; 39 41
+10 -8
fs/jffs2/xattr_user.c
··· 16 16 #include <linux/mtd/mtd.h> 17 17 #include "nodelist.h" 18 18 19 - static int jffs2_user_getxattr(struct inode *inode, const char *name, 20 - void *buffer, size_t size) 19 + static int jffs2_user_getxattr(struct dentry *dentry, const char *name, 20 + void *buffer, size_t size, int type) 21 21 { 22 22 if (!strcmp(name, "")) 23 23 return -EINVAL; 24 - return do_jffs2_getxattr(inode, JFFS2_XPREFIX_USER, name, buffer, size); 24 + return do_jffs2_getxattr(dentry->d_inode, JFFS2_XPREFIX_USER, 25 + name, buffer, size); 25 26 } 26 27 27 - static int jffs2_user_setxattr(struct inode *inode, const char *name, const void *buffer, 28 - size_t size, int flags) 28 + static int jffs2_user_setxattr(struct dentry *dentry, const char *name, 29 + const void *buffer, size_t size, int flags, int type) 29 30 { 30 31 if (!strcmp(name, "")) 31 32 return -EINVAL; 32 - return do_jffs2_setxattr(inode, JFFS2_XPREFIX_USER, name, buffer, size, flags); 33 + return do_jffs2_setxattr(dentry->d_inode, JFFS2_XPREFIX_USER, 34 + name, buffer, size, flags); 33 35 } 34 36 35 - static size_t jffs2_user_listxattr(struct inode *inode, char *list, size_t list_size, 36 - const char *name, size_t name_len) 37 + static size_t jffs2_user_listxattr(struct dentry *dentry, char *list, 38 + size_t list_size, const char *name, size_t name_len, int type) 37 39 { 38 40 size_t retlen = XATTR_USER_PREFIX_LEN + name_len + 1; 39 41
-1
fs/libfs.c
··· 848 848 EXPORT_SYMBOL(simple_dir_inode_operations); 849 849 EXPORT_SYMBOL(simple_dir_operations); 850 850 EXPORT_SYMBOL(simple_empty); 851 - EXPORT_SYMBOL(d_alloc_name); 852 851 EXPORT_SYMBOL(simple_fill_super); 853 852 EXPORT_SYMBOL(simple_getattr); 854 853 EXPORT_SYMBOL(simple_link);
+233 -233
fs/namei.c
··· 35 35 #include <linux/fs_struct.h> 36 36 #include <asm/uaccess.h> 37 37 38 + #include "internal.h" 39 + 38 40 #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) 39 41 40 42 /* [Feb-1997 T. Schoebel-Theuer] ··· 109 107 * implemented. Let's see if raised priority of ->s_vfs_rename_mutex gives 110 108 * any extra contention... 111 109 */ 112 - 113 - static int __link_path_walk(const char *name, struct nameidata *nd); 114 110 115 111 /* In order to reduce some races, while at the same time doing additional 116 112 * checking and hopefully speeding things up, we copy filenames to the ··· 414 414 } 415 415 416 416 /* 417 - * Internal lookup() using the new generic dcache. 418 - * SMP-safe 417 + * force_reval_path - force revalidation of a dentry 418 + * 419 + * In some situations the path walking code will trust dentries without 420 + * revalidating them. This causes problems for filesystems that depend on 421 + * d_revalidate to handle file opens (e.g. NFSv4). When FS_REVAL_DOT is set 422 + * (which indicates that it's possible for the dentry to go stale), force 423 + * a d_revalidate call before proceeding. 424 + * 425 + * Returns 0 if the revalidation was successful. If the revalidation fails, 426 + * either return the error returned by d_revalidate or -ESTALE if the 427 + * revalidation it just returned 0. If d_revalidate returns 0, we attempt to 428 + * invalidate the dentry. It's up to the caller to handle putting references 429 + * to the path if necessary. 419 430 */ 420 - static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, struct nameidata *nd) 431 + static int 432 + force_reval_path(struct path *path, struct nameidata *nd) 421 433 { 422 - struct dentry * dentry = __d_lookup(parent, name); 434 + int status; 435 + struct dentry *dentry = path->dentry; 423 436 424 - /* lockess __d_lookup may fail due to concurrent d_move() 425 - * in some unrelated directory, so try with d_lookup 437 + /* 438 + * only check on filesystems where it's possible for the dentry to 439 + * become stale. It's assumed that if this flag is set then the 440 + * d_revalidate op will also be defined. 426 441 */ 427 - if (!dentry) 428 - dentry = d_lookup(parent, name); 442 + if (!(dentry->d_sb->s_type->fs_flags & FS_REVAL_DOT)) 443 + return 0; 429 444 430 - if (dentry && dentry->d_op && dentry->d_op->d_revalidate) 431 - dentry = do_revalidate(dentry, nd); 445 + status = dentry->d_op->d_revalidate(dentry, nd); 446 + if (status > 0) 447 + return 0; 432 448 433 - return dentry; 449 + if (!status) { 450 + d_invalidate(dentry); 451 + status = -ESTALE; 452 + } 453 + return status; 434 454 } 435 455 436 456 /* 437 - * Short-cut version of permission(), for calling by 438 - * path_walk(), when dcache lock is held. Combines parts 439 - * of permission() and generic_permission(), and tests ONLY for 440 - * MAY_EXEC permission. 457 + * Short-cut version of permission(), for calling on directories 458 + * during pathname resolution. Combines parts of permission() 459 + * and generic_permission(), and tests ONLY for MAY_EXEC permission. 441 460 * 442 461 * If appropriate, check DAC only. If not appropriate, or 443 - * short-cut DAC fails, then call permission() to do more 462 + * short-cut DAC fails, then call ->permission() to do more 444 463 * complete permission check. 445 464 */ 446 - static int exec_permission_lite(struct inode *inode) 465 + static int exec_permission(struct inode *inode) 447 466 { 448 467 int ret; 449 468 ··· 484 465 return security_inode_permission(inode, MAY_EXEC); 485 466 } 486 467 487 - /* 488 - * This is called when everything else fails, and we actually have 489 - * to go to the low-level filesystem to find out what we should do.. 490 - * 491 - * We get the directory semaphore, and after getting that we also 492 - * make sure that nobody added the entry to the dcache in the meantime.. 493 - * SMP-safe 494 - */ 495 - static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, struct nameidata *nd) 496 - { 497 - struct dentry * result; 498 - struct inode *dir = parent->d_inode; 499 - 500 - mutex_lock(&dir->i_mutex); 501 - /* 502 - * First re-do the cached lookup just in case it was created 503 - * while we waited for the directory semaphore.. 504 - * 505 - * FIXME! This could use version numbering or similar to 506 - * avoid unnecessary cache lookups. 507 - * 508 - * The "dcache_lock" is purely to protect the RCU list walker 509 - * from concurrent renames at this point (we mustn't get false 510 - * negatives from the RCU list walk here, unlike the optimistic 511 - * fast walk). 512 - * 513 - * so doing d_lookup() (with seqlock), instead of lockfree __d_lookup 514 - */ 515 - result = d_lookup(parent, name); 516 - if (!result) { 517 - struct dentry *dentry; 518 - 519 - /* Don't create child dentry for a dead directory. */ 520 - result = ERR_PTR(-ENOENT); 521 - if (IS_DEADDIR(dir)) 522 - goto out_unlock; 523 - 524 - dentry = d_alloc(parent, name); 525 - result = ERR_PTR(-ENOMEM); 526 - if (dentry) { 527 - result = dir->i_op->lookup(dir, dentry, nd); 528 - if (result) 529 - dput(dentry); 530 - else 531 - result = dentry; 532 - } 533 - out_unlock: 534 - mutex_unlock(&dir->i_mutex); 535 - return result; 536 - } 537 - 538 - /* 539 - * Uhhuh! Nasty case: the cache was re-populated while 540 - * we waited on the semaphore. Need to revalidate. 541 - */ 542 - mutex_unlock(&dir->i_mutex); 543 - if (result->d_op && result->d_op->d_revalidate) { 544 - result = do_revalidate(result, nd); 545 - if (!result) 546 - result = ERR_PTR(-ENOENT); 547 - } 548 - return result; 549 - } 550 - 551 - /* 552 - * Wrapper to retry pathname resolution whenever the underlying 553 - * file system returns an ESTALE. 554 - * 555 - * Retry the whole path once, forcing real lookup requests 556 - * instead of relying on the dcache. 557 - */ 558 - static __always_inline int link_path_walk(const char *name, struct nameidata *nd) 559 - { 560 - struct path save = nd->path; 561 - int result; 562 - 563 - /* make sure the stuff we saved doesn't go away */ 564 - path_get(&save); 565 - 566 - result = __link_path_walk(name, nd); 567 - if (result == -ESTALE) { 568 - /* nd->path had been dropped */ 569 - nd->path = save; 570 - path_get(&nd->path); 571 - nd->flags |= LOOKUP_REVAL; 572 - result = __link_path_walk(name, nd); 573 - } 574 - 575 - path_put(&save); 576 - 577 - return result; 578 - } 579 - 580 468 static __always_inline void set_root(struct nameidata *nd) 581 469 { 582 470 if (!nd->root.mnt) { ··· 494 568 read_unlock(&fs->lock); 495 569 } 496 570 } 571 + 572 + static int link_path_walk(const char *, struct nameidata *); 497 573 498 574 static __always_inline int __vfs_follow_link(struct nameidata *nd, const char *link) 499 575 { ··· 569 641 error = 0; 570 642 if (s) 571 643 error = __vfs_follow_link(nd, s); 644 + else if (nd->last_type == LAST_BIND) { 645 + error = force_reval_path(&nd->path, nd); 646 + if (error) 647 + path_put(&nd->path); 648 + } 572 649 if (dentry->d_inode->i_op->put_link) 573 650 dentry->d_inode->i_op->put_link(dentry, nd, cookie); 574 651 } 575 - path_put(path); 576 - 577 652 return error; 578 653 } 579 654 ··· 603 672 current->total_link_count++; 604 673 nd->depth++; 605 674 err = __do_follow_link(path, nd); 675 + path_put(path); 606 676 current->link_count--; 607 677 nd->depth--; 608 678 return err; ··· 729 797 struct path *path) 730 798 { 731 799 struct vfsmount *mnt = nd->path.mnt; 732 - struct dentry *dentry = __d_lookup(nd->path.dentry, name); 800 + struct dentry *dentry, *parent; 801 + struct inode *dir; 802 + /* 803 + * See if the low-level filesystem might want 804 + * to use its own hash.. 805 + */ 806 + if (nd->path.dentry->d_op && nd->path.dentry->d_op->d_hash) { 807 + int err = nd->path.dentry->d_op->d_hash(nd->path.dentry, name); 808 + if (err < 0) 809 + return err; 810 + } 733 811 812 + dentry = __d_lookup(nd->path.dentry, name); 734 813 if (!dentry) 735 814 goto need_lookup; 736 815 if (dentry->d_op && dentry->d_op->d_revalidate) ··· 753 810 return 0; 754 811 755 812 need_lookup: 756 - dentry = real_lookup(nd->path.dentry, name, nd); 813 + parent = nd->path.dentry; 814 + dir = parent->d_inode; 815 + 816 + mutex_lock(&dir->i_mutex); 817 + /* 818 + * First re-do the cached lookup just in case it was created 819 + * while we waited for the directory semaphore.. 820 + * 821 + * FIXME! This could use version numbering or similar to 822 + * avoid unnecessary cache lookups. 823 + * 824 + * The "dcache_lock" is purely to protect the RCU list walker 825 + * from concurrent renames at this point (we mustn't get false 826 + * negatives from the RCU list walk here, unlike the optimistic 827 + * fast walk). 828 + * 829 + * so doing d_lookup() (with seqlock), instead of lockfree __d_lookup 830 + */ 831 + dentry = d_lookup(parent, name); 832 + if (!dentry) { 833 + struct dentry *new; 834 + 835 + /* Don't create child dentry for a dead directory. */ 836 + dentry = ERR_PTR(-ENOENT); 837 + if (IS_DEADDIR(dir)) 838 + goto out_unlock; 839 + 840 + new = d_alloc(parent, name); 841 + dentry = ERR_PTR(-ENOMEM); 842 + if (new) { 843 + dentry = dir->i_op->lookup(dir, new, nd); 844 + if (dentry) 845 + dput(new); 846 + else 847 + dentry = new; 848 + } 849 + out_unlock: 850 + mutex_unlock(&dir->i_mutex); 851 + if (IS_ERR(dentry)) 852 + goto fail; 853 + goto done; 854 + } 855 + 856 + /* 857 + * Uhhuh! Nasty case: the cache was re-populated while 858 + * we waited on the semaphore. Need to revalidate. 859 + */ 860 + mutex_unlock(&dir->i_mutex); 861 + if (dentry->d_op && dentry->d_op->d_revalidate) { 862 + dentry = do_revalidate(dentry, nd); 863 + if (!dentry) 864 + dentry = ERR_PTR(-ENOENT); 865 + } 757 866 if (IS_ERR(dentry)) 758 867 goto fail; 759 868 goto done; ··· 830 835 * Returns 0 and nd will have valid dentry and mnt on success. 831 836 * Returns error and drops reference to input namei data on failure. 832 837 */ 833 - static int __link_path_walk(const char *name, struct nameidata *nd) 838 + static int link_path_walk(const char *name, struct nameidata *nd) 834 839 { 835 840 struct path next; 836 841 struct inode *inode; ··· 853 858 unsigned int c; 854 859 855 860 nd->flags |= LOOKUP_CONTINUE; 856 - err = exec_permission_lite(inode); 861 + err = exec_permission(inode); 857 862 if (err) 858 863 break; 859 864 ··· 892 897 /* fallthrough */ 893 898 case 1: 894 899 continue; 895 - } 896 - /* 897 - * See if the low-level filesystem might want 898 - * to use its own hash.. 899 - */ 900 - if (nd->path.dentry->d_op && nd->path.dentry->d_op->d_hash) { 901 - err = nd->path.dentry->d_op->d_hash(nd->path.dentry, 902 - &this); 903 - if (err < 0) 904 - break; 905 900 } 906 901 /* This does the actual lookups.. */ 907 902 err = do_lookup(nd, &this, &next); ··· 937 952 /* fallthrough */ 938 953 case 1: 939 954 goto return_reval; 940 - } 941 - if (nd->path.dentry->d_op && nd->path.dentry->d_op->d_hash) { 942 - err = nd->path.dentry->d_op->d_hash(nd->path.dentry, 943 - &this); 944 - if (err < 0) 945 - break; 946 955 } 947 956 err = do_lookup(nd, &this, &next); 948 957 if (err) ··· 996 1017 997 1018 static int path_walk(const char *name, struct nameidata *nd) 998 1019 { 1020 + struct path save = nd->path; 1021 + int result; 1022 + 999 1023 current->total_link_count = 0; 1000 - return link_path_walk(name, nd); 1024 + 1025 + /* make sure the stuff we saved doesn't go away */ 1026 + path_get(&save); 1027 + 1028 + result = link_path_walk(name, nd); 1029 + if (result == -ESTALE) { 1030 + /* nd->path had been dropped */ 1031 + current->total_link_count = 0; 1032 + nd->path = save; 1033 + path_get(&nd->path); 1034 + nd->flags |= LOOKUP_REVAL; 1035 + result = link_path_walk(name, nd); 1036 + } 1037 + 1038 + path_put(&save); 1039 + 1040 + return result; 1001 1041 } 1002 1042 1003 1043 static int path_init(int dfd, const char *name, unsigned int flags, struct nameidata *nd) ··· 1139 1141 return retval; 1140 1142 } 1141 1143 1142 - /** 1143 - * path_lookup_open - lookup a file path with open intent 1144 - * @dfd: the directory to use as base, or AT_FDCWD 1145 - * @name: pointer to file name 1146 - * @lookup_flags: lookup intent flags 1147 - * @nd: pointer to nameidata 1148 - * @open_flags: open intent flags 1149 - */ 1150 - static int path_lookup_open(int dfd, const char *name, 1151 - unsigned int lookup_flags, struct nameidata *nd, int open_flags) 1152 - { 1153 - struct file *filp = get_empty_filp(); 1154 - int err; 1155 - 1156 - if (filp == NULL) 1157 - return -ENFILE; 1158 - nd->intent.open.file = filp; 1159 - nd->intent.open.flags = open_flags; 1160 - nd->intent.open.create_mode = 0; 1161 - err = do_path_lookup(dfd, name, lookup_flags|LOOKUP_OPEN, nd); 1162 - if (IS_ERR(nd->intent.open.file)) { 1163 - if (err == 0) { 1164 - err = PTR_ERR(nd->intent.open.file); 1165 - path_put(&nd->path); 1166 - } 1167 - } else if (err != 0) 1168 - release_open_intent(nd); 1169 - return err; 1170 - } 1171 - 1172 1144 static struct dentry *__lookup_hash(struct qstr *name, 1173 1145 struct dentry *base, struct nameidata *nd) 1174 1146 { ··· 1159 1191 goto out; 1160 1192 } 1161 1193 1162 - dentry = cached_lookup(base, name, nd); 1194 + dentry = __d_lookup(base, name); 1195 + 1196 + /* lockess __d_lookup may fail due to concurrent d_move() 1197 + * in some unrelated directory, so try with d_lookup 1198 + */ 1199 + if (!dentry) 1200 + dentry = d_lookup(base, name); 1201 + 1202 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate) 1203 + dentry = do_revalidate(dentry, nd); 1204 + 1163 1205 if (!dentry) { 1164 1206 struct dentry *new; 1165 1207 ··· 1201 1223 { 1202 1224 int err; 1203 1225 1204 - err = inode_permission(nd->path.dentry->d_inode, MAY_EXEC); 1226 + err = exec_permission(nd->path.dentry->d_inode); 1205 1227 if (err) 1206 1228 return ERR_PTR(err); 1207 1229 return __lookup_hash(&nd->last, nd->path.dentry, nd); ··· 1251 1273 if (err) 1252 1274 return ERR_PTR(err); 1253 1275 1254 - err = inode_permission(base->d_inode, MAY_EXEC); 1276 + err = exec_permission(base->d_inode); 1255 1277 if (err) 1256 1278 return ERR_PTR(err); 1257 1279 return __lookup_hash(&this, base, NULL); ··· 1489 1511 if (error) 1490 1512 return error; 1491 1513 1492 - error = ima_path_check(path, acc_mode ? 1493 - acc_mode & (MAY_READ | MAY_WRITE | MAY_EXEC) : 1494 - ACC_MODE(flag) & (MAY_READ | MAY_WRITE), 1495 - IMA_COUNT_UPDATE); 1496 - 1497 - if (error) 1498 - return error; 1499 1514 /* 1500 1515 * An append-only file must be opened in append mode for writing. 1501 1516 */ 1502 1517 if (IS_APPEND(inode)) { 1503 - error = -EPERM; 1504 1518 if ((flag & FMODE_WRITE) && !(flag & O_APPEND)) 1505 - goto err_out; 1519 + return -EPERM; 1506 1520 if (flag & O_TRUNC) 1507 - goto err_out; 1521 + return -EPERM; 1508 1522 } 1509 1523 1510 1524 /* O_NOATIME can only be set by the owner or superuser */ 1511 - if (flag & O_NOATIME) 1512 - if (!is_owner_or_cap(inode)) { 1513 - error = -EPERM; 1514 - goto err_out; 1515 - } 1525 + if (flag & O_NOATIME && !is_owner_or_cap(inode)) 1526 + return -EPERM; 1516 1527 1517 1528 /* 1518 1529 * Ensure there are no outstanding leases on the file. 1519 1530 */ 1520 - error = break_lease(inode, flag); 1531 + return break_lease(inode, flag); 1532 + } 1533 + 1534 + static int handle_truncate(struct path *path) 1535 + { 1536 + struct inode *inode = path->dentry->d_inode; 1537 + int error = get_write_access(inode); 1521 1538 if (error) 1522 - goto err_out; 1523 - 1524 - if (flag & O_TRUNC) { 1525 - error = get_write_access(inode); 1526 - if (error) 1527 - goto err_out; 1528 - 1529 - /* 1530 - * Refuse to truncate files with mandatory locks held on them. 1531 - */ 1532 - error = locks_verify_locked(inode); 1533 - if (!error) 1534 - error = security_path_truncate(path, 0, 1535 - ATTR_MTIME|ATTR_CTIME|ATTR_OPEN); 1536 - if (!error) { 1537 - vfs_dq_init(inode); 1538 - 1539 - error = do_truncate(dentry, 0, 1540 - ATTR_MTIME|ATTR_CTIME|ATTR_OPEN, 1541 - NULL); 1542 - } 1543 - put_write_access(inode); 1544 - if (error) 1545 - goto err_out; 1546 - } else 1547 - if (flag & FMODE_WRITE) 1548 - vfs_dq_init(inode); 1549 - 1550 - return 0; 1551 - err_out: 1552 - ima_counts_put(path, acc_mode ? 1553 - acc_mode & (MAY_READ | MAY_WRITE | MAY_EXEC) : 1554 - ACC_MODE(flag) & (MAY_READ | MAY_WRITE)); 1539 + return error; 1540 + /* 1541 + * Refuse to truncate files with mandatory locks held on them. 1542 + */ 1543 + error = locks_verify_locked(inode); 1544 + if (!error) 1545 + error = security_path_truncate(path, 0, 1546 + ATTR_MTIME|ATTR_CTIME|ATTR_OPEN); 1547 + if (!error) { 1548 + error = do_truncate(path->dentry, 0, 1549 + ATTR_MTIME|ATTR_CTIME|ATTR_OPEN, 1550 + NULL); 1551 + } 1552 + put_write_access(inode); 1555 1553 return error; 1556 1554 } 1557 1555 ··· 1582 1628 return flag; 1583 1629 } 1584 1630 1585 - static int open_will_write_to_fs(int flag, struct inode *inode) 1631 + static int open_will_truncate(int flag, struct inode *inode) 1586 1632 { 1587 1633 /* 1588 1634 * We'll never write to the fs underlying ··· 1604 1650 struct file *filp; 1605 1651 struct nameidata nd; 1606 1652 int error; 1607 - struct path path; 1653 + struct path path, save; 1608 1654 struct dentry *dir; 1609 1655 int count = 0; 1610 - int will_write; 1656 + int will_truncate; 1611 1657 int flag = open_to_namei_flags(open_flag); 1612 1658 1613 1659 /* ··· 1635 1681 * The simplest case - just a plain lookup. 1636 1682 */ 1637 1683 if (!(flag & O_CREAT)) { 1638 - error = path_lookup_open(dfd, pathname, lookup_flags(flag), 1639 - &nd, flag); 1684 + filp = get_empty_filp(); 1685 + 1686 + if (filp == NULL) 1687 + return ERR_PTR(-ENFILE); 1688 + nd.intent.open.file = filp; 1689 + nd.intent.open.flags = flag; 1690 + nd.intent.open.create_mode = 0; 1691 + error = do_path_lookup(dfd, pathname, 1692 + lookup_flags(flag)|LOOKUP_OPEN, &nd); 1693 + if (IS_ERR(nd.intent.open.file)) { 1694 + if (error == 0) { 1695 + error = PTR_ERR(nd.intent.open.file); 1696 + path_put(&nd.path); 1697 + } 1698 + } else if (error) 1699 + release_open_intent(&nd); 1640 1700 if (error) 1641 1701 return ERR_PTR(error); 1642 1702 goto ok; ··· 1726 1758 goto exit; 1727 1759 } 1728 1760 filp = nameidata_to_filp(&nd, open_flag); 1729 - if (IS_ERR(filp)) 1730 - ima_counts_put(&nd.path, 1731 - acc_mode & (MAY_READ | MAY_WRITE | 1732 - MAY_EXEC)); 1733 1761 mnt_drop_write(nd.path.mnt); 1734 1762 if (nd.root.mnt) 1735 1763 path_put(&nd.root); 1764 + if (!IS_ERR(filp)) { 1765 + error = ima_path_check(&filp->f_path, filp->f_mode & 1766 + (MAY_READ | MAY_WRITE | MAY_EXEC)); 1767 + if (error) { 1768 + fput(filp); 1769 + filp = ERR_PTR(error); 1770 + } 1771 + } 1736 1772 return filp; 1737 1773 } 1738 1774 ··· 1777 1805 * be avoided. Taking this mnt write here 1778 1806 * ensures that (2) can not occur. 1779 1807 */ 1780 - will_write = open_will_write_to_fs(flag, nd.path.dentry->d_inode); 1781 - if (will_write) { 1808 + will_truncate = open_will_truncate(flag, nd.path.dentry->d_inode); 1809 + if (will_truncate) { 1782 1810 error = mnt_want_write(nd.path.mnt); 1783 1811 if (error) 1784 1812 goto exit; 1785 1813 } 1786 1814 error = may_open(&nd.path, acc_mode, flag); 1787 1815 if (error) { 1788 - if (will_write) 1816 + if (will_truncate) 1789 1817 mnt_drop_write(nd.path.mnt); 1790 1818 goto exit; 1791 1819 } 1792 1820 filp = nameidata_to_filp(&nd, open_flag); 1793 - if (IS_ERR(filp)) 1794 - ima_counts_put(&nd.path, 1795 - acc_mode & (MAY_READ | MAY_WRITE | MAY_EXEC)); 1821 + if (!IS_ERR(filp)) { 1822 + error = ima_path_check(&filp->f_path, filp->f_mode & 1823 + (MAY_READ | MAY_WRITE | MAY_EXEC)); 1824 + if (error) { 1825 + fput(filp); 1826 + filp = ERR_PTR(error); 1827 + } 1828 + } 1829 + if (!IS_ERR(filp)) { 1830 + if (acc_mode & MAY_WRITE) 1831 + vfs_dq_init(nd.path.dentry->d_inode); 1832 + 1833 + if (will_truncate) { 1834 + error = handle_truncate(&nd.path); 1835 + if (error) { 1836 + fput(filp); 1837 + filp = ERR_PTR(error); 1838 + } 1839 + } 1840 + } 1796 1841 /* 1797 1842 * It is now safe to drop the mnt write 1798 1843 * because the filp has had a write taken 1799 1844 * on its behalf. 1800 1845 */ 1801 - if (will_write) 1846 + if (will_truncate) 1802 1847 mnt_drop_write(nd.path.mnt); 1803 1848 if (nd.root.mnt) 1804 1849 path_put(&nd.root); ··· 1852 1863 error = security_inode_follow_link(path.dentry, &nd); 1853 1864 if (error) 1854 1865 goto exit_dput; 1866 + save = nd.path; 1867 + path_get(&save); 1855 1868 error = __do_follow_link(&path, &nd); 1869 + if (error == -ESTALE) { 1870 + /* nd.path had been dropped */ 1871 + nd.path = save; 1872 + path_get(&nd.path); 1873 + nd.flags |= LOOKUP_REVAL; 1874 + error = __do_follow_link(&path, &nd); 1875 + } 1876 + path_put(&save); 1877 + path_put(&path); 1856 1878 if (error) { 1857 1879 /* Does someone understand code flow here? Or it is only 1858 1880 * me so stupid? Anathema to whoever designed this non-sense
+1 -2
fs/namespace.c
··· 2068 2068 * create_mnt_ns - creates a private namespace and adds a root filesystem 2069 2069 * @mnt: pointer to the new root filesystem mountpoint 2070 2070 */ 2071 - struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt) 2071 + static struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt) 2072 2072 { 2073 2073 struct mnt_namespace *new_ns; 2074 2074 ··· 2080 2080 } 2081 2081 return new_ns; 2082 2082 } 2083 - EXPORT_SYMBOL(create_mnt_ns); 2084 2083 2085 2084 SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name, 2086 2085 char __user *, type, unsigned long, flags, void __user *, data)
-8
fs/nfs/super.c
··· 2648 2648 static int nfs_follow_remote_path(struct vfsmount *root_mnt, 2649 2649 const char *export_path, struct vfsmount *mnt_target) 2650 2650 { 2651 - struct mnt_namespace *ns_private; 2652 2651 struct nameidata nd; 2653 2652 struct super_block *s; 2654 2653 int ret; 2655 2654 2656 - ns_private = create_mnt_ns(root_mnt); 2657 - ret = PTR_ERR(ns_private); 2658 - if (IS_ERR(ns_private)) 2659 - goto out_mntput; 2660 - 2661 2655 ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt, 2662 2656 export_path, LOOKUP_FOLLOW, &nd); 2663 - 2664 - put_mnt_ns(ns_private); 2665 2657 2666 2658 if (ret != 0) 2667 2659 goto out_err;
+1 -4
fs/nfsd/vfs.c
··· 752 752 flags, current_cred()); 753 753 if (IS_ERR(*filp)) 754 754 host_err = PTR_ERR(*filp); 755 - else 756 - ima_counts_get(*filp); 757 755 out_nfserr: 758 756 err = nfserrno(host_err); 759 757 out: ··· 2130 2132 */ 2131 2133 path.mnt = exp->ex_path.mnt; 2132 2134 path.dentry = dentry; 2133 - err = ima_path_check(&path, acc & (MAY_READ | MAY_WRITE | MAY_EXEC), 2134 - IMA_COUNT_LEAVE); 2135 + err = ima_path_check(&path, acc & (MAY_READ | MAY_WRITE | MAY_EXEC)); 2135 2136 nfsd_out: 2136 2137 return err? nfserrno(err) : 0; 2137 2138 }
+1 -2
fs/nilfs2/super.c
··· 1118 1118 /* Abandoning the newly allocated superblock */ 1119 1119 mutex_unlock(&nilfs->ns_mount_mutex); 1120 1120 put_nilfs(nilfs); 1121 - up_write(&s->s_umount); 1122 - deactivate_super(s); 1121 + deactivate_locked_super(s); 1123 1122 /* 1124 1123 * deactivate_super() invokes close_bdev_exclusive(). 1125 1124 * We must finish all post-cleaning before this call;
+14 -15
fs/notify/inotify/inotify_user.c
··· 646 646 struct fsnotify_group *group; 647 647 struct user_struct *user; 648 648 struct file *filp; 649 + struct path path; 649 650 int fd, ret; 650 651 651 652 /* Check the IN_* constants for consistency. */ ··· 659 658 fd = get_unused_fd_flags(flags & O_CLOEXEC); 660 659 if (fd < 0) 661 660 return fd; 662 - 663 - filp = get_empty_filp(); 664 - if (!filp) { 665 - ret = -ENFILE; 666 - goto out_put_fd; 667 - } 668 661 669 662 user = get_current_user(); 670 663 if (unlikely(atomic_read(&user->inotify_devs) >= ··· 674 679 goto out_free_uid; 675 680 } 676 681 677 - filp->f_op = &inotify_fops; 678 - filp->f_path.mnt = mntget(inotify_mnt); 679 - filp->f_path.dentry = dget(inotify_mnt->mnt_root); 680 - filp->f_mapping = filp->f_path.dentry->d_inode->i_mapping; 681 - filp->f_mode = FMODE_READ; 682 + atomic_inc(&user->inotify_devs); 683 + 684 + path.mnt = inotify_mnt; 685 + path.dentry = inotify_mnt->mnt_root; 686 + path_get(&path); 687 + filp = alloc_file(&path, FMODE_READ, &inotify_fops); 688 + if (!filp) 689 + goto Enfile; 690 + 682 691 filp->f_flags = O_RDONLY | (flags & O_NONBLOCK); 683 692 filp->private_data = group; 684 - 685 - atomic_inc(&user->inotify_devs); 686 693 687 694 fd_install(fd, filp); 688 695 689 696 return fd; 690 697 698 + Enfile: 699 + ret = -ENFILE; 700 + path_put(&path); 701 + atomic_dec(&user->inotify_devs); 691 702 out_free_uid: 692 703 free_uid(user); 693 - put_filp(filp); 694 - out_put_fd: 695 704 put_unused_fd(fd); 696 705 return ret; 697 706 }
+25 -62
fs/ocfs2/acl.c
··· 331 331 return ret; 332 332 } 333 333 334 - static size_t ocfs2_xattr_list_acl_access(struct inode *inode, 334 + static size_t ocfs2_xattr_list_acl_access(struct dentry *dentry, 335 335 char *list, 336 336 size_t list_len, 337 337 const char *name, 338 - size_t name_len) 338 + size_t name_len, 339 + int type) 339 340 { 340 - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 341 + struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); 341 342 const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); 342 343 343 344 if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) ··· 349 348 return size; 350 349 } 351 350 352 - static size_t ocfs2_xattr_list_acl_default(struct inode *inode, 351 + static size_t ocfs2_xattr_list_acl_default(struct dentry *dentry, 353 352 char *list, 354 353 size_t list_len, 355 354 const char *name, 356 - size_t name_len) 355 + size_t name_len, 356 + int type) 357 357 { 358 - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 358 + struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); 359 359 const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); 360 360 361 361 if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) ··· 367 365 return size; 368 366 } 369 367 370 - static int ocfs2_xattr_get_acl(struct inode *inode, 371 - int type, 372 - void *buffer, 373 - size_t size) 368 + static int ocfs2_xattr_get_acl(struct dentry *dentry, const char *name, 369 + void *buffer, size_t size, int type) 374 370 { 375 - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 371 + struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); 376 372 struct posix_acl *acl; 377 373 int ret; 378 374 375 + if (strcmp(name, "") != 0) 376 + return -EINVAL; 379 377 if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) 380 378 return -EOPNOTSUPP; 381 379 382 - acl = ocfs2_get_acl(inode, type); 380 + acl = ocfs2_get_acl(dentry->d_inode, type); 383 381 if (IS_ERR(acl)) 384 382 return PTR_ERR(acl); 385 383 if (acl == NULL) ··· 390 388 return ret; 391 389 } 392 390 393 - static int ocfs2_xattr_get_acl_access(struct inode *inode, 394 - const char *name, 395 - void *buffer, 396 - size_t size) 391 + static int ocfs2_xattr_set_acl(struct dentry *dentry, const char *name, 392 + const void *value, size_t size, int flags, int type) 397 393 { 398 - if (strcmp(name, "") != 0) 399 - return -EINVAL; 400 - return ocfs2_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size); 401 - } 402 - 403 - static int ocfs2_xattr_get_acl_default(struct inode *inode, 404 - const char *name, 405 - void *buffer, 406 - size_t size) 407 - { 408 - if (strcmp(name, "") != 0) 409 - return -EINVAL; 410 - return ocfs2_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size); 411 - } 412 - 413 - static int ocfs2_xattr_set_acl(struct inode *inode, 414 - int type, 415 - const void *value, 416 - size_t size) 417 - { 394 + struct inode *inode = dentry->d_inode; 418 395 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 419 396 struct posix_acl *acl; 420 397 int ret = 0; 421 398 399 + if (strcmp(name, "") != 0) 400 + return -EINVAL; 422 401 if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) 423 402 return -EOPNOTSUPP; 424 403 ··· 425 442 return ret; 426 443 } 427 444 428 - static int ocfs2_xattr_set_acl_access(struct inode *inode, 429 - const char *name, 430 - const void *value, 431 - size_t size, 432 - int flags) 433 - { 434 - if (strcmp(name, "") != 0) 435 - return -EINVAL; 436 - return ocfs2_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); 437 - } 438 - 439 - static int ocfs2_xattr_set_acl_default(struct inode *inode, 440 - const char *name, 441 - const void *value, 442 - size_t size, 443 - int flags) 444 - { 445 - if (strcmp(name, "") != 0) 446 - return -EINVAL; 447 - return ocfs2_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); 448 - } 449 - 450 445 struct xattr_handler ocfs2_xattr_acl_access_handler = { 451 446 .prefix = POSIX_ACL_XATTR_ACCESS, 447 + .flags = ACL_TYPE_ACCESS, 452 448 .list = ocfs2_xattr_list_acl_access, 453 - .get = ocfs2_xattr_get_acl_access, 454 - .set = ocfs2_xattr_set_acl_access, 449 + .get = ocfs2_xattr_get_acl, 450 + .set = ocfs2_xattr_set_acl, 455 451 }; 456 452 457 453 struct xattr_handler ocfs2_xattr_acl_default_handler = { 458 454 .prefix = POSIX_ACL_XATTR_DEFAULT, 455 + .flags = ACL_TYPE_DEFAULT, 459 456 .list = ocfs2_xattr_list_acl_default, 460 - .get = ocfs2_xattr_get_acl_default, 461 - .set = ocfs2_xattr_set_acl_default, 457 + .get = ocfs2_xattr_get_acl, 458 + .set = ocfs2_xattr_set_acl, 462 459 };
+2 -2
fs/ocfs2/alloc.c
··· 7190 7190 * wait on them - the truncate_inode_pages() call later will 7191 7191 * do that for us. 7192 7192 */ 7193 - ret = do_sync_mapping_range(inode->i_mapping, range_start, 7194 - range_end - 1, SYNC_FILE_RANGE_WRITE); 7193 + ret = filemap_fdatawrite_range(inode->i_mapping, range_start, 7194 + range_end - 1); 7195 7195 if (ret) 7196 7196 mlog_errno(ret); 7197 7197
+35 -37
fs/ocfs2/xattr.c
··· 205 205 int offset, 206 206 struct ocfs2_xattr_value_root **xv, 207 207 struct buffer_head **bh); 208 - static int ocfs2_xattr_security_set(struct inode *inode, const char *name, 209 - const void *value, size_t size, int flags); 210 208 211 209 static inline u16 ocfs2_xattr_buckets_per_cluster(struct ocfs2_super *osb) 212 210 { ··· 6976 6978 6977 6979 ret = ocfs2_init_security_get(inode, dir, &si); 6978 6980 if (!ret) { 6979 - ret = ocfs2_xattr_security_set(inode, si.name, 6980 - si.value, si.value_len, 6981 - XATTR_CREATE); 6981 + ret = ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY, 6982 + si.name, si.value, si.value_len, 6983 + XATTR_CREATE); 6982 6984 if (ret) { 6983 6985 mlog_errno(ret); 6984 6986 goto leave; ··· 7006 7008 /* 7007 7009 * 'security' attributes support 7008 7010 */ 7009 - static size_t ocfs2_xattr_security_list(struct inode *inode, char *list, 7011 + static size_t ocfs2_xattr_security_list(struct dentry *dentry, char *list, 7010 7012 size_t list_size, const char *name, 7011 - size_t name_len) 7013 + size_t name_len, int type) 7012 7014 { 7013 7015 const size_t prefix_len = XATTR_SECURITY_PREFIX_LEN; 7014 7016 const size_t total_len = prefix_len + name_len + 1; ··· 7021 7023 return total_len; 7022 7024 } 7023 7025 7024 - static int ocfs2_xattr_security_get(struct inode *inode, const char *name, 7025 - void *buffer, size_t size) 7026 + static int ocfs2_xattr_security_get(struct dentry *dentry, const char *name, 7027 + void *buffer, size_t size, int type) 7026 7028 { 7027 7029 if (strcmp(name, "") == 0) 7028 7030 return -EINVAL; 7029 - return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_SECURITY, name, 7030 - buffer, size); 7031 + return ocfs2_xattr_get(dentry->d_inode, OCFS2_XATTR_INDEX_SECURITY, 7032 + name, buffer, size); 7031 7033 } 7032 7034 7033 - static int ocfs2_xattr_security_set(struct inode *inode, const char *name, 7034 - const void *value, size_t size, int flags) 7035 + static int ocfs2_xattr_security_set(struct dentry *dentry, const char *name, 7036 + const void *value, size_t size, int flags, int type) 7035 7037 { 7036 7038 if (strcmp(name, "") == 0) 7037 7039 return -EINVAL; 7038 7040 7039 - return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY, name, value, 7040 - size, flags); 7041 + return ocfs2_xattr_set(dentry->d_inode, OCFS2_XATTR_INDEX_SECURITY, 7042 + name, value, size, flags); 7041 7043 } 7042 7044 7043 7045 int ocfs2_init_security_get(struct inode *inode, ··· 7074 7076 /* 7075 7077 * 'trusted' attributes support 7076 7078 */ 7077 - static size_t ocfs2_xattr_trusted_list(struct inode *inode, char *list, 7079 + static size_t ocfs2_xattr_trusted_list(struct dentry *dentry, char *list, 7078 7080 size_t list_size, const char *name, 7079 - size_t name_len) 7081 + size_t name_len, int type) 7080 7082 { 7081 7083 const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN; 7082 7084 const size_t total_len = prefix_len + name_len + 1; ··· 7089 7091 return total_len; 7090 7092 } 7091 7093 7092 - static int ocfs2_xattr_trusted_get(struct inode *inode, const char *name, 7093 - void *buffer, size_t size) 7094 + static int ocfs2_xattr_trusted_get(struct dentry *dentry, const char *name, 7095 + void *buffer, size_t size, int type) 7094 7096 { 7095 7097 if (strcmp(name, "") == 0) 7096 7098 return -EINVAL; 7097 - return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_TRUSTED, name, 7098 - buffer, size); 7099 + return ocfs2_xattr_get(dentry->d_inode, OCFS2_XATTR_INDEX_TRUSTED, 7100 + name, buffer, size); 7099 7101 } 7100 7102 7101 - static int ocfs2_xattr_trusted_set(struct inode *inode, const char *name, 7102 - const void *value, size_t size, int flags) 7103 + static int ocfs2_xattr_trusted_set(struct dentry *dentry, const char *name, 7104 + const void *value, size_t size, int flags, int type) 7103 7105 { 7104 7106 if (strcmp(name, "") == 0) 7105 7107 return -EINVAL; 7106 7108 7107 - return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_TRUSTED, name, value, 7108 - size, flags); 7109 + return ocfs2_xattr_set(dentry->d_inode, OCFS2_XATTR_INDEX_TRUSTED, 7110 + name, value, size, flags); 7109 7111 } 7110 7112 7111 7113 struct xattr_handler ocfs2_xattr_trusted_handler = { ··· 7118 7120 /* 7119 7121 * 'user' attributes support 7120 7122 */ 7121 - static size_t ocfs2_xattr_user_list(struct inode *inode, char *list, 7123 + static size_t ocfs2_xattr_user_list(struct dentry *dentry, char *list, 7122 7124 size_t list_size, const char *name, 7123 - size_t name_len) 7125 + size_t name_len, int type) 7124 7126 { 7125 7127 const size_t prefix_len = XATTR_USER_PREFIX_LEN; 7126 7128 const size_t total_len = prefix_len + name_len + 1; 7127 - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 7129 + struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); 7128 7130 7129 7131 if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) 7130 7132 return 0; ··· 7137 7139 return total_len; 7138 7140 } 7139 7141 7140 - static int ocfs2_xattr_user_get(struct inode *inode, const char *name, 7141 - void *buffer, size_t size) 7142 + static int ocfs2_xattr_user_get(struct dentry *dentry, const char *name, 7143 + void *buffer, size_t size, int type) 7142 7144 { 7143 - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 7145 + struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); 7144 7146 7145 7147 if (strcmp(name, "") == 0) 7146 7148 return -EINVAL; 7147 7149 if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) 7148 7150 return -EOPNOTSUPP; 7149 - return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_USER, name, 7151 + return ocfs2_xattr_get(dentry->d_inode, OCFS2_XATTR_INDEX_USER, name, 7150 7152 buffer, size); 7151 7153 } 7152 7154 7153 - static int ocfs2_xattr_user_set(struct inode *inode, const char *name, 7154 - const void *value, size_t size, int flags) 7155 + static int ocfs2_xattr_user_set(struct dentry *dentry, const char *name, 7156 + const void *value, size_t size, int flags, int type) 7155 7157 { 7156 - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 7158 + struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); 7157 7159 7158 7160 if (strcmp(name, "") == 0) 7159 7161 return -EINVAL; 7160 7162 if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) 7161 7163 return -EOPNOTSUPP; 7162 7164 7163 - return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_USER, name, value, 7164 - size, flags); 7165 + return ocfs2_xattr_set(dentry->d_inode, OCFS2_XATTR_INDEX_USER, 7166 + name, value, size, flags); 7165 7167 } 7166 7168 7167 7169 struct xattr_handler ocfs2_xattr_user_handler = {
+4
fs/open.c
··· 30 30 #include <linux/audit.h> 31 31 #include <linux/falloc.h> 32 32 #include <linux/fs_struct.h> 33 + #include <linux/ima.h> 34 + 35 + #include "internal.h" 33 36 34 37 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) 35 38 { ··· 858 855 if (error) 859 856 goto cleanup_all; 860 857 } 858 + ima_counts_get(f); 861 859 862 860 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); 863 861
+12 -17
fs/pipe.c
··· 974 974 int err; 975 975 struct inode *inode; 976 976 struct file *f; 977 - struct dentry *dentry; 977 + struct path path; 978 978 struct qstr name = { .name = "" }; 979 979 980 980 err = -ENFILE; ··· 983 983 goto err; 984 984 985 985 err = -ENOMEM; 986 - dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &name); 987 - if (!dentry) 986 + path.dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &name); 987 + if (!path.dentry) 988 988 goto err_inode; 989 + path.mnt = mntget(pipe_mnt); 989 990 990 - dentry->d_op = &pipefs_dentry_operations; 991 + path.dentry->d_op = &pipefs_dentry_operations; 991 992 /* 992 993 * We dont want to publish this dentry into global dentry hash table. 993 994 * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED 994 995 * This permits a working /proc/$pid/fd/XXX on pipes 995 996 */ 996 - dentry->d_flags &= ~DCACHE_UNHASHED; 997 - d_instantiate(dentry, inode); 997 + path.dentry->d_flags &= ~DCACHE_UNHASHED; 998 + d_instantiate(path.dentry, inode); 998 999 999 1000 err = -ENFILE; 1000 - f = alloc_file(pipe_mnt, dentry, FMODE_WRITE, &write_pipefifo_fops); 1001 + f = alloc_file(&path, FMODE_WRITE, &write_pipefifo_fops); 1001 1002 if (!f) 1002 1003 goto err_dentry; 1003 1004 f->f_mapping = inode->i_mapping; ··· 1010 1009 1011 1010 err_dentry: 1012 1011 free_pipe_info(inode); 1013 - dput(dentry); 1012 + path_put(&path); 1014 1013 return ERR_PTR(err); 1015 1014 1016 1015 err_inode: ··· 1029 1028 1030 1029 struct file *create_read_pipe(struct file *wrf, int flags) 1031 1030 { 1032 - struct file *f = get_empty_filp(); 1031 + /* Grab pipe from the writer */ 1032 + struct file *f = alloc_file(&wrf->f_path, FMODE_READ, 1033 + &read_pipefifo_fops); 1033 1034 if (!f) 1034 1035 return ERR_PTR(-ENFILE); 1035 1036 1036 - /* Grab pipe from the writer */ 1037 - f->f_path = wrf->f_path; 1038 1037 path_get(&wrf->f_path); 1039 - f->f_mapping = wrf->f_path.dentry->d_inode->i_mapping; 1040 - 1041 - f->f_pos = 0; 1042 1038 f->f_flags = O_RDONLY | (flags & O_NONBLOCK); 1043 - f->f_op = &read_pipefifo_fops; 1044 - f->f_mode = FMODE_READ; 1045 - f->f_version = 0; 1046 1039 1047 1040 return f; 1048 1041 }
+18 -18
fs/reiserfs/xattr.c
··· 48 48 #include <net/checksum.h> 49 49 #include <linux/stat.h> 50 50 #include <linux/quotaops.h> 51 + #include <linux/security.h> 51 52 52 53 #define PRIVROOT_NAME ".reiserfs_priv" 53 54 #define XAROOT_NAME "xattrs" ··· 727 726 reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer, 728 727 size_t size) 729 728 { 730 - struct inode *inode = dentry->d_inode; 731 729 struct xattr_handler *handler; 732 730 733 - handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name); 731 + handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name); 734 732 735 - if (!handler || get_inode_sd_version(inode) == STAT_DATA_V1) 733 + if (!handler || get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1) 736 734 return -EOPNOTSUPP; 737 735 738 - return handler->get(inode, name, buffer, size); 736 + return handler->get(dentry, name, buffer, size, handler->flags); 739 737 } 740 738 741 739 /* ··· 746 746 reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value, 747 747 size_t size, int flags) 748 748 { 749 - struct inode *inode = dentry->d_inode; 750 749 struct xattr_handler *handler; 751 750 752 - handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name); 751 + handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name); 753 752 754 - if (!handler || get_inode_sd_version(inode) == STAT_DATA_V1) 753 + if (!handler || get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1) 755 754 return -EOPNOTSUPP; 756 755 757 - return handler->set(inode, name, value, size, flags); 756 + return handler->set(dentry, name, value, size, flags, handler->flags); 758 757 } 759 758 760 759 /* ··· 763 764 */ 764 765 int reiserfs_removexattr(struct dentry *dentry, const char *name) 765 766 { 766 - struct inode *inode = dentry->d_inode; 767 767 struct xattr_handler *handler; 768 - handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name); 768 + handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name); 769 769 770 - if (!handler || get_inode_sd_version(inode) == STAT_DATA_V1) 770 + if (!handler || get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1) 771 771 return -EOPNOTSUPP; 772 772 773 - return handler->set(inode, name, NULL, 0, XATTR_REPLACE); 773 + return handler->set(dentry, name, NULL, 0, XATTR_REPLACE, handler->flags); 774 774 } 775 775 776 776 struct listxattr_buf { 777 777 size_t size; 778 778 size_t pos; 779 779 char *buf; 780 - struct inode *inode; 780 + struct dentry *dentry; 781 781 }; 782 782 783 783 static int listxattr_filler(void *buf, const char *name, int namelen, ··· 787 789 if (name[0] != '.' || 788 790 (namelen != 1 && (name[1] != '.' || namelen != 2))) { 789 791 struct xattr_handler *handler; 790 - handler = find_xattr_handler_prefix(b->inode->i_sb->s_xattr, 792 + handler = find_xattr_handler_prefix(b->dentry->d_sb->s_xattr, 791 793 name); 792 794 if (!handler) /* Unsupported xattr name */ 793 795 return 0; 794 796 if (b->buf) { 795 - size = handler->list(b->inode, b->buf + b->pos, 796 - b->size, name, namelen); 797 + size = handler->list(b->dentry, b->buf + b->pos, 798 + b->size, name, namelen, 799 + handler->flags); 797 800 if (size > b->size) 798 801 return -ERANGE; 799 802 } else { 800 - size = handler->list(b->inode, NULL, 0, name, namelen); 803 + size = handler->list(b->dentry, NULL, 0, name, 804 + namelen, handler->flags); 801 805 } 802 806 803 807 b->pos += size; ··· 820 820 int err = 0; 821 821 loff_t pos = 0; 822 822 struct listxattr_buf buf = { 823 - .inode = dentry->d_inode, 823 + .dentry = dentry, 824 824 .buf = buffer, 825 825 .size = buffer ? size : 0, 826 826 };
+19 -50
fs/reiserfs/xattr_acl.c
··· 15 15 struct posix_acl *acl); 16 16 17 17 static int 18 - xattr_set_acl(struct inode *inode, int type, const void *value, size_t size) 18 + posix_acl_set(struct dentry *dentry, const char *name, const void *value, 19 + size_t size, int flags, int type) 19 20 { 21 + struct inode *inode = dentry->d_inode; 20 22 struct posix_acl *acl; 21 23 int error, error2; 22 24 struct reiserfs_transaction_handle th; ··· 62 60 } 63 61 64 62 static int 65 - xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size) 63 + posix_acl_get(struct dentry *dentry, const char *name, void *buffer, 64 + size_t size, int type) 66 65 { 67 66 struct posix_acl *acl; 68 67 int error; 69 68 70 - if (!reiserfs_posixacl(inode->i_sb)) 69 + if (!reiserfs_posixacl(dentry->d_sb)) 71 70 return -EOPNOTSUPP; 72 71 73 - acl = reiserfs_get_acl(inode, type); 72 + acl = reiserfs_get_acl(dentry->d_inode, type); 74 73 if (IS_ERR(acl)) 75 74 return PTR_ERR(acl); 76 75 if (acl == NULL) ··· 485 482 return error; 486 483 } 487 484 488 - static int 489 - posix_acl_access_get(struct inode *inode, const char *name, 490 - void *buffer, size_t size) 491 - { 492 - if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS) - 1) 493 - return -EINVAL; 494 - return xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size); 495 - } 496 - 497 - static int 498 - posix_acl_access_set(struct inode *inode, const char *name, 499 - const void *value, size_t size, int flags) 500 - { 501 - if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS) - 1) 502 - return -EINVAL; 503 - return xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); 504 - } 505 - 506 - static size_t posix_acl_access_list(struct inode *inode, char *list, 485 + static size_t posix_acl_access_list(struct dentry *dentry, char *list, 507 486 size_t list_size, const char *name, 508 - size_t name_len) 487 + size_t name_len, int type) 509 488 { 510 489 const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); 511 - if (!reiserfs_posixacl(inode->i_sb)) 490 + if (!reiserfs_posixacl(dentry->d_sb)) 512 491 return 0; 513 492 if (list && size <= list_size) 514 493 memcpy(list, POSIX_ACL_XATTR_ACCESS, size); ··· 499 514 500 515 struct xattr_handler reiserfs_posix_acl_access_handler = { 501 516 .prefix = POSIX_ACL_XATTR_ACCESS, 502 - .get = posix_acl_access_get, 503 - .set = posix_acl_access_set, 517 + .flags = ACL_TYPE_ACCESS, 518 + .get = posix_acl_get, 519 + .set = posix_acl_set, 504 520 .list = posix_acl_access_list, 505 521 }; 506 522 507 - static int 508 - posix_acl_default_get(struct inode *inode, const char *name, 509 - void *buffer, size_t size) 510 - { 511 - if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT) - 1) 512 - return -EINVAL; 513 - return xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size); 514 - } 515 - 516 - static int 517 - posix_acl_default_set(struct inode *inode, const char *name, 518 - const void *value, size_t size, int flags) 519 - { 520 - if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT) - 1) 521 - return -EINVAL; 522 - return xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); 523 - } 524 - 525 - static size_t posix_acl_default_list(struct inode *inode, char *list, 523 + static size_t posix_acl_default_list(struct dentry *dentry, char *list, 526 524 size_t list_size, const char *name, 527 - size_t name_len) 525 + size_t name_len, int type) 528 526 { 529 527 const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); 530 - if (!reiserfs_posixacl(inode->i_sb)) 528 + if (!reiserfs_posixacl(dentry->d_sb)) 531 529 return 0; 532 530 if (list && size <= list_size) 533 531 memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); ··· 519 551 520 552 struct xattr_handler reiserfs_posix_acl_default_handler = { 521 553 .prefix = POSIX_ACL_XATTR_DEFAULT, 522 - .get = posix_acl_default_get, 523 - .set = posix_acl_default_set, 554 + .flags = ACL_TYPE_DEFAULT, 555 + .get = posix_acl_get, 556 + .set = posix_acl_set, 524 557 .list = posix_acl_default_list, 525 558 };
+11 -10
fs/reiserfs/xattr_security.c
··· 8 8 #include <asm/uaccess.h> 9 9 10 10 static int 11 - security_get(struct inode *inode, const char *name, void *buffer, size_t size) 11 + security_get(struct dentry *dentry, const char *name, void *buffer, size_t size, 12 + int handler_flags) 12 13 { 13 14 if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) 14 15 return -EINVAL; 15 16 16 - if (IS_PRIVATE(inode)) 17 + if (IS_PRIVATE(dentry->d_inode)) 17 18 return -EPERM; 18 19 19 - return reiserfs_xattr_get(inode, name, buffer, size); 20 + return reiserfs_xattr_get(dentry->d_inode, name, buffer, size); 20 21 } 21 22 22 23 static int 23 - security_set(struct inode *inode, const char *name, const void *buffer, 24 - size_t size, int flags) 24 + security_set(struct dentry *dentry, const char *name, const void *buffer, 25 + size_t size, int flags, int handler_flags) 25 26 { 26 27 if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) 27 28 return -EINVAL; 28 29 29 - if (IS_PRIVATE(inode)) 30 + if (IS_PRIVATE(dentry->d_inode)) 30 31 return -EPERM; 31 32 32 - return reiserfs_xattr_set(inode, name, buffer, size, flags); 33 + return reiserfs_xattr_set(dentry->d_inode, name, buffer, size, flags); 33 34 } 34 35 35 - static size_t security_list(struct inode *inode, char *list, size_t list_len, 36 - const char *name, size_t namelen) 36 + static size_t security_list(struct dentry *dentry, char *list, size_t list_len, 37 + const char *name, size_t namelen, int handler_flags) 37 38 { 38 39 const size_t len = namelen + 1; 39 40 40 - if (IS_PRIVATE(inode)) 41 + if (IS_PRIVATE(dentry->d_inode)) 41 42 return 0; 42 43 43 44 if (list && len <= list_len) {
+11 -10
fs/reiserfs/xattr_trusted.c
··· 8 8 #include <asm/uaccess.h> 9 9 10 10 static int 11 - trusted_get(struct inode *inode, const char *name, void *buffer, size_t size) 11 + trusted_get(struct dentry *dentry, const char *name, void *buffer, size_t size, 12 + int handler_flags) 12 13 { 13 14 if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) 14 15 return -EINVAL; 15 16 16 - if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode)) 17 + if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(dentry->d_inode)) 17 18 return -EPERM; 18 19 19 - return reiserfs_xattr_get(inode, name, buffer, size); 20 + return reiserfs_xattr_get(dentry->d_inode, name, buffer, size); 20 21 } 21 22 22 23 static int 23 - trusted_set(struct inode *inode, const char *name, const void *buffer, 24 - size_t size, int flags) 24 + trusted_set(struct dentry *dentry, const char *name, const void *buffer, 25 + size_t size, int flags, int handler_flags) 25 26 { 26 27 if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) 27 28 return -EINVAL; 28 29 29 - if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode)) 30 + if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(dentry->d_inode)) 30 31 return -EPERM; 31 32 32 - return reiserfs_xattr_set(inode, name, buffer, size, flags); 33 + return reiserfs_xattr_set(dentry->d_inode, name, buffer, size, flags); 33 34 } 34 35 35 - static size_t trusted_list(struct inode *inode, char *list, size_t list_size, 36 - const char *name, size_t name_len) 36 + static size_t trusted_list(struct dentry *dentry, char *list, size_t list_size, 37 + const char *name, size_t name_len, int handler_flags) 37 38 { 38 39 const size_t len = name_len + 1; 39 40 40 - if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode)) 41 + if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(dentry->d_inode)) 41 42 return 0; 42 43 43 44 if (list && len <= list_size) {
+11 -10
fs/reiserfs/xattr_user.c
··· 7 7 #include <asm/uaccess.h> 8 8 9 9 static int 10 - user_get(struct inode *inode, const char *name, void *buffer, size_t size) 10 + user_get(struct dentry *dentry, const char *name, void *buffer, size_t size, 11 + int handler_flags) 11 12 { 12 13 13 14 if (strlen(name) < sizeof(XATTR_USER_PREFIX)) 14 15 return -EINVAL; 15 - if (!reiserfs_xattrs_user(inode->i_sb)) 16 + if (!reiserfs_xattrs_user(dentry->d_sb)) 16 17 return -EOPNOTSUPP; 17 - return reiserfs_xattr_get(inode, name, buffer, size); 18 + return reiserfs_xattr_get(dentry->d_inode, name, buffer, size); 18 19 } 19 20 20 21 static int 21 - user_set(struct inode *inode, const char *name, const void *buffer, 22 - size_t size, int flags) 22 + user_set(struct dentry *dentry, const char *name, const void *buffer, 23 + size_t size, int flags, int handler_flags) 23 24 { 24 25 if (strlen(name) < sizeof(XATTR_USER_PREFIX)) 25 26 return -EINVAL; 26 27 27 - if (!reiserfs_xattrs_user(inode->i_sb)) 28 + if (!reiserfs_xattrs_user(dentry->d_sb)) 28 29 return -EOPNOTSUPP; 29 - return reiserfs_xattr_set(inode, name, buffer, size, flags); 30 + return reiserfs_xattr_set(dentry->d_inode, name, buffer, size, flags); 30 31 } 31 32 32 - static size_t user_list(struct inode *inode, char *list, size_t list_size, 33 - const char *name, size_t name_len) 33 + static size_t user_list(struct dentry *dentry, char *list, size_t list_size, 34 + const char *name, size_t name_len, int handler_flags) 34 35 { 35 36 const size_t len = name_len + 1; 36 37 37 - if (!reiserfs_xattrs_user(inode->i_sb)) 38 + if (!reiserfs_xattrs_user(dentry->d_sb)) 38 39 return 0; 39 40 if (list && len <= list_size) { 40 41 memcpy(list, name, name_len);
+14 -14
fs/xattr.c
··· 615 615 generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size) 616 616 { 617 617 struct xattr_handler *handler; 618 - struct inode *inode = dentry->d_inode; 619 618 620 - handler = xattr_resolve_name(inode->i_sb->s_xattr, &name); 619 + handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); 621 620 if (!handler) 622 621 return -EOPNOTSUPP; 623 - return handler->get(inode, name, buffer, size); 622 + return handler->get(dentry, name, buffer, size, handler->flags); 624 623 } 625 624 626 625 /* ··· 629 630 ssize_t 630 631 generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) 631 632 { 632 - struct inode *inode = dentry->d_inode; 633 - struct xattr_handler *handler, **handlers = inode->i_sb->s_xattr; 633 + struct xattr_handler *handler, **handlers = dentry->d_sb->s_xattr; 634 634 unsigned int size = 0; 635 635 636 636 if (!buffer) { 637 - for_each_xattr_handler(handlers, handler) 638 - size += handler->list(inode, NULL, 0, NULL, 0); 637 + for_each_xattr_handler(handlers, handler) { 638 + size += handler->list(dentry, NULL, 0, NULL, 0, 639 + handler->flags); 640 + } 639 641 } else { 640 642 char *buf = buffer; 641 643 642 644 for_each_xattr_handler(handlers, handler) { 643 - size = handler->list(inode, buf, buffer_size, NULL, 0); 645 + size = handler->list(dentry, buf, buffer_size, 646 + NULL, 0, handler->flags); 644 647 if (size > buffer_size) 645 648 return -ERANGE; 646 649 buf += size; ··· 660 659 generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) 661 660 { 662 661 struct xattr_handler *handler; 663 - struct inode *inode = dentry->d_inode; 664 662 665 663 if (size == 0) 666 664 value = ""; /* empty EA, do not remove */ 667 - handler = xattr_resolve_name(inode->i_sb->s_xattr, &name); 665 + handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); 668 666 if (!handler) 669 667 return -EOPNOTSUPP; 670 - return handler->set(inode, name, value, size, flags); 668 + return handler->set(dentry, name, value, size, 0, handler->flags); 671 669 } 672 670 673 671 /* ··· 677 677 generic_removexattr(struct dentry *dentry, const char *name) 678 678 { 679 679 struct xattr_handler *handler; 680 - struct inode *inode = dentry->d_inode; 681 680 682 - handler = xattr_resolve_name(inode->i_sb->s_xattr, &name); 681 + handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); 683 682 if (!handler) 684 683 return -EOPNOTSUPP; 685 - return handler->set(inode, name, NULL, 0, XATTR_REPLACE); 684 + return handler->set(dentry, name, NULL, 0, 685 + XATTR_REPLACE, handler->flags); 686 686 } 687 687 688 688 EXPORT_SYMBOL(generic_getxattr);
+20 -37
fs/xfs/linux-2.6/xfs_acl.c
··· 354 354 return error; 355 355 } 356 356 357 - /* 358 - * System xattr handlers. 359 - * 360 - * Currently Posix ACLs are the only system namespace extended attribute 361 - * handlers supported by XFS, so we just implement the handlers here. 362 - * If we ever support other system extended attributes this will need 363 - * some refactoring. 364 - */ 365 - 366 357 static int 367 - xfs_decode_acl(const char *name) 368 - { 369 - if (strcmp(name, "posix_acl_access") == 0) 370 - return ACL_TYPE_ACCESS; 371 - else if (strcmp(name, "posix_acl_default") == 0) 372 - return ACL_TYPE_DEFAULT; 373 - return -EINVAL; 374 - } 375 - 376 - static int 377 - xfs_xattr_system_get(struct inode *inode, const char *name, 378 - void *value, size_t size) 358 + xfs_xattr_acl_get(struct dentry *dentry, const char *name, 359 + void *value, size_t size, int type) 379 360 { 380 361 struct posix_acl *acl; 381 - int type, error; 362 + int error; 382 363 383 - type = xfs_decode_acl(name); 384 - if (type < 0) 385 - return type; 386 - 387 - acl = xfs_get_acl(inode, type); 364 + acl = xfs_get_acl(dentry->d_inode, type); 388 365 if (IS_ERR(acl)) 389 366 return PTR_ERR(acl); 390 367 if (acl == NULL) ··· 374 397 } 375 398 376 399 static int 377 - xfs_xattr_system_set(struct inode *inode, const char *name, 378 - const void *value, size_t size, int flags) 400 + xfs_xattr_acl_set(struct dentry *dentry, const char *name, 401 + const void *value, size_t size, int flags, int type) 379 402 { 403 + struct inode *inode = dentry->d_inode; 380 404 struct posix_acl *acl = NULL; 381 - int error = 0, type; 405 + int error = 0; 382 406 383 - type = xfs_decode_acl(name); 384 - if (type < 0) 385 - return type; 386 407 if (flags & XATTR_CREATE) 387 408 return -EINVAL; 388 409 if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) ··· 437 462 return error; 438 463 } 439 464 440 - struct xattr_handler xfs_xattr_system_handler = { 441 - .prefix = XATTR_SYSTEM_PREFIX, 442 - .get = xfs_xattr_system_get, 443 - .set = xfs_xattr_system_set, 465 + struct xattr_handler xfs_xattr_acl_access_handler = { 466 + .prefix = POSIX_ACL_XATTR_ACCESS, 467 + .flags = ACL_TYPE_ACCESS, 468 + .get = xfs_xattr_acl_get, 469 + .set = xfs_xattr_acl_set, 470 + }; 471 + 472 + struct xattr_handler xfs_xattr_acl_default_handler = { 473 + .prefix = POSIX_ACL_XATTR_DEFAULT, 474 + .flags = ACL_TYPE_DEFAULT, 475 + .get = xfs_xattr_acl_get, 476 + .set = xfs_xattr_acl_set, 444 477 };
+15 -56
fs/xfs/linux-2.6/xfs_xattr.c
··· 30 30 31 31 32 32 static int 33 - __xfs_xattr_get(struct inode *inode, const char *name, 33 + xfs_xattr_get(struct dentry *dentry, const char *name, 34 34 void *value, size_t size, int xflags) 35 35 { 36 - struct xfs_inode *ip = XFS_I(inode); 36 + struct xfs_inode *ip = XFS_I(dentry->d_inode); 37 37 int error, asize = size; 38 38 39 39 if (strcmp(name, "") == 0) ··· 52 52 } 53 53 54 54 static int 55 - __xfs_xattr_set(struct inode *inode, const char *name, const void *value, 55 + xfs_xattr_set(struct dentry *dentry, const char *name, const void *value, 56 56 size_t size, int flags, int xflags) 57 57 { 58 - struct xfs_inode *ip = XFS_I(inode); 58 + struct xfs_inode *ip = XFS_I(dentry->d_inode); 59 59 60 60 if (strcmp(name, "") == 0) 61 61 return -EINVAL; ··· 71 71 return -xfs_attr_set(ip, name, (void *)value, size, xflags); 72 72 } 73 73 74 - static int 75 - xfs_xattr_user_get(struct inode *inode, const char *name, 76 - void *value, size_t size) 77 - { 78 - return __xfs_xattr_get(inode, name, value, size, 0); 79 - } 80 - 81 - static int 82 - xfs_xattr_user_set(struct inode *inode, const char *name, 83 - const void *value, size_t size, int flags) 84 - { 85 - return __xfs_xattr_set(inode, name, value, size, flags, 0); 86 - } 87 - 88 74 static struct xattr_handler xfs_xattr_user_handler = { 89 75 .prefix = XATTR_USER_PREFIX, 90 - .get = xfs_xattr_user_get, 91 - .set = xfs_xattr_user_set, 76 + .flags = 0, /* no flags implies user namespace */ 77 + .get = xfs_xattr_get, 78 + .set = xfs_xattr_set, 92 79 }; 93 - 94 - 95 - static int 96 - xfs_xattr_trusted_get(struct inode *inode, const char *name, 97 - void *value, size_t size) 98 - { 99 - return __xfs_xattr_get(inode, name, value, size, ATTR_ROOT); 100 - } 101 - 102 - static int 103 - xfs_xattr_trusted_set(struct inode *inode, const char *name, 104 - const void *value, size_t size, int flags) 105 - { 106 - return __xfs_xattr_set(inode, name, value, size, flags, ATTR_ROOT); 107 - } 108 80 109 81 static struct xattr_handler xfs_xattr_trusted_handler = { 110 82 .prefix = XATTR_TRUSTED_PREFIX, 111 - .get = xfs_xattr_trusted_get, 112 - .set = xfs_xattr_trusted_set, 83 + .flags = ATTR_ROOT, 84 + .get = xfs_xattr_get, 85 + .set = xfs_xattr_set, 113 86 }; 114 - 115 - 116 - static int 117 - xfs_xattr_secure_get(struct inode *inode, const char *name, 118 - void *value, size_t size) 119 - { 120 - return __xfs_xattr_get(inode, name, value, size, ATTR_SECURE); 121 - } 122 - 123 - static int 124 - xfs_xattr_secure_set(struct inode *inode, const char *name, 125 - const void *value, size_t size, int flags) 126 - { 127 - return __xfs_xattr_set(inode, name, value, size, flags, ATTR_SECURE); 128 - } 129 87 130 88 static struct xattr_handler xfs_xattr_security_handler = { 131 89 .prefix = XATTR_SECURITY_PREFIX, 132 - .get = xfs_xattr_secure_get, 133 - .set = xfs_xattr_secure_set, 90 + .flags = ATTR_SECURE, 91 + .get = xfs_xattr_get, 92 + .set = xfs_xattr_set, 134 93 }; 135 - 136 94 137 95 struct xattr_handler *xfs_xattr_handlers[] = { 138 96 &xfs_xattr_user_handler, 139 97 &xfs_xattr_trusted_handler, 140 98 &xfs_xattr_security_handler, 141 99 #ifdef CONFIG_XFS_POSIX_ACL 142 - &xfs_xattr_system_handler, 100 + &xfs_xattr_acl_access_handler, 101 + &xfs_xattr_acl_default_handler, 143 102 #endif 144 103 NULL 145 104 };
+2 -1
fs/xfs/xfs_acl.h
··· 49 49 extern int posix_acl_access_exists(struct inode *inode); 50 50 extern int posix_acl_default_exists(struct inode *inode); 51 51 52 - extern struct xattr_handler xfs_xattr_system_handler; 52 + extern struct xattr_handler xfs_xattr_acl_access_handler; 53 + extern struct xattr_handler xfs_xattr_acl_default_handler; 53 54 #else 54 55 # define xfs_check_acl NULL 55 56 # define xfs_get_acl(inode, type) NULL
+3 -5
include/linux/file.h
··· 18 18 struct file_operations; 19 19 struct vfsmount; 20 20 struct dentry; 21 - extern int init_file(struct file *, struct vfsmount *mnt, 22 - struct dentry *dentry, fmode_t mode, 23 - const struct file_operations *fop); 24 - extern struct file *alloc_file(struct vfsmount *, struct dentry *dentry, 25 - fmode_t mode, const struct file_operations *fop); 21 + struct path; 22 + extern struct file *alloc_file(struct path *, fmode_t mode, 23 + const struct file_operations *fop); 26 24 27 25 static inline void fput_light(struct file *file, int fput_needed) 28 26 {
-1
include/linux/fs.h
··· 2189 2189 __insert_inode_hash(inode, inode->i_ino); 2190 2190 } 2191 2191 2192 - extern struct file * get_empty_filp(void); 2193 2192 extern void file_move(struct file *f, struct list_head *list); 2194 2193 extern void file_kill(struct file *f); 2195 2194 #ifdef CONFIG_BLOCK
+10 -31
include/linux/generic_acl.h
··· 1 - /* 2 - * include/linux/generic_acl.h 3 - * 4 - * (C) 2005 Andreas Gruenbacher <agruen@suse.de> 5 - * 6 - * This file is released under the GPL. 7 - */ 1 + #ifndef LINUX_GENERIC_ACL_H 2 + #define LINUX_GENERIC_ACL_H 8 3 9 - #ifndef GENERIC_ACL_H 10 - #define GENERIC_ACL_H 4 + #include <linux/xattr.h> 11 5 12 - #include <linux/posix_acl.h> 13 - #include <linux/posix_acl_xattr.h> 6 + struct inode; 14 7 15 - /** 16 - * struct generic_acl_operations - filesystem operations 17 - * 18 - * Filesystems must make these operations available to the generic 19 - * operations. 20 - */ 21 - struct generic_acl_operations { 22 - struct posix_acl *(*getacl)(struct inode *, int); 23 - void (*setacl)(struct inode *, int, struct posix_acl *); 24 - }; 8 + extern struct xattr_handler generic_acl_access_handler; 9 + extern struct xattr_handler generic_acl_default_handler; 25 10 26 - size_t generic_acl_list(struct inode *, struct generic_acl_operations *, int, 27 - char *, size_t); 28 - int generic_acl_get(struct inode *, struct generic_acl_operations *, int, 29 - void *, size_t); 30 - int generic_acl_set(struct inode *, struct generic_acl_operations *, int, 31 - const void *, size_t); 32 - int generic_acl_init(struct inode *, struct inode *, 33 - struct generic_acl_operations *); 34 - int generic_acl_chmod(struct inode *, struct generic_acl_operations *); 11 + int generic_acl_init(struct inode *, struct inode *); 12 + int generic_acl_chmod(struct inode *); 13 + int generic_check_acl(struct inode *inode, int mask); 35 14 36 - #endif 15 + #endif /* LINUX_GENERIC_ACL_H */
+2 -10
include/linux/ima.h
··· 13 13 #include <linux/fs.h> 14 14 struct linux_binprm; 15 15 16 - #define IMA_COUNT_UPDATE 1 17 - #define IMA_COUNT_LEAVE 0 18 - 19 16 #ifdef CONFIG_IMA 20 17 extern int ima_bprm_check(struct linux_binprm *bprm); 21 18 extern int ima_inode_alloc(struct inode *inode); 22 19 extern void ima_inode_free(struct inode *inode); 23 - extern int ima_path_check(struct path *path, int mask, int update_counts); 20 + extern int ima_path_check(struct path *path, int mask); 24 21 extern void ima_file_free(struct file *file); 25 22 extern int ima_file_mmap(struct file *file, unsigned long prot); 26 23 extern void ima_counts_get(struct file *file); 27 - extern void ima_counts_put(struct path *path, int mask); 28 24 29 25 #else 30 26 static inline int ima_bprm_check(struct linux_binprm *bprm) ··· 38 42 return; 39 43 } 40 44 41 - static inline int ima_path_check(struct path *path, int mask, int update_counts) 45 + static inline int ima_path_check(struct path *path, int mask) 42 46 { 43 47 return 0; 44 48 } ··· 58 62 return; 59 63 } 60 64 61 - static inline void ima_counts_put(struct path *path, int mask) 62 - { 63 - return; 64 - } 65 65 #endif /* CONFIG_IMA_H */ 66 66 #endif /* _LINUX_IMA_H */
-1
include/linux/mnt_namespace.h
··· 23 23 24 24 struct fs_struct; 25 25 26 - extern struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt); 27 26 extern struct mnt_namespace *copy_mnt_ns(unsigned long, struct mnt_namespace *, 28 27 struct fs_struct *); 29 28 extern void put_mnt_ns(struct mnt_namespace *ns);
-16
include/linux/shmem_fs.h
··· 41 41 extern int init_tmpfs(void); 42 42 extern int shmem_fill_super(struct super_block *sb, void *data, int silent); 43 43 44 - #ifdef CONFIG_TMPFS_POSIX_ACL 45 - int shmem_check_acl(struct inode *, int); 46 - int shmem_acl_init(struct inode *, struct inode *); 47 - 48 - extern struct xattr_handler shmem_xattr_acl_access_handler; 49 - extern struct xattr_handler shmem_xattr_acl_default_handler; 50 - 51 - extern struct generic_acl_operations shmem_acl_ops; 52 - 53 - #else 54 - static inline int shmem_acl_init(struct inode *inode, struct inode *dir) 55 - { 56 - return 0; 57 - } 58 - #endif /* CONFIG_TMPFS_POSIX_ACL */ 59 - 60 44 #endif
+7 -6
include/linux/xattr.h
··· 38 38 39 39 struct xattr_handler { 40 40 char *prefix; 41 - size_t (*list)(struct inode *inode, char *list, size_t list_size, 42 - const char *name, size_t name_len); 43 - int (*get)(struct inode *inode, const char *name, void *buffer, 44 - size_t size); 45 - int (*set)(struct inode *inode, const char *name, const void *buffer, 46 - size_t size, int flags); 41 + int flags; /* fs private flags passed back to the handlers */ 42 + size_t (*list)(struct dentry *dentry, char *list, size_t list_size, 43 + const char *name, size_t name_len, int handler_flags); 44 + int (*get)(struct dentry *dentry, const char *name, void *buffer, 45 + size_t size, int handler_flags); 46 + int (*set)(struct dentry *dentry, const char *name, const void *buffer, 47 + size_t size, int flags, int handler_flags); 47 48 }; 48 49 49 50 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
-2
ipc/mqueue.c
··· 32 32 #include <linux/nsproxy.h> 33 33 #include <linux/pid.h> 34 34 #include <linux/ipc_namespace.h> 35 - #include <linux/ima.h> 36 35 37 36 #include <net/sock.h> 38 37 #include "util.h" ··· 733 734 error = PTR_ERR(filp); 734 735 goto out_putfd; 735 736 } 736 - ima_counts_get(filp); 737 737 738 738 fd_install(fd, filp); 739 739 goto out_upsem;
+5 -7
ipc/shm.c
··· 39 39 #include <linux/nsproxy.h> 40 40 #include <linux/mount.h> 41 41 #include <linux/ipc_namespace.h> 42 - #include <linux/ima.h> 43 42 44 43 #include <asm/uaccess.h> 45 44 ··· 878 879 if (err) 879 880 goto out_unlock; 880 881 881 - path.dentry = dget(shp->shm_file->f_path.dentry); 882 - path.mnt = shp->shm_file->f_path.mnt; 882 + path = shp->shm_file->f_path; 883 + path_get(&path); 883 884 shp->shm_nattch++; 884 885 size = i_size_read(path.dentry->d_inode); 885 886 shm_unlock(shp); ··· 889 890 if (!sfd) 890 891 goto out_put_dentry; 891 892 892 - file = alloc_file(path.mnt, path.dentry, f_mode, 893 - is_file_hugepages(shp->shm_file) ? 893 + file = alloc_file(&path, f_mode, 894 + is_file_hugepages(shp->shm_file) ? 894 895 &shm_file_operations_huge : 895 896 &shm_file_operations); 896 897 if (!file) 897 898 goto out_free; 898 - ima_counts_get(file); 899 899 900 900 file->private_data = sfd; 901 901 file->f_mapping = shp->shm_file->f_mapping; ··· 949 951 out_free: 950 952 kfree(sfd); 951 953 out_put_dentry: 952 - dput(path.dentry); 954 + path_put(&path); 953 955 goto out_nattch; 954 956 } 955 957
-1
mm/Makefile
··· 22 22 obj-$(CONFIG_NUMA) += mempolicy.o 23 23 obj-$(CONFIG_SPARSEMEM) += sparse.o 24 24 obj-$(CONFIG_SPARSEMEM_VMEMMAP) += sparse-vmemmap.o 25 - obj-$(CONFIG_TMPFS_POSIX_ACL) += shmem_acl.o 26 25 obj-$(CONFIG_SLOB) += slob.o 27 26 obj-$(CONFIG_MMU_NOTIFIER) += mmu_notifier.o 28 27 obj-$(CONFIG_KSM) += ksm.o
+1 -14
mm/filemap.c
··· 2240 2240 size_t count, ssize_t written) 2241 2241 { 2242 2242 struct file *file = iocb->ki_filp; 2243 - struct address_space *mapping = file->f_mapping; 2244 2243 ssize_t status; 2245 2244 struct iov_iter i; 2246 2245 ··· 2251 2252 *ppos = pos + status; 2252 2253 } 2253 2254 2254 - /* 2255 - * If we get here for O_DIRECT writes then we must have fallen through 2256 - * to buffered writes (block instantiation inside i_size). So we sync 2257 - * the file data here, to try to honour O_DIRECT expectations. 2258 - */ 2259 - if (unlikely(file->f_flags & O_DIRECT) && written) 2260 - status = filemap_write_and_wait_range(mapping, 2261 - pos, pos + written - 1); 2262 - 2263 2255 return written ? written : status; 2264 2256 } 2265 2257 EXPORT_SYMBOL(generic_file_buffered_write); ··· 2349 2359 * semantics. 2350 2360 */ 2351 2361 endbyte = pos + written_buffered - written - 1; 2352 - err = do_sync_mapping_range(file->f_mapping, pos, endbyte, 2353 - SYNC_FILE_RANGE_WAIT_BEFORE| 2354 - SYNC_FILE_RANGE_WRITE| 2355 - SYNC_FILE_RANGE_WAIT_AFTER); 2362 + err = filemap_write_and_wait_range(file->f_mapping, pos, endbyte); 2356 2363 if (err == 0) { 2357 2364 written = written_buffered; 2358 2365 invalidate_mapping_pages(mapping,
+36 -35
mm/shmem.c
··· 29 29 #include <linux/mm.h> 30 30 #include <linux/module.h> 31 31 #include <linux/swap.h> 32 - #include <linux/ima.h> 33 32 34 33 static struct vfsmount *shm_mnt; 35 34 ··· 41 42 42 43 #include <linux/xattr.h> 43 44 #include <linux/exportfs.h> 45 + #include <linux/posix_acl.h> 44 46 #include <linux/generic_acl.h> 45 47 #include <linux/mman.h> 46 48 #include <linux/string.h> ··· 810 810 error = inode_setattr(inode, attr); 811 811 #ifdef CONFIG_TMPFS_POSIX_ACL 812 812 if (!error && (attr->ia_valid & ATTR_MODE)) 813 - error = generic_acl_chmod(inode, &shmem_acl_ops); 813 + error = generic_acl_chmod(inode); 814 814 #endif 815 815 if (page) 816 816 page_cache_release(page); ··· 1824 1824 return error; 1825 1825 } 1826 1826 } 1827 - error = shmem_acl_init(inode, dir); 1827 + #ifdef CONFIG_TMPFS_POSIX_ACL 1828 + error = generic_acl_init(inode, dir); 1828 1829 if (error) { 1829 1830 iput(inode); 1830 1831 return error; 1831 1832 } 1833 + #endif 1832 1834 if (dir->i_mode & S_ISGID) { 1833 1835 inode->i_gid = dir->i_gid; 1834 1836 if (S_ISDIR(mode)) ··· 2045 2043 * filesystem level, though. 2046 2044 */ 2047 2045 2048 - static size_t shmem_xattr_security_list(struct inode *inode, char *list, 2046 + static size_t shmem_xattr_security_list(struct dentry *dentry, char *list, 2049 2047 size_t list_len, const char *name, 2050 - size_t name_len) 2048 + size_t name_len, int handler_flags) 2051 2049 { 2052 - return security_inode_listsecurity(inode, list, list_len); 2050 + return security_inode_listsecurity(dentry->d_inode, list, list_len); 2053 2051 } 2054 2052 2055 - static int shmem_xattr_security_get(struct inode *inode, const char *name, 2056 - void *buffer, size_t size) 2053 + static int shmem_xattr_security_get(struct dentry *dentry, const char *name, 2054 + void *buffer, size_t size, int handler_flags) 2057 2055 { 2058 2056 if (strcmp(name, "") == 0) 2059 2057 return -EINVAL; 2060 - return xattr_getsecurity(inode, name, buffer, size); 2058 + return xattr_getsecurity(dentry->d_inode, name, buffer, size); 2061 2059 } 2062 2060 2063 - static int shmem_xattr_security_set(struct inode *inode, const char *name, 2064 - const void *value, size_t size, int flags) 2061 + static int shmem_xattr_security_set(struct dentry *dentry, const char *name, 2062 + const void *value, size_t size, int flags, int handler_flags) 2065 2063 { 2066 2064 if (strcmp(name, "") == 0) 2067 2065 return -EINVAL; 2068 - return security_inode_setsecurity(inode, name, value, size, flags); 2066 + return security_inode_setsecurity(dentry->d_inode, name, value, 2067 + size, flags); 2069 2068 } 2070 2069 2071 2070 static struct xattr_handler shmem_xattr_security_handler = { ··· 2077 2074 }; 2078 2075 2079 2076 static struct xattr_handler *shmem_xattr_handlers[] = { 2080 - &shmem_xattr_acl_access_handler, 2081 - &shmem_xattr_acl_default_handler, 2077 + &generic_acl_access_handler, 2078 + &generic_acl_default_handler, 2082 2079 &shmem_xattr_security_handler, 2083 2080 NULL 2084 2081 }; ··· 2457 2454 .getxattr = generic_getxattr, 2458 2455 .listxattr = generic_listxattr, 2459 2456 .removexattr = generic_removexattr, 2460 - .check_acl = shmem_check_acl, 2457 + .check_acl = generic_check_acl, 2461 2458 #endif 2462 2459 2463 2460 }; ··· 2480 2477 .getxattr = generic_getxattr, 2481 2478 .listxattr = generic_listxattr, 2482 2479 .removexattr = generic_removexattr, 2483 - .check_acl = shmem_check_acl, 2480 + .check_acl = generic_check_acl, 2484 2481 #endif 2485 2482 }; 2486 2483 ··· 2491 2488 .getxattr = generic_getxattr, 2492 2489 .listxattr = generic_listxattr, 2493 2490 .removexattr = generic_removexattr, 2494 - .check_acl = shmem_check_acl, 2491 + .check_acl = generic_check_acl, 2495 2492 #endif 2496 2493 }; 2497 2494 ··· 2629 2626 int error; 2630 2627 struct file *file; 2631 2628 struct inode *inode; 2632 - struct dentry *dentry, *root; 2629 + struct path path; 2630 + struct dentry *root; 2633 2631 struct qstr this; 2634 2632 2635 2633 if (IS_ERR(shm_mnt)) ··· 2647 2643 this.len = strlen(name); 2648 2644 this.hash = 0; /* will go */ 2649 2645 root = shm_mnt->mnt_root; 2650 - dentry = d_alloc(root, &this); 2651 - if (!dentry) 2646 + path.dentry = d_alloc(root, &this); 2647 + if (!path.dentry) 2652 2648 goto put_memory; 2653 - 2654 - error = -ENFILE; 2655 - file = get_empty_filp(); 2656 - if (!file) 2657 - goto put_dentry; 2649 + path.mnt = mntget(shm_mnt); 2658 2650 2659 2651 error = -ENOSPC; 2660 2652 inode = shmem_get_inode(root->d_sb, S_IFREG | S_IRWXUGO, 0, flags); 2661 2653 if (!inode) 2662 - goto close_file; 2654 + goto put_dentry; 2663 2655 2664 - d_instantiate(dentry, inode); 2656 + d_instantiate(path.dentry, inode); 2665 2657 inode->i_size = size; 2666 2658 inode->i_nlink = 0; /* It is unlinked */ 2667 - init_file(file, shm_mnt, dentry, FMODE_WRITE | FMODE_READ, 2668 - &shmem_file_operations); 2669 - 2670 2659 #ifndef CONFIG_MMU 2671 2660 error = ramfs_nommu_expand_for_mapping(inode, size); 2672 2661 if (error) 2673 - goto close_file; 2662 + goto put_dentry; 2674 2663 #endif 2675 - ima_counts_get(file); 2664 + 2665 + error = -ENFILE; 2666 + file = alloc_file(&path, FMODE_WRITE | FMODE_READ, 2667 + &shmem_file_operations); 2668 + if (!file) 2669 + goto put_dentry; 2670 + 2676 2671 return file; 2677 2672 2678 - close_file: 2679 - put_filp(file); 2680 2673 put_dentry: 2681 - dput(dentry); 2674 + path_put(&path); 2682 2675 put_memory: 2683 2676 shmem_unacct_size(flags, size); 2684 2677 return ERR_PTR(error);
-171
mm/shmem_acl.c
··· 1 - /* 2 - * mm/shmem_acl.c 3 - * 4 - * (C) 2005 Andreas Gruenbacher <agruen@suse.de> 5 - * 6 - * This file is released under the GPL. 7 - */ 8 - 9 - #include <linux/fs.h> 10 - #include <linux/shmem_fs.h> 11 - #include <linux/xattr.h> 12 - #include <linux/generic_acl.h> 13 - 14 - /** 15 - * shmem_get_acl - generic_acl_operations->getacl() operation 16 - */ 17 - static struct posix_acl * 18 - shmem_get_acl(struct inode *inode, int type) 19 - { 20 - struct posix_acl *acl = NULL; 21 - 22 - spin_lock(&inode->i_lock); 23 - switch(type) { 24 - case ACL_TYPE_ACCESS: 25 - acl = posix_acl_dup(inode->i_acl); 26 - break; 27 - 28 - case ACL_TYPE_DEFAULT: 29 - acl = posix_acl_dup(inode->i_default_acl); 30 - break; 31 - } 32 - spin_unlock(&inode->i_lock); 33 - 34 - return acl; 35 - } 36 - 37 - /** 38 - * shmem_set_acl - generic_acl_operations->setacl() operation 39 - */ 40 - static void 41 - shmem_set_acl(struct inode *inode, int type, struct posix_acl *acl) 42 - { 43 - struct posix_acl *free = NULL; 44 - 45 - spin_lock(&inode->i_lock); 46 - switch(type) { 47 - case ACL_TYPE_ACCESS: 48 - free = inode->i_acl; 49 - inode->i_acl = posix_acl_dup(acl); 50 - break; 51 - 52 - case ACL_TYPE_DEFAULT: 53 - free = inode->i_default_acl; 54 - inode->i_default_acl = posix_acl_dup(acl); 55 - break; 56 - } 57 - spin_unlock(&inode->i_lock); 58 - posix_acl_release(free); 59 - } 60 - 61 - struct generic_acl_operations shmem_acl_ops = { 62 - .getacl = shmem_get_acl, 63 - .setacl = shmem_set_acl, 64 - }; 65 - 66 - /** 67 - * shmem_list_acl_access, shmem_get_acl_access, shmem_set_acl_access, 68 - * shmem_xattr_acl_access_handler - plumbing code to implement the 69 - * system.posix_acl_access xattr using the generic acl functions. 70 - */ 71 - 72 - static size_t 73 - shmem_list_acl_access(struct inode *inode, char *list, size_t list_size, 74 - const char *name, size_t name_len) 75 - { 76 - return generic_acl_list(inode, &shmem_acl_ops, ACL_TYPE_ACCESS, 77 - list, list_size); 78 - } 79 - 80 - static int 81 - shmem_get_acl_access(struct inode *inode, const char *name, void *buffer, 82 - size_t size) 83 - { 84 - if (strcmp(name, "") != 0) 85 - return -EINVAL; 86 - return generic_acl_get(inode, &shmem_acl_ops, ACL_TYPE_ACCESS, buffer, 87 - size); 88 - } 89 - 90 - static int 91 - shmem_set_acl_access(struct inode *inode, const char *name, const void *value, 92 - size_t size, int flags) 93 - { 94 - if (strcmp(name, "") != 0) 95 - return -EINVAL; 96 - return generic_acl_set(inode, &shmem_acl_ops, ACL_TYPE_ACCESS, value, 97 - size); 98 - } 99 - 100 - struct xattr_handler shmem_xattr_acl_access_handler = { 101 - .prefix = POSIX_ACL_XATTR_ACCESS, 102 - .list = shmem_list_acl_access, 103 - .get = shmem_get_acl_access, 104 - .set = shmem_set_acl_access, 105 - }; 106 - 107 - /** 108 - * shmem_list_acl_default, shmem_get_acl_default, shmem_set_acl_default, 109 - * shmem_xattr_acl_default_handler - plumbing code to implement the 110 - * system.posix_acl_default xattr using the generic acl functions. 111 - */ 112 - 113 - static size_t 114 - shmem_list_acl_default(struct inode *inode, char *list, size_t list_size, 115 - const char *name, size_t name_len) 116 - { 117 - return generic_acl_list(inode, &shmem_acl_ops, ACL_TYPE_DEFAULT, 118 - list, list_size); 119 - } 120 - 121 - static int 122 - shmem_get_acl_default(struct inode *inode, const char *name, void *buffer, 123 - size_t size) 124 - { 125 - if (strcmp(name, "") != 0) 126 - return -EINVAL; 127 - return generic_acl_get(inode, &shmem_acl_ops, ACL_TYPE_DEFAULT, buffer, 128 - size); 129 - } 130 - 131 - static int 132 - shmem_set_acl_default(struct inode *inode, const char *name, const void *value, 133 - size_t size, int flags) 134 - { 135 - if (strcmp(name, "") != 0) 136 - return -EINVAL; 137 - return generic_acl_set(inode, &shmem_acl_ops, ACL_TYPE_DEFAULT, value, 138 - size); 139 - } 140 - 141 - struct xattr_handler shmem_xattr_acl_default_handler = { 142 - .prefix = POSIX_ACL_XATTR_DEFAULT, 143 - .list = shmem_list_acl_default, 144 - .get = shmem_get_acl_default, 145 - .set = shmem_set_acl_default, 146 - }; 147 - 148 - /** 149 - * shmem_acl_init - Inizialize the acl(s) of a new inode 150 - */ 151 - int 152 - shmem_acl_init(struct inode *inode, struct inode *dir) 153 - { 154 - return generic_acl_init(inode, dir, &shmem_acl_ops); 155 - } 156 - 157 - /** 158 - * shmem_check_acl - check_acl() callback for generic_permission() 159 - */ 160 - int 161 - shmem_check_acl(struct inode *inode, int mask) 162 - { 163 - struct posix_acl *acl = shmem_get_acl(inode, ACL_TYPE_ACCESS); 164 - 165 - if (acl) { 166 - int error = posix_acl_permission(inode, acl, mask); 167 - posix_acl_release(acl); 168 - return error; 169 - } 170 - return -EAGAIN; 171 - }
+46 -66
net/9p/trans_fd.c
··· 42 42 #include <net/9p/client.h> 43 43 #include <net/9p/transport.h> 44 44 45 + #include <linux/syscalls.h> /* killme */ 46 + 45 47 #define P9_PORT 564 46 48 #define MAX_SOCK_BUF (64*1024) 47 49 #define MAXPOLLWADDR 2 ··· 790 788 791 789 static int p9_socket_open(struct p9_client *client, struct socket *csocket) 792 790 { 793 - int fd, ret; 791 + struct p9_trans_fd *p; 792 + int ret, fd; 793 + 794 + p = kmalloc(sizeof(struct p9_trans_fd), GFP_KERNEL); 795 + if (!p) 796 + return -ENOMEM; 794 797 795 798 csocket->sk->sk_allocation = GFP_NOIO; 796 799 fd = sock_map_fd(csocket, 0); 797 800 if (fd < 0) { 798 801 P9_EPRINTK(KERN_ERR, "p9_socket_open: failed to map fd\n"); 802 + sock_release(csocket); 803 + kfree(p); 799 804 return fd; 800 805 } 801 806 802 - ret = p9_fd_open(client, fd, fd); 803 - if (ret < 0) { 804 - P9_EPRINTK(KERN_ERR, "p9_socket_open: failed to open fd\n"); 807 + get_file(csocket->file); 808 + get_file(csocket->file); 809 + p->wr = p->rd = csocket->file; 810 + client->trans = p; 811 + client->status = Connected; 812 + 813 + sys_close(fd); /* still racy */ 814 + 815 + p->rd->f_flags |= O_NONBLOCK; 816 + 817 + p->conn = p9_conn_create(client); 818 + if (IS_ERR(p->conn)) { 819 + ret = PTR_ERR(p->conn); 820 + p->conn = NULL; 821 + kfree(p); 822 + sockfd_put(csocket); 805 823 sockfd_put(csocket); 806 824 return ret; 807 825 } 808 - 809 - ((struct p9_trans_fd *)client->trans)->rd->f_flags |= O_NONBLOCK; 810 - 811 826 return 0; 812 827 } 813 828 ··· 902 883 struct socket *csocket; 903 884 struct sockaddr_in sin_server; 904 885 struct p9_fd_opts opts; 905 - struct p9_trans_fd *p = NULL; /* this gets allocated in p9_fd_open */ 906 886 907 887 err = parse_opts(args, &opts); 908 888 if (err < 0) ··· 915 897 sin_server.sin_family = AF_INET; 916 898 sin_server.sin_addr.s_addr = in_aton(addr); 917 899 sin_server.sin_port = htons(opts.port); 918 - sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, &csocket); 900 + err = sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, &csocket); 919 901 920 - if (!csocket) { 902 + if (err) { 921 903 P9_EPRINTK(KERN_ERR, "p9_trans_tcp: problem creating socket\n"); 922 - err = -EIO; 923 - goto error; 904 + return err; 924 905 } 925 906 926 907 err = csocket->ops->connect(csocket, ··· 929 912 P9_EPRINTK(KERN_ERR, 930 913 "p9_trans_tcp: problem connecting socket to %s\n", 931 914 addr); 932 - goto error; 933 - } 934 - 935 - err = p9_socket_open(client, csocket); 936 - if (err < 0) 937 - goto error; 938 - 939 - p = (struct p9_trans_fd *) client->trans; 940 - p->conn = p9_conn_create(client); 941 - if (IS_ERR(p->conn)) { 942 - err = PTR_ERR(p->conn); 943 - p->conn = NULL; 944 - goto error; 945 - } 946 - 947 - return 0; 948 - 949 - error: 950 - if (csocket) 951 915 sock_release(csocket); 916 + return err; 917 + } 952 918 953 - kfree(p); 954 - 955 - return err; 919 + return p9_socket_open(client, csocket); 956 920 } 957 921 958 922 static int ··· 942 944 int err; 943 945 struct socket *csocket; 944 946 struct sockaddr_un sun_server; 945 - struct p9_trans_fd *p = NULL; /* this gets allocated in p9_fd_open */ 946 947 947 948 csocket = NULL; 948 949 949 950 if (strlen(addr) > UNIX_PATH_MAX) { 950 951 P9_EPRINTK(KERN_ERR, "p9_trans_unix: address too long: %s\n", 951 952 addr); 952 - err = -ENAMETOOLONG; 953 - goto error; 953 + return -ENAMETOOLONG; 954 954 } 955 955 956 956 sun_server.sun_family = PF_UNIX; 957 957 strcpy(sun_server.sun_path, addr); 958 - sock_create_kern(PF_UNIX, SOCK_STREAM, 0, &csocket); 958 + err = sock_create_kern(PF_UNIX, SOCK_STREAM, 0, &csocket); 959 + if (err < 0) { 960 + P9_EPRINTK(KERN_ERR, "p9_trans_unix: problem creating socket\n"); 961 + return err; 962 + } 959 963 err = csocket->ops->connect(csocket, (struct sockaddr *)&sun_server, 960 964 sizeof(struct sockaddr_un) - 1, 0); 961 965 if (err < 0) { 962 966 P9_EPRINTK(KERN_ERR, 963 967 "p9_trans_unix: problem connecting socket: %s: %d\n", 964 968 addr, err); 965 - goto error; 966 - } 967 - 968 - err = p9_socket_open(client, csocket); 969 - if (err < 0) 970 - goto error; 971 - 972 - p = (struct p9_trans_fd *) client->trans; 973 - p->conn = p9_conn_create(client); 974 - if (IS_ERR(p->conn)) { 975 - err = PTR_ERR(p->conn); 976 - p->conn = NULL; 977 - goto error; 978 - } 979 - 980 - return 0; 981 - 982 - error: 983 - if (csocket) 984 969 sock_release(csocket); 970 + return err; 971 + } 985 972 986 - kfree(p); 987 - return err; 973 + return p9_socket_open(client, csocket); 988 974 } 989 975 990 976 static int ··· 976 994 { 977 995 int err; 978 996 struct p9_fd_opts opts; 979 - struct p9_trans_fd *p = NULL; /* this get allocated in p9_fd_open */ 997 + struct p9_trans_fd *p; 980 998 981 999 parse_opts(args, &opts); 982 1000 ··· 987 1005 988 1006 err = p9_fd_open(client, opts.rfd, opts.wfd); 989 1007 if (err < 0) 990 - goto error; 1008 + return err; 991 1009 992 1010 p = (struct p9_trans_fd *) client->trans; 993 1011 p->conn = p9_conn_create(client); 994 1012 if (IS_ERR(p->conn)) { 995 1013 err = PTR_ERR(p->conn); 996 1014 p->conn = NULL; 997 - goto error; 1015 + fput(p->rd); 1016 + fput(p->wr); 1017 + return err; 998 1018 } 999 1019 1000 1020 return 0; 1001 - 1002 - error: 1003 - kfree(p); 1004 - return err; 1005 1021 } 1006 1022 1007 1023 static struct p9_trans_module p9_tcp_trans = {
+36 -72
net/socket.c
··· 355 355 * but we take care of internal coherence yet. 356 356 */ 357 357 358 - static int sock_alloc_fd(struct file **filep, int flags) 358 + static int sock_alloc_file(struct socket *sock, struct file **f, int flags) 359 359 { 360 + struct qstr name = { .name = "" }; 361 + struct path path; 362 + struct file *file; 360 363 int fd; 361 364 362 365 fd = get_unused_fd_flags(flags); 363 - if (likely(fd >= 0)) { 364 - struct file *file = get_empty_filp(); 366 + if (unlikely(fd < 0)) 367 + return fd; 365 368 366 - *filep = file; 367 - if (unlikely(!file)) { 368 - put_unused_fd(fd); 369 - return -ENFILE; 370 - } 371 - } else 372 - *filep = NULL; 373 - return fd; 374 - } 375 - 376 - static int sock_attach_fd(struct socket *sock, struct file *file, int flags) 377 - { 378 - struct dentry *dentry; 379 - struct qstr name = { .name = "" }; 380 - 381 - dentry = d_alloc(sock_mnt->mnt_sb->s_root, &name); 382 - if (unlikely(!dentry)) 369 + path.dentry = d_alloc(sock_mnt->mnt_sb->s_root, &name); 370 + if (unlikely(!path.dentry)) { 371 + put_unused_fd(fd); 383 372 return -ENOMEM; 373 + } 374 + path.mnt = mntget(sock_mnt); 384 375 385 - dentry->d_op = &sockfs_dentry_operations; 376 + path.dentry->d_op = &sockfs_dentry_operations; 386 377 /* 387 378 * We dont want to push this dentry into global dentry hash table. 388 379 * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED 389 380 * This permits a working /proc/$pid/fd/XXX on sockets 390 381 */ 391 - dentry->d_flags &= ~DCACHE_UNHASHED; 392 - d_instantiate(dentry, SOCK_INODE(sock)); 382 + path.dentry->d_flags &= ~DCACHE_UNHASHED; 383 + d_instantiate(path.dentry, SOCK_INODE(sock)); 384 + SOCK_INODE(sock)->i_fop = &socket_file_ops; 385 + 386 + file = alloc_file(&path, FMODE_READ | FMODE_WRITE, 387 + &socket_file_ops); 388 + if (unlikely(!file)) { 389 + /* drop dentry, keep inode */ 390 + atomic_inc(&path.dentry->d_inode->i_count); 391 + path_put(&path); 392 + put_unused_fd(fd); 393 + return -ENFILE; 394 + } 393 395 394 396 sock->file = file; 395 - init_file(file, sock_mnt, dentry, FMODE_READ | FMODE_WRITE, 396 - &socket_file_ops); 397 - SOCK_INODE(sock)->i_fop = &socket_file_ops; 398 397 file->f_flags = O_RDWR | (flags & O_NONBLOCK); 399 398 file->f_pos = 0; 400 399 file->private_data = sock; 401 400 402 - return 0; 401 + *f = file; 402 + return fd; 403 403 } 404 404 405 405 int sock_map_fd(struct socket *sock, int flags) 406 406 { 407 407 struct file *newfile; 408 - int fd = sock_alloc_fd(&newfile, flags); 408 + int fd = sock_alloc_file(sock, &newfile, flags); 409 409 410 - if (likely(fd >= 0)) { 411 - int err = sock_attach_fd(sock, newfile, flags); 412 - 413 - if (unlikely(err < 0)) { 414 - put_filp(newfile); 415 - put_unused_fd(fd); 416 - return err; 417 - } 410 + if (likely(fd >= 0)) 418 411 fd_install(fd, newfile); 419 - } 412 + 420 413 return fd; 421 414 } 422 415 ··· 1383 1390 if (err < 0) 1384 1391 goto out_release_both; 1385 1392 1386 - fd1 = sock_alloc_fd(&newfile1, flags & O_CLOEXEC); 1393 + fd1 = sock_alloc_file(sock1, &newfile1, flags); 1387 1394 if (unlikely(fd1 < 0)) { 1388 1395 err = fd1; 1389 1396 goto out_release_both; 1390 1397 } 1391 1398 1392 - fd2 = sock_alloc_fd(&newfile2, flags & O_CLOEXEC); 1399 + fd2 = sock_alloc_file(sock2, &newfile2, flags); 1393 1400 if (unlikely(fd2 < 0)) { 1394 1401 err = fd2; 1395 - put_filp(newfile1); 1396 - put_unused_fd(fd1); 1397 - goto out_release_both; 1398 - } 1399 - 1400 - err = sock_attach_fd(sock1, newfile1, flags & O_NONBLOCK); 1401 - if (unlikely(err < 0)) { 1402 - goto out_fd2; 1403 - } 1404 - 1405 - err = sock_attach_fd(sock2, newfile2, flags & O_NONBLOCK); 1406 - if (unlikely(err < 0)) { 1407 1402 fput(newfile1); 1408 - goto out_fd1; 1403 + put_unused_fd(fd1); 1404 + sock_release(sock2); 1405 + goto out; 1409 1406 } 1410 1407 1411 1408 audit_fd_pair(fd1, fd2); ··· 1421 1438 sock_release(sock1); 1422 1439 out: 1423 1440 return err; 1424 - 1425 - out_fd2: 1426 - put_filp(newfile1); 1427 - sock_release(sock1); 1428 - out_fd1: 1429 - put_filp(newfile2); 1430 - sock_release(sock2); 1431 - put_unused_fd(fd1); 1432 - put_unused_fd(fd2); 1433 - goto out; 1434 1441 } 1435 1442 1436 1443 /* ··· 1524 1551 */ 1525 1552 __module_get(newsock->ops->owner); 1526 1553 1527 - newfd = sock_alloc_fd(&newfile, flags & O_CLOEXEC); 1554 + newfd = sock_alloc_file(newsock, &newfile, flags); 1528 1555 if (unlikely(newfd < 0)) { 1529 1556 err = newfd; 1530 1557 sock_release(newsock); 1531 1558 goto out_put; 1532 1559 } 1533 - 1534 - err = sock_attach_fd(newsock, newfile, flags & O_NONBLOCK); 1535 - if (err < 0) 1536 - goto out_fd_simple; 1537 1560 1538 1561 err = security_socket_accept(sock, newsock); 1539 1562 if (err) ··· 1560 1591 fput_light(sock->file, fput_needed); 1561 1592 out: 1562 1593 return err; 1563 - out_fd_simple: 1564 - sock_release(newsock); 1565 - put_filp(newfile); 1566 - put_unused_fd(newfd); 1567 - goto out_put; 1568 1594 out_fd: 1569 1595 fput(newfile); 1570 1596 put_unused_fd(newfd);
-3
security/integrity/ima/ima.h
··· 97 97 98 98 /* iint cache flags */ 99 99 #define IMA_MEASURED 1 100 - #define IMA_IINT_DUMP_STACK 512 101 100 102 101 /* integrity data associated with an inode */ 103 102 struct ima_iint_cache { ··· 127 128 */ 128 129 struct ima_iint_cache *ima_iint_insert(struct inode *inode); 129 130 struct ima_iint_cache *ima_iint_find_get(struct inode *inode); 130 - struct ima_iint_cache *ima_iint_find_insert_get(struct inode *inode); 131 - void ima_iint_delete(struct inode *inode); 132 131 void iint_free(struct kref *kref); 133 132 void iint_rcu_free(struct rcu_head *rcu); 134 133
+13 -68
security/integrity/ima/ima_iint.c
··· 19 19 #include <linux/radix-tree.h> 20 20 #include "ima.h" 21 21 22 - #define ima_iint_delete ima_inode_free 23 - 24 22 RADIX_TREE(ima_iint_store, GFP_ATOMIC); 25 23 DEFINE_SPINLOCK(ima_iint_lock); 26 24 ··· 43 45 return iint; 44 46 } 45 47 46 - /* Allocate memory for the iint associated with the inode 47 - * from the iint_cache slab, initialize the iint, and 48 - * insert it into the radix tree. 49 - * 50 - * On success return a pointer to the iint; on failure return NULL. 48 + /** 49 + * ima_inode_alloc - allocate an iint associated with an inode 50 + * @inode: pointer to the inode 51 51 */ 52 - struct ima_iint_cache *ima_iint_insert(struct inode *inode) 52 + int ima_inode_alloc(struct inode *inode) 53 53 { 54 54 struct ima_iint_cache *iint = NULL; 55 55 int rc = 0; 56 56 57 57 if (!ima_initialized) 58 - return iint; 58 + return 0; 59 + 59 60 iint = kmem_cache_alloc(iint_cache, GFP_NOFS); 60 61 if (!iint) 61 - return iint; 62 + return -ENOMEM; 62 63 63 64 rc = radix_tree_preload(GFP_NOFS); 64 65 if (rc < 0) ··· 67 70 rc = radix_tree_insert(&ima_iint_store, (unsigned long)inode, iint); 68 71 spin_unlock(&ima_iint_lock); 69 72 out: 70 - if (rc < 0) { 73 + if (rc < 0) 71 74 kmem_cache_free(iint_cache, iint); 72 - if (rc == -EEXIST) { 73 - spin_lock(&ima_iint_lock); 74 - iint = radix_tree_lookup(&ima_iint_store, 75 - (unsigned long)inode); 76 - spin_unlock(&ima_iint_lock); 77 - } else 78 - iint = NULL; 79 - } 75 + 80 76 radix_tree_preload_end(); 81 - return iint; 77 + 78 + return rc; 82 79 } 83 - 84 - /** 85 - * ima_inode_alloc - allocate an iint associated with an inode 86 - * @inode: pointer to the inode 87 - * 88 - * Return 0 on success, 1 on failure. 89 - */ 90 - int ima_inode_alloc(struct inode *inode) 91 - { 92 - struct ima_iint_cache *iint; 93 - 94 - if (!ima_initialized) 95 - return 0; 96 - 97 - iint = ima_iint_insert(inode); 98 - if (!iint) 99 - return 1; 100 - return 0; 101 - } 102 - 103 - /* ima_iint_find_insert_get - get the iint associated with an inode 104 - * 105 - * Most insertions are done at inode_alloc, except those allocated 106 - * before late_initcall. When the iint does not exist, allocate it, 107 - * initialize and insert it, and increment the iint refcount. 108 - * 109 - * (Can't initialize at security_initcall before any inodes are 110 - * allocated, got to wait at least until proc_init.) 111 - * 112 - * Return the iint. 113 - */ 114 - struct ima_iint_cache *ima_iint_find_insert_get(struct inode *inode) 115 - { 116 - struct ima_iint_cache *iint = NULL; 117 - 118 - iint = ima_iint_find_get(inode); 119 - if (iint) 120 - return iint; 121 - 122 - iint = ima_iint_insert(inode); 123 - if (iint) 124 - kref_get(&iint->refcount); 125 - 126 - return iint; 127 - } 128 - EXPORT_SYMBOL_GPL(ima_iint_find_insert_get); 129 80 130 81 /* iint_free - called when the iint refcount goes to zero */ 131 82 void iint_free(struct kref *kref) ··· 109 164 } 110 165 111 166 /** 112 - * ima_iint_delete - called on integrity_inode_free 167 + * ima_inode_free - called on security_inode_free 113 168 * @inode: pointer to the inode 114 169 * 115 170 * Free the integrity information(iint) associated with an inode. 116 171 */ 117 - void ima_iint_delete(struct inode *inode) 172 + void ima_inode_free(struct inode *inode) 118 173 { 119 174 struct ima_iint_cache *iint; 120 175
+103 -81
security/integrity/ima/ima_main.c
··· 13 13 * License. 14 14 * 15 15 * File: ima_main.c 16 - * implements the IMA hooks: ima_bprm_check, ima_file_mmap, 17 - * and ima_path_check. 16 + * implements the IMA hooks: ima_bprm_check, ima_file_mmap, 17 + * and ima_path_check. 18 18 */ 19 19 #include <linux/module.h> 20 20 #include <linux/file.h> ··· 35 35 } 36 36 __setup("ima_hash=", hash_setup); 37 37 38 + struct ima_imbalance { 39 + struct hlist_node node; 40 + unsigned long fsmagic; 41 + }; 42 + 43 + /* 44 + * ima_limit_imbalance - emit one imbalance message per filesystem type 45 + * 46 + * Maintain list of filesystem types that do not measure files properly. 47 + * Return false if unknown, true if known. 48 + */ 49 + static bool ima_limit_imbalance(struct file *file) 50 + { 51 + static DEFINE_SPINLOCK(ima_imbalance_lock); 52 + static HLIST_HEAD(ima_imbalance_list); 53 + 54 + struct super_block *sb = file->f_dentry->d_sb; 55 + struct ima_imbalance *entry; 56 + struct hlist_node *node; 57 + bool found = false; 58 + 59 + rcu_read_lock(); 60 + hlist_for_each_entry_rcu(entry, node, &ima_imbalance_list, node) { 61 + if (entry->fsmagic == sb->s_magic) { 62 + found = true; 63 + break; 64 + } 65 + } 66 + rcu_read_unlock(); 67 + if (found) 68 + goto out; 69 + 70 + entry = kmalloc(sizeof(*entry), GFP_NOFS); 71 + if (!entry) 72 + goto out; 73 + entry->fsmagic = sb->s_magic; 74 + spin_lock(&ima_imbalance_lock); 75 + /* 76 + * we could have raced and something else might have added this fs 77 + * to the list, but we don't really care 78 + */ 79 + hlist_add_head_rcu(&entry->node, &ima_imbalance_list); 80 + spin_unlock(&ima_imbalance_lock); 81 + printk(KERN_INFO "IMA: unmeasured files on fsmagic: %lX\n", 82 + entry->fsmagic); 83 + out: 84 + return found; 85 + } 86 + 87 + /* 88 + * Update the counts given an fmode_t 89 + */ 90 + static void ima_inc_counts(struct ima_iint_cache *iint, fmode_t mode) 91 + { 92 + BUG_ON(!mutex_is_locked(&iint->mutex)); 93 + 94 + iint->opencount++; 95 + if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) 96 + iint->readcount++; 97 + if (mode & FMODE_WRITE) 98 + iint->writecount++; 99 + } 100 + 101 + /* 102 + * Decrement ima counts 103 + */ 104 + static void ima_dec_counts(struct ima_iint_cache *iint, struct inode *inode, 105 + struct file *file) 106 + { 107 + mode_t mode = file->f_mode; 108 + BUG_ON(!mutex_is_locked(&iint->mutex)); 109 + 110 + iint->opencount--; 111 + if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) 112 + iint->readcount--; 113 + if (mode & FMODE_WRITE) { 114 + iint->writecount--; 115 + if (iint->writecount == 0) { 116 + if (iint->version != inode->i_version) 117 + iint->flags &= ~IMA_MEASURED; 118 + } 119 + } 120 + 121 + if (((iint->opencount < 0) || 122 + (iint->readcount < 0) || 123 + (iint->writecount < 0)) && 124 + !ima_limit_imbalance(file)) { 125 + printk(KERN_INFO "%s: open/free imbalance (r:%ld w:%ld o:%ld)\n", 126 + __FUNCTION__, iint->readcount, iint->writecount, 127 + iint->opencount); 128 + dump_stack(); 129 + } 130 + } 131 + 38 132 /** 39 133 * ima_file_free - called on __fput() 40 134 * @file: pointer to file structure being freed ··· 148 54 return; 149 55 150 56 mutex_lock(&iint->mutex); 151 - if (iint->opencount <= 0) { 152 - printk(KERN_INFO 153 - "%s: %s open/free imbalance (r:%ld w:%ld o:%ld f:%ld)\n", 154 - __FUNCTION__, file->f_dentry->d_name.name, 155 - iint->readcount, iint->writecount, 156 - iint->opencount, atomic_long_read(&file->f_count)); 157 - if (!(iint->flags & IMA_IINT_DUMP_STACK)) { 158 - dump_stack(); 159 - iint->flags |= IMA_IINT_DUMP_STACK; 160 - } 161 - } 162 - iint->opencount--; 163 - 164 - if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) 165 - iint->readcount--; 166 - 167 - if (file->f_mode & FMODE_WRITE) { 168 - iint->writecount--; 169 - if (iint->writecount == 0) { 170 - if (iint->version != inode->i_version) 171 - iint->flags &= ~IMA_MEASURED; 172 - } 173 - } 57 + ima_dec_counts(iint, inode, file); 174 58 mutex_unlock(&iint->mutex); 175 59 kref_put(&iint->refcount, iint_free); 176 60 } ··· 188 116 { 189 117 int rc = 0; 190 118 191 - iint->opencount++; 192 - iint->readcount++; 119 + ima_inc_counts(iint, file->f_mode); 193 120 194 121 rc = ima_collect_measurement(iint, file); 195 122 if (!rc) 196 123 ima_store_measurement(iint, file, filename); 197 124 return rc; 198 - } 199 - 200 - static void ima_update_counts(struct ima_iint_cache *iint, int mask) 201 - { 202 - iint->opencount++; 203 - if ((mask & MAY_WRITE) || (mask == 0)) 204 - iint->writecount++; 205 - else if (mask & (MAY_READ | MAY_EXEC)) 206 - iint->readcount++; 207 125 } 208 126 209 127 /** ··· 214 152 * Always return 0 and audit dentry_open failures. 215 153 * (Return code will be based upon measurement appraisal.) 216 154 */ 217 - int ima_path_check(struct path *path, int mask, int update_counts) 155 + int ima_path_check(struct path *path, int mask) 218 156 { 219 157 struct inode *inode = path->dentry->d_inode; 220 158 struct ima_iint_cache *iint; ··· 223 161 224 162 if (!ima_initialized || !S_ISREG(inode->i_mode)) 225 163 return 0; 226 - iint = ima_iint_find_insert_get(inode); 164 + iint = ima_iint_find_get(inode); 227 165 if (!iint) 228 166 return 0; 229 167 230 168 mutex_lock(&iint->mutex); 231 - if (update_counts) 232 - ima_update_counts(iint, mask); 233 169 234 170 rc = ima_must_measure(iint, inode, MAY_READ, PATH_CHECK); 235 171 if (rc < 0) ··· 279 219 280 220 if (!ima_initialized || !S_ISREG(inode->i_mode)) 281 221 return 0; 282 - iint = ima_iint_find_insert_get(inode); 222 + iint = ima_iint_find_get(inode); 283 223 if (!iint) 284 224 return -ENOMEM; 285 225 ··· 298 238 } 299 239 300 240 /* 301 - * ima_counts_put - decrement file counts 302 - * 303 - * File counts are incremented in ima_path_check. On file open 304 - * error, such as ETXTBSY, decrement the counts to prevent 305 - * unnecessary imbalance messages. 306 - */ 307 - void ima_counts_put(struct path *path, int mask) 308 - { 309 - struct inode *inode = path->dentry->d_inode; 310 - struct ima_iint_cache *iint; 311 - 312 - /* The inode may already have been freed, freeing the iint 313 - * with it. Verify the inode is not NULL before dereferencing 314 - * it. 315 - */ 316 - if (!ima_initialized || !inode || !S_ISREG(inode->i_mode)) 317 - return; 318 - iint = ima_iint_find_insert_get(inode); 319 - if (!iint) 320 - return; 321 - 322 - mutex_lock(&iint->mutex); 323 - iint->opencount--; 324 - if ((mask & MAY_WRITE) || (mask == 0)) 325 - iint->writecount--; 326 - else if (mask & (MAY_READ | MAY_EXEC)) 327 - iint->readcount--; 328 - mutex_unlock(&iint->mutex); 329 - 330 - kref_put(&iint->refcount, iint_free); 331 - } 332 - 333 - /* 334 241 * ima_counts_get - increment file counts 335 242 * 336 243 * - for IPC shm and shmat file. ··· 313 286 314 287 if (!ima_initialized || !S_ISREG(inode->i_mode)) 315 288 return; 316 - iint = ima_iint_find_insert_get(inode); 289 + iint = ima_iint_find_get(inode); 317 290 if (!iint) 318 291 return; 319 292 mutex_lock(&iint->mutex); 320 - iint->opencount++; 321 - if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) 322 - iint->readcount++; 323 - 324 - if (file->f_mode & FMODE_WRITE) 325 - iint->writecount++; 293 + ima_inc_counts(iint, file->f_mode); 326 294 mutex_unlock(&iint->mutex); 327 295 328 296 kref_put(&iint->refcount, iint_free);