1
Add a vfsmount parameter to notify_change()
3
The vfsmount parameter must be set appropriately for files visibile
4
outside the kernel. Files that are only used in a filesystem (e.g.,
5
reiserfs xattr files) will have a NULL vfsmount.
7
The kernel nfsd also doesn't have the necessary context for client
8
requests. We cannot put it under any pathname based policy, and
9
also set vfsmount to NULL there.
11
The next patch passes the vfsmount to the inode_setattr LSM hook.
13
Signed-off-by: Tony Jones <tonyj@suse.de>
14
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
17
===================================================================
20
@@ -101,7 +101,8 @@ int inode_setattr(struct inode * inode,
22
EXPORT_SYMBOL(inode_setattr);
24
-int notify_change(struct dentry * dentry, struct iattr * attr)
25
+int notify_change(struct dentry *dentry, struct vfsmount *mnt,
28
struct inode *inode = dentry->d_inode;
30
Index: b/include/linux/fs.h
31
===================================================================
32
--- a/include/linux/fs.h
33
+++ b/include/linux/fs.h
34
@@ -1458,8 +1458,8 @@ static inline int break_lease(struct ino
38
-extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs,
40
+extern int do_truncate(struct dentry *, struct vfsmount *, loff_t start,
41
+ unsigned int time_attrs, struct file *filp);
42
extern long do_sys_open(int fdf, const char __user *filename, int flags,
44
extern struct file *filp_open(const char *, int, int);
45
@@ -1612,7 +1612,7 @@ extern int do_remount_sb(struct super_bl
47
extern sector_t bmap(struct inode *, sector_t);
49
-extern int notify_change(struct dentry *, struct iattr *);
50
+extern int notify_change(struct dentry *, struct vfsmount *, struct iattr *);
51
extern int permission(struct inode *, int, struct nameidata *);
52
extern int generic_permission(struct inode *, int,
53
int (*check_acl)(struct inode *, int));
54
Index: b/fs/ecryptfs/inode.c
55
===================================================================
56
--- a/fs/ecryptfs/inode.c
57
+++ b/fs/ecryptfs/inode.c
58
@@ -873,12 +873,14 @@ static int ecryptfs_setattr(struct dentr
61
struct dentry *lower_dentry;
62
+ struct vfsmount *lower_mnt;
64
struct inode *lower_inode;
65
struct ecryptfs_crypt_stat *crypt_stat;
67
crypt_stat = &ecryptfs_inode_to_private(dentry->d_inode)->crypt_stat;
68
lower_dentry = ecryptfs_dentry_to_lower(dentry);
69
+ lower_mnt = ecryptfs_dentry_to_lower_mnt(dentry);
70
inode = dentry->d_inode;
71
lower_inode = ecryptfs_inode_to_lower(inode);
72
if (ia->ia_valid & ATTR_SIZE) {
73
@@ -893,7 +895,7 @@ static int ecryptfs_setattr(struct dentr
77
- rc = notify_change(lower_dentry, ia);
78
+ rc = notify_change(lower_dentry, lower_mnt, ia);
80
fsstack_copy_attr_all(inode, lower_inode, NULL);
82
Index: b/fs/fat/file.c
83
===================================================================
86
@@ -92,7 +92,7 @@ int fat_generic_ioctl(struct inode *inod
89
/* This MUST be done before doing anything irreversible... */
90
- err = notify_change(filp->f_path.dentry, &ia);
91
+ err = notify_change(filp->f_path.dentry, filp->f_path.mnt, &ia);
95
Index: b/fs/hpfs/namei.c
96
===================================================================
99
@@ -426,7 +426,7 @@ again:
100
/*printk("HPFS: truncating file before delete.\n");*/
101
newattrs.ia_size = 0;
102
newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
103
- err = notify_change(dentry, &newattrs);
104
+ err = notify_change(dentry, NULL, &newattrs);
105
put_write_access(inode);
108
Index: b/fs/nfsd/vfs.c
109
===================================================================
112
@@ -358,7 +358,7 @@ nfsd_setattr(struct svc_rqst *rqstp, str
113
err = nfserr_notsync;
114
if (!check_guard || guardtime == inode->i_ctime.tv_sec) {
116
- host_err = notify_change(dentry, iap);
117
+ host_err = notify_change(dentry, fhp->fh_export->ex_mnt, iap);
118
err = nfserrno(host_err);
121
@@ -890,13 +890,13 @@ out:
125
-static void kill_suid(struct dentry *dentry)
126
+static void kill_suid(struct dentry *dentry, struct vfsmount *mnt)
129
ia.ia_valid = ATTR_KILL_SUID | ATTR_KILL_SGID;
131
mutex_lock(&dentry->d_inode->i_mutex);
132
- notify_change(dentry, &ia);
133
+ notify_change(dentry, mnt, &ia);
134
mutex_unlock(&dentry->d_inode->i_mutex);
137
@@ -955,7 +955,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, s
139
/* clear setuid/setgid flag after write */
140
if (host_err >= 0 && (inode->i_mode & (S_ISUID | S_ISGID)))
142
+ kill_suid(dentry, exp->ex_mnt);
144
if (host_err >= 0 && stable) {
145
static ino_t last_ino;
147
===================================================================
150
@@ -194,8 +194,8 @@ out:
154
-int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
156
+int do_truncate(struct dentry *dentry, struct vfsmount *mnt, loff_t length,
157
+ unsigned int time_attrs, struct file *filp)
160
struct iattr newattrs;
161
@@ -212,7 +212,7 @@ int do_truncate(struct dentry *dentry, l
164
mutex_lock(&dentry->d_inode->i_mutex);
165
- err = notify_change(dentry, &newattrs);
166
+ err = notify_change(dentry, mnt, &newattrs);
167
mutex_unlock(&dentry->d_inode->i_mutex);
170
@@ -267,7 +267,7 @@ static long do_sys_truncate(const char _
171
error = locks_verify_truncate(inode, NULL, length);
174
- error = do_truncate(nd.dentry, length, 0, NULL);
175
+ error = do_truncate(nd.dentry, nd.mnt, length, 0, NULL);
177
put_write_access(inode);
179
@@ -319,7 +319,8 @@ static long do_sys_ftruncate(unsigned in
181
error = locks_verify_truncate(inode, file, length);
183
- error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
184
+ error = do_truncate(dentry, file->f_path.mnt, length,
185
+ ATTR_MTIME|ATTR_CTIME, file);
189
@@ -519,7 +520,7 @@ asmlinkage long sys_fchmod(unsigned int
190
mode = inode->i_mode;
191
newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
192
newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
193
- err = notify_change(dentry, &newattrs);
194
+ err = notify_change(dentry, file->f_path.mnt, &newattrs);
195
mutex_unlock(&inode->i_mutex);
198
@@ -554,7 +555,7 @@ asmlinkage long sys_fchmodat(int dfd, co
199
mode = inode->i_mode;
200
newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
201
newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
202
- error = notify_change(nd.dentry, &newattrs);
203
+ error = notify_change(nd.dentry, nd.mnt, &newattrs);
204
mutex_unlock(&inode->i_mutex);
207
@@ -568,7 +569,8 @@ asmlinkage long sys_chmod(const char __u
208
return sys_fchmodat(AT_FDCWD, filename, mode);
211
-static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
212
+static int chown_common(struct dentry * dentry, struct vfsmount *mnt,
213
+ uid_t user, gid_t group)
215
struct inode * inode;
217
@@ -597,7 +599,7 @@ static int chown_common(struct dentry *
218
if (!S_ISDIR(inode->i_mode))
219
newattrs.ia_valid |= ATTR_KILL_SUID|ATTR_KILL_SGID;
220
mutex_lock(&inode->i_mutex);
221
- error = notify_change(dentry, &newattrs);
222
+ error = notify_change(dentry, mnt, &newattrs);
223
mutex_unlock(&inode->i_mutex);
226
@@ -611,7 +613,7 @@ asmlinkage long sys_chown(const char __u
227
error = user_path_walk(filename, &nd);
230
- error = chown_common(nd.dentry, user, group);
231
+ error = chown_common(nd.dentry, nd.mnt, user, group);
235
@@ -631,7 +633,7 @@ asmlinkage long sys_fchownat(int dfd, co
236
error = __user_walk_fd(dfd, filename, follow, &nd);
239
- error = chown_common(nd.dentry, user, group);
240
+ error = chown_common(nd.dentry, nd.mnt, user, group);
244
@@ -645,7 +647,7 @@ asmlinkage long sys_lchown(const char __
245
error = user_path_walk_link(filename, &nd);
248
- error = chown_common(nd.dentry, user, group);
249
+ error = chown_common(nd.dentry, nd.mnt, user, group);
253
@@ -664,7 +666,7 @@ asmlinkage long sys_fchown(unsigned int
255
dentry = file->f_path.dentry;
256
audit_inode(NULL, dentry->d_inode);
257
- error = chown_common(dentry, user, group);
258
+ error = chown_common(dentry, file->f_path.mnt, user, group);
262
Index: b/fs/reiserfs/xattr.c
263
===================================================================
264
--- a/fs/reiserfs/xattr.c
265
+++ b/fs/reiserfs/xattr.c
266
@@ -527,7 +527,7 @@ reiserfs_xattr_set(struct inode *inode,
267
newattrs.ia_size = buffer_size;
268
newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
269
mutex_lock(&xinode->i_mutex);
270
- err = notify_change(fp->f_path.dentry, &newattrs);
271
+ err = notify_change(fp->f_path.dentry, NULL, &newattrs);
275
@@ -867,7 +867,7 @@ reiserfs_chown_xattrs_filler(void *buf,
278
if (!S_ISDIR(xafile->d_inode->i_mode))
279
- err = notify_change(xafile, attrs);
280
+ err = notify_change(xafile, NULL, attrs);
284
@@ -919,7 +919,7 @@ int reiserfs_chown_xattrs(struct inode *
288
- err = notify_change(dir, attrs);
289
+ err = notify_change(dir, NULL, attrs);
293
Index: b/fs/sysfs/file.c
294
===================================================================
295
--- a/fs/sysfs/file.c
296
+++ b/fs/sysfs/file.c
297
@@ -560,7 +560,7 @@ int sysfs_chmod_file(struct kobject *kob
298
newattrs.ia_mode = (mode & S_IALLUGO) |
299
(inode->i_mode & ~S_IALLUGO);
300
newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
301
- res = notify_change(victim, &newattrs);
302
+ res = notify_change(victim, NULL, &newattrs);
303
mutex_unlock(&inode->i_mutex);
307
===================================================================
310
@@ -62,7 +62,7 @@ asmlinkage long sys_utime(char __user *
313
mutex_lock(&inode->i_mutex);
314
- error = notify_change(nd.dentry, &newattrs);
315
+ error = notify_change(nd.dentry, nd.mnt, &newattrs);
316
mutex_unlock(&inode->i_mutex);
319
@@ -115,7 +115,7 @@ long do_utimes(int dfd, char __user *fil
322
mutex_lock(&inode->i_mutex);
323
- error = notify_change(nd.dentry, &newattrs);
324
+ error = notify_change(nd.dentry, nd.mnt, &newattrs);
325
mutex_unlock(&inode->i_mutex);
328
Index: b/mm/filemap.c
329
===================================================================
332
@@ -1877,7 +1877,7 @@ int __remove_suid(struct path *path, int
333
struct iattr newattrs;
335
newattrs.ia_valid = ATTR_FORCE | kill;
336
- return notify_change(path->dentry, &newattrs);
337
+ return notify_change(path->dentry, path->mnt, &newattrs);
340
int remove_suid(struct path *path)
342
===================================================================
345
@@ -1532,7 +1532,8 @@ int do_coredump(long signr, int exit_cod
347
if (!file->f_op->write)
349
- if (!ispipe && do_truncate(file->f_path.dentry, 0, 0, file) != 0)
351
+ do_truncate(file->f_path.dentry, file->f_path.mnt, 0, 0, file) != 0)
354
retval = binfmt->core_dump(signr, regs, file);
356
===================================================================
359
@@ -1580,7 +1580,8 @@ int may_open(struct nameidata *nd, int a
363
- error = do_truncate(dentry, 0, ATTR_MTIME|ATTR_CTIME, NULL);
364
+ error = do_truncate(dentry, nd->mnt, 0,
365
+ ATTR_MTIME|ATTR_CTIME, NULL);
367
put_write_access(inode);
369
Index: b/mm/tiny-shmem.c
370
===================================================================
371
--- a/mm/tiny-shmem.c
372
+++ b/mm/tiny-shmem.c
373
@@ -86,7 +86,7 @@ struct file *shmem_file_setup(char *name
374
file->f_mode = FMODE_WRITE | FMODE_READ;
376
/* notify everyone as to the change of file size */
377
- error = do_truncate(dentry, size, 0, file);
378
+ error = do_truncate(dentry, file->f_path.mnt, size, 0, file);