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