]>
Commit | Line | Data |
---|---|---|
6a930a95 BS |
1 | From: Tony Jones <tonyj@suse.de> |
2 | Subject: Add a struct vfsmount parameter to vfs_setxattr() | |
3 | ||
4 | The vfsmount will be passed down to the LSM hook so that LSMs can compute | |
5 | pathnames. | |
6 | ||
7 | Signed-off-by: Tony Jones <tonyj@suse.de> | |
8 | Signed-off-by: Andreas Gruenbacher <agruen@suse.de> | |
9 | Signed-off-by: John Johansen <jjohansen@suse.de> | |
10 | ||
11 | --- | |
12 | fs/nfsd/vfs.c | 16 +++++++++++----- | |
13 | fs/xattr.c | 16 ++++++++-------- | |
14 | include/linux/xattr.h | 3 ++- | |
15 | 3 files changed, 21 insertions(+), 14 deletions(-) | |
16 | ||
17 | Index: linux-2.6.27/fs/nfsd/vfs.c | |
18 | =================================================================== | |
19 | --- linux-2.6.27.orig/fs/nfsd/vfs.c | |
20 | +++ linux-2.6.27/fs/nfsd/vfs.c | |
21 | @@ -438,7 +438,8 @@ static ssize_t nfsd_getxattr(struct dent | |
22 | ||
23 | #if defined(CONFIG_NFSD_V4) | |
24 | static int | |
25 | -set_nfsv4_acl_one(struct dentry *dentry, struct posix_acl *pacl, char *key) | |
26 | +set_nfsv4_acl_one(struct dentry *dentry, struct vfsmount *mnt, | |
27 | + struct posix_acl *pacl, char *key) | |
28 | { | |
29 | int len; | |
30 | size_t buflen; | |
31 | @@ -457,7 +458,7 @@ set_nfsv4_acl_one(struct dentry *dentry, | |
32 | goto out; | |
33 | } | |
34 | ||
35 | - error = vfs_setxattr(dentry, key, buf, len, 0); | |
36 | + error = vfs_setxattr(dentry, mnt, key, buf, len, 0); | |
37 | out: | |
38 | kfree(buf); | |
39 | return error; | |
40 | @@ -470,6 +471,7 @@ nfsd4_set_nfs4_acl(struct svc_rqst *rqst | |
41 | __be32 error; | |
42 | int host_error; | |
43 | struct dentry *dentry; | |
44 | + struct vfsmount *mnt; | |
45 | struct inode *inode; | |
46 | struct posix_acl *pacl = NULL, *dpacl = NULL; | |
47 | unsigned int flags = 0; | |
48 | @@ -480,6 +482,7 @@ nfsd4_set_nfs4_acl(struct svc_rqst *rqst | |
49 | return error; | |
50 | ||
51 | dentry = fhp->fh_dentry; | |
52 | + mnt = fhp->fh_export->ex_path.mnt; | |
53 | inode = dentry->d_inode; | |
54 | if (S_ISDIR(inode->i_mode)) | |
55 | flags = NFS4_ACL_DIR; | |
56 | @@ -490,12 +493,14 @@ nfsd4_set_nfs4_acl(struct svc_rqst *rqst | |
57 | } else if (host_error < 0) | |
58 | goto out_nfserr; | |
59 | ||
60 | - host_error = set_nfsv4_acl_one(dentry, pacl, POSIX_ACL_XATTR_ACCESS); | |
61 | + host_error = set_nfsv4_acl_one(dentry, mnt, pacl, | |
62 | + POSIX_ACL_XATTR_ACCESS); | |
63 | if (host_error < 0) | |
64 | goto out_release; | |
65 | ||
66 | if (S_ISDIR(inode->i_mode)) | |
67 | - host_error = set_nfsv4_acl_one(dentry, dpacl, POSIX_ACL_XATTR_DEFAULT); | |
68 | + host_error = set_nfsv4_acl_one(dentry, mnt, dpacl, | |
69 | + POSIX_ACL_XATTR_DEFAULT); | |
70 | ||
71 | out_release: | |
72 | posix_acl_release(pacl); | |
73 | @@ -2123,7 +2128,8 @@ nfsd_set_posix_acl(struct svc_fh *fhp, i | |
74 | if (error) | |
75 | goto getout; | |
76 | if (size) | |
77 | - error = vfs_setxattr(fhp->fh_dentry, name, value, size, 0); | |
78 | + error = vfs_setxattr(fhp->fh_dentry, fhp->fh_export->ex_path.mnt, | |
79 | + name, value, size,0); | |
80 | else { | |
81 | if (!S_ISDIR(inode->i_mode) && type == ACL_TYPE_DEFAULT) | |
82 | error = 0; | |
83 | Index: linux-2.6.27/fs/xattr.c | |
84 | =================================================================== | |
85 | --- linux-2.6.27.orig/fs/xattr.c | |
86 | +++ linux-2.6.27/fs/xattr.c | |
87 | @@ -67,8 +67,8 @@ xattr_permission(struct inode *inode, co | |
88 | } | |
89 | ||
90 | int | |
91 | -vfs_setxattr(struct dentry *dentry, const char *name, const void *value, | |
92 | - size_t size, int flags) | |
93 | +vfs_setxattr(struct dentry *dentry, struct vfsmount *mnt, const char *name, | |
94 | + const void *value, size_t size, int flags) | |
95 | { | |
96 | struct inode *inode = dentry->d_inode; | |
97 | int error; | |
98 | @@ -218,8 +218,8 @@ EXPORT_SYMBOL_GPL(vfs_removexattr); | |
99 | * Extended attribute SET operations | |
100 | */ | |
101 | static long | |
102 | -setxattr(struct dentry *d, const char __user *name, const void __user *value, | |
103 | - size_t size, int flags) | |
104 | +setxattr(struct dentry *dentry, struct vfsmount *mnt, const char __user *name, | |
105 | + const void __user *value, size_t size, int flags) | |
106 | { | |
107 | int error; | |
108 | void *kvalue = NULL; | |
109 | @@ -246,7 +246,7 @@ setxattr(struct dentry *d, const char __ | |
110 | } | |
111 | } | |
112 | ||
113 | - error = vfs_setxattr(d, kname, kvalue, size, flags); | |
114 | + error = vfs_setxattr(dentry, mnt, kname, kvalue, size, flags); | |
115 | kfree(kvalue); | |
116 | return error; | |
117 | } | |
118 | @@ -263,7 +263,7 @@ SYSCALL_DEFINE5(setxattr, const char __u | |
119 | return error; | |
120 | error = mnt_want_write(path.mnt); | |
121 | if (!error) { | |
122 | - error = setxattr(path.dentry, name, value, size, flags); | |
123 | + error = setxattr(path.dentry, path.mnt, name, value, size, flags); | |
124 | mnt_drop_write(path.mnt); | |
125 | } | |
126 | path_put(&path); | |
127 | @@ -282,7 +282,7 @@ SYSCALL_DEFINE5(lsetxattr, const char __ | |
128 | return error; | |
129 | error = mnt_want_write(path.mnt); | |
130 | if (!error) { | |
131 | - error = setxattr(path.dentry, name, value, size, flags); | |
132 | + error = setxattr(path.dentry, path.mnt, name, value, size, flags); | |
133 | mnt_drop_write(path.mnt); | |
134 | } | |
135 | path_put(&path); | |
136 | @@ -303,7 +303,7 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, cons | |
137 | audit_inode(NULL, dentry); | |
138 | error = mnt_want_write_file(f->f_path.mnt, f); | |
139 | if (!error) { | |
140 | - error = setxattr(dentry, name, value, size, flags); | |
141 | + error = setxattr(dentry, f->f_vfsmnt, name, value, size, flags); | |
142 | mnt_drop_write(f->f_path.mnt); | |
143 | } | |
144 | fput(f); | |
145 | Index: linux-2.6.27/include/linux/xattr.h | |
146 | =================================================================== | |
147 | --- linux-2.6.27.orig/include/linux/xattr.h | |
148 | +++ linux-2.6.27/include/linux/xattr.h | |
149 | @@ -16,6 +16,7 @@ | |
150 | #ifdef __KERNEL__ | |
151 | ||
152 | #include <linux/types.h> | |
153 | +#include <linux/mount.h> | |
154 | ||
155 | /* Namespaces */ | |
156 | #define XATTR_OS2_PREFIX "os2." | |
157 | @@ -49,7 +50,7 @@ struct xattr_handler { | |
158 | ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t); | |
159 | ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t); | |
160 | ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size); | |
161 | -int vfs_setxattr(struct dentry *, const char *, const void *, size_t, int); | |
162 | +int vfs_setxattr(struct dentry *, struct vfsmount *, const char *, const void *, size_t, int); | |
163 | int vfs_removexattr(struct dentry *, const char *); | |
164 | ||
165 | ssize_t generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size); |