1 From: Tony Jones <tonyj@suse.de>
2 Subject: Add a struct vfsmount parameter to vfs_setxattr()
4 The vfsmount will be passed down to the LSM hook so that LSMs can compute
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>
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(-)
17 --- linux-2.6.27.orig/fs/nfsd/vfs.c
18 +++ linux-2.6.27/fs/nfsd/vfs.c
19 @@ -438,7 +438,8 @@ static ssize_t nfsd_getxattr(struct dent
21 #if defined(CONFIG_NFSD_V4)
23 -set_nfsv4_acl_one(struct dentry *dentry, struct posix_acl *pacl, char *key)
24 +set_nfsv4_acl_one(struct dentry *dentry, struct vfsmount *mnt,
25 + struct posix_acl *pacl, char *key)
29 @@ -457,7 +458,7 @@ set_nfsv4_acl_one(struct dentry *dentry,
33 - error = vfs_setxattr(dentry, key, buf, len, 0);
34 + error = vfs_setxattr(dentry, mnt, key, buf, len, 0);
38 @@ -470,6 +471,7 @@ nfsd4_set_nfs4_acl(struct svc_rqst *rqst
41 struct dentry *dentry;
42 + struct vfsmount *mnt;
44 struct posix_acl *pacl = NULL, *dpacl = NULL;
45 unsigned int flags = 0;
46 @@ -480,6 +482,7 @@ nfsd4_set_nfs4_acl(struct svc_rqst *rqst
49 dentry = fhp->fh_dentry;
50 + mnt = fhp->fh_export->ex_path.mnt;
51 inode = dentry->d_inode;
52 if (S_ISDIR(inode->i_mode))
54 @@ -490,12 +493,14 @@ nfsd4_set_nfs4_acl(struct svc_rqst *rqst
55 } else if (host_error < 0)
58 - host_error = set_nfsv4_acl_one(dentry, pacl, POSIX_ACL_XATTR_ACCESS);
59 + host_error = set_nfsv4_acl_one(dentry, mnt, pacl,
60 + POSIX_ACL_XATTR_ACCESS);
64 if (S_ISDIR(inode->i_mode))
65 - host_error = set_nfsv4_acl_one(dentry, dpacl, POSIX_ACL_XATTR_DEFAULT);
66 + host_error = set_nfsv4_acl_one(dentry, mnt, dpacl,
67 + POSIX_ACL_XATTR_DEFAULT);
70 posix_acl_release(pacl);
71 @@ -2123,7 +2128,8 @@ nfsd_set_posix_acl(struct svc_fh *fhp, i
75 - error = vfs_setxattr(fhp->fh_dentry, name, value, size, 0);
76 + error = vfs_setxattr(fhp->fh_dentry, fhp->fh_export->ex_path.mnt,
77 + name, value, size,0);
79 if (!S_ISDIR(inode->i_mode) && type == ACL_TYPE_DEFAULT)
81 --- linux-2.6.27.orig/fs/xattr.c
82 +++ linux-2.6.27/fs/xattr.c
83 @@ -67,8 +67,8 @@ xattr_permission(struct inode *inode, co
87 -vfs_setxattr(struct dentry *dentry, const char *name, const void *value,
88 - size_t size, int flags)
89 +vfs_setxattr(struct dentry *dentry, struct vfsmount *mnt, const char *name,
90 + const void *value, size_t size, int flags)
92 struct inode *inode = dentry->d_inode;
94 @@ -218,8 +218,8 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
95 * Extended attribute SET operations
98 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
99 - size_t size, int flags)
100 +setxattr(struct dentry *dentry, struct vfsmount *mnt, const char __user *name,
101 + const void __user *value, size_t size, int flags)
105 @@ -246,7 +246,7 @@ setxattr(struct dentry *d, const char __
109 - error = vfs_setxattr(d, kname, kvalue, size, flags);
110 + error = vfs_setxattr(dentry, mnt, kname, kvalue, size, flags);
114 @@ -263,7 +263,7 @@ SYSCALL_DEFINE5(setxattr, const char __u
116 error = mnt_want_write(path.mnt);
118 - error = setxattr(path.dentry, name, value, size, flags);
119 + error = setxattr(path.dentry, path.mnt, name, value, size, flags);
120 mnt_drop_write(path.mnt);
123 @@ -282,7 +282,7 @@ SYSCALL_DEFINE5(lsetxattr, const char __
125 error = mnt_want_write(path.mnt);
127 - error = setxattr(path.dentry, name, value, size, flags);
128 + error = setxattr(path.dentry, path.mnt, name, value, size, flags);
129 mnt_drop_write(path.mnt);
132 @@ -303,7 +303,7 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, cons
133 audit_inode(NULL, dentry);
134 error = mnt_want_write_file(f->f_path.mnt, f);
136 - error = setxattr(dentry, name, value, size, flags);
137 + error = setxattr(dentry, f->f_vfsmnt, name, value, size, flags);
138 mnt_drop_write(f->f_path.mnt);
141 --- linux-2.6.27.orig/include/linux/xattr.h
142 +++ linux-2.6.27/include/linux/xattr.h
146 #include <linux/types.h>
147 +#include <linux/mount.h>
150 #define XATTR_OS2_PREFIX "os2."
151 @@ -49,7 +50,7 @@ struct xattr_handler {
152 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
153 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
154 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
155 -int vfs_setxattr(struct dentry *, const char *, const void *, size_t, int);
156 +int vfs_setxattr(struct dentry *, struct vfsmount *, const char *, const void *, size_t, int);
157 int vfs_removexattr(struct dentry *, const char *);
159 ssize_t generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size);