1
From: Tony Jones <tonyj@suse.de>
2
Subject: Add a vfsmount parameter to notify_change()
4
The vfsmount parameter must be set appropriately for files visibile
5
outside the kernel. Files that are only used in a filesystem (e.g.,
6
reiserfs xattr files) will have a NULL vfsmount.
8
Signed-off-by: Tony Jones <tonyj@suse.de>
9
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
10
Signed-off-by: John Johansen <jjohansen@suse.de>
14
fs/ecryptfs/inode.c | 4 +++-
16
fs/hpfs/namei.c | 2 +-
18
fs/nfsd/vfs.c | 8 ++++----
19
fs/open.c | 28 +++++++++++++++-------------
20
fs/reiserfs/xattr.c | 6 +++---
22
include/linux/fs.h | 6 +++---
24
11 files changed, 36 insertions(+), 30 deletions(-)
28
@@ -100,7 +100,8 @@ int inode_setattr(struct inode * inode,
30
EXPORT_SYMBOL(inode_setattr);
32
-int notify_change(struct dentry * dentry, struct iattr * attr)
33
+int notify_change(struct dentry *dentry, struct vfsmount *mnt,
36
struct inode *inode = dentry->d_inode;
37
mode_t mode = inode->i_mode;
38
--- a/fs/ecryptfs/inode.c
39
+++ b/fs/ecryptfs/inode.c
40
@@ -849,6 +849,7 @@ static int ecryptfs_setattr(struct dentr
43
struct dentry *lower_dentry;
44
+ struct vfsmount *lower_mnt;
46
struct inode *lower_inode;
47
struct ecryptfs_crypt_stat *crypt_stat;
48
@@ -859,6 +860,7 @@ static int ecryptfs_setattr(struct dentr
49
inode = dentry->d_inode;
50
lower_inode = ecryptfs_inode_to_lower(inode);
51
lower_dentry = ecryptfs_dentry_to_lower(dentry);
52
+ lower_mnt = ecryptfs_dentry_to_lower_mnt(dentry);
53
mutex_lock(&crypt_stat->cs_mutex);
54
if (S_ISDIR(dentry->d_inode->i_mode))
55
crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED);
56
@@ -910,7 +912,7 @@ static int ecryptfs_setattr(struct dentr
57
ia->ia_valid &= ~ATTR_MODE;
59
mutex_lock(&lower_dentry->d_inode->i_mutex);
60
- rc = notify_change(lower_dentry, ia);
61
+ rc = notify_change(lower_dentry, lower_mnt, ia);
62
mutex_unlock(&lower_dentry->d_inode->i_mutex);
64
fsstack_copy_attr_all(inode, lower_inode, NULL);
67
@@ -1821,7 +1821,8 @@ int do_coredump(long signr, int exit_cod
69
if (!file->f_op->write)
71
- if (!ispipe && do_truncate(file->f_path.dentry, 0, 0, file) != 0)
73
+ do_truncate(file->f_path.dentry, file->f_path.mnt, 0, 0, file) != 0)
76
retval = binfmt->core_dump(signr, regs, file, core_limit);
79
@@ -426,7 +426,7 @@ again:
80
/*printk("HPFS: truncating file before delete.\n");*/
82
newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
83
- err = notify_change(dentry, &newattrs);
84
+ err = notify_change(dentry, NULL, &newattrs);
85
put_write_access(inode);
90
@@ -1557,7 +1557,7 @@ int may_open(struct nameidata *nd, int a
94
- error = do_truncate(dentry, 0,
95
+ error = do_truncate(dentry, nd->path.mnt, 0,
96
ATTR_MTIME|ATTR_CTIME|ATTR_OPEN,
101
@@ -387,7 +387,7 @@ nfsd_setattr(struct svc_rqst *rqstp, str
102
err = nfserr_notsync;
103
if (!check_guard || guardtime == inode->i_ctime.tv_sec) {
105
- host_err = notify_change(dentry, iap);
106
+ host_err = notify_change(dentry, fhp->fh_export->ex_path.mnt, iap);
107
err = nfserrno(host_err);
110
@@ -947,13 +947,13 @@ out:
114
-static void kill_suid(struct dentry *dentry)
115
+static void kill_suid(struct dentry *dentry, struct vfsmount *mnt)
118
ia.ia_valid = ATTR_KILL_SUID | ATTR_KILL_SGID | ATTR_KILL_PRIV;
120
mutex_lock(&dentry->d_inode->i_mutex);
121
- notify_change(dentry, &ia);
122
+ notify_change(dentry, mnt, &ia);
123
mutex_unlock(&dentry->d_inode->i_mutex);
126
@@ -1012,7 +1012,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, s
128
/* clear setuid/setgid flag after write */
129
if (host_err >= 0 && (inode->i_mode & (S_ISUID | S_ISGID)))
131
+ kill_suid(dentry, exp->ex_path.mnt);
133
if (host_err >= 0 && stable) {
134
static ino_t last_ino;
137
@@ -197,8 +197,8 @@ out:
141
-int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
143
+int do_truncate(struct dentry *dentry, struct vfsmount *mnt, loff_t length,
144
+ unsigned int time_attrs, struct file *filp)
147
struct iattr newattrs;
148
@@ -218,7 +218,7 @@ int do_truncate(struct dentry *dentry, l
149
newattrs.ia_valid |= should_remove_suid(dentry);
151
mutex_lock(&dentry->d_inode->i_mutex);
152
- err = notify_change(dentry, &newattrs);
153
+ err = notify_change(dentry, mnt, &newattrs);
154
mutex_unlock(&dentry->d_inode->i_mutex);
157
@@ -274,7 +274,7 @@ static long do_sys_truncate(const char _
158
error = locks_verify_truncate(inode, NULL, length);
161
- error = do_truncate(path.dentry, length, 0, NULL);
162
+ error = do_truncate(path.dentry, path.mnt, length, 0, NULL);
166
@@ -329,7 +329,8 @@ static long do_sys_ftruncate(unsigned in
168
error = locks_verify_truncate(inode, file, length);
170
- error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
171
+ error = do_truncate(dentry, file->f_path.mnt, length,
172
+ ATTR_MTIME|ATTR_CTIME, file);
176
@@ -605,7 +606,7 @@ asmlinkage long sys_fchmod(unsigned int
177
mode = inode->i_mode;
178
newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
179
newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
180
- err = notify_change(dentry, &newattrs);
181
+ err = notify_change(dentry, file->f_path.mnt, &newattrs);
182
mutex_unlock(&inode->i_mutex);
183
mnt_drop_write(file->f_path.mnt);
185
@@ -635,7 +636,7 @@ asmlinkage long sys_fchmodat(int dfd, co
186
mode = inode->i_mode;
187
newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
188
newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
189
- error = notify_change(path.dentry, &newattrs);
190
+ error = notify_change(path.dentry, path.mnt, &newattrs);
191
mutex_unlock(&inode->i_mutex);
192
mnt_drop_write(path.mnt);
194
@@ -649,7 +650,8 @@ asmlinkage long sys_chmod(const char __u
195
return sys_fchmodat(AT_FDCWD, filename, mode);
198
-static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
199
+static int chown_common(struct dentry * dentry, struct vfsmount *mnt,
200
+ uid_t user, gid_t group)
202
struct inode *inode = dentry->d_inode;
204
@@ -668,7 +670,7 @@ static int chown_common(struct dentry *
206
ATTR_KILL_SUID | ATTR_KILL_SGID | ATTR_KILL_PRIV;
207
mutex_lock(&inode->i_mutex);
208
- error = notify_change(dentry, &newattrs);
209
+ error = notify_change(dentry, mnt, &newattrs);
210
mutex_unlock(&inode->i_mutex);
213
@@ -685,7 +687,7 @@ asmlinkage long sys_chown(const char __u
214
error = mnt_want_write(path.mnt);
217
- error = chown_common(path.dentry, user, group);
218
+ error = chown_common(path.dentry, path.mnt, user, group);
219
mnt_drop_write(path.mnt);
222
@@ -710,7 +712,7 @@ asmlinkage long sys_fchownat(int dfd, co
223
error = mnt_want_write(path.mnt);
226
- error = chown_common(path.dentry, user, group);
227
+ error = chown_common(path.dentry, path.mnt, user, group);
228
mnt_drop_write(path.mnt);
231
@@ -729,7 +731,7 @@ asmlinkage long sys_lchown(const char __
232
error = mnt_want_write(path.mnt);
235
- error = chown_common(path.dentry, user, group);
236
+ error = chown_common(path.dentry, path.mnt, user, group);
237
mnt_drop_write(path.mnt);
240
@@ -753,7 +755,7 @@ asmlinkage long sys_fchown(unsigned int
242
dentry = file->f_path.dentry;
243
audit_inode(NULL, dentry);
244
- error = chown_common(dentry, user, group);
245
+ error = chown_common(dentry, file->f_path.mnt, user, group);
246
mnt_drop_write(file->f_path.mnt);
249
--- a/fs/reiserfs/xattr.c
250
+++ b/fs/reiserfs/xattr.c
251
@@ -459,7 +459,7 @@ reiserfs_xattr_set(struct inode *inode,
252
newattrs.ia_size = buffer_size;
253
newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
254
mutex_lock_nested(&xinode->i_mutex, I_MUTEX_XATTR);
255
- err = notify_change(dentry, &newattrs);
256
+ err = notify_change(dentry, NULL, &newattrs);
260
@@ -790,7 +790,7 @@ reiserfs_chown_xattrs_filler(void *buf,
263
if (!S_ISDIR(xafile->d_inode->i_mode))
264
- err = notify_change(xafile, attrs);
265
+ err = notify_change(xafile, NULL, attrs);
269
@@ -834,7 +834,7 @@ int reiserfs_chown_xattrs(struct inode *
273
- err = notify_change(dir, attrs);
274
+ err = notify_change(dir, NULL, attrs);
280
@@ -102,7 +102,7 @@ static int utimes_common(struct path *pa
283
mutex_lock(&inode->i_mutex);
284
- error = notify_change(path->dentry, &newattrs);
285
+ error = notify_change(path->dentry, path->mnt, &newattrs);
286
mutex_unlock(&inode->i_mutex);
288
mnt_drop_write_and_out:
289
--- a/include/linux/fs.h
290
+++ b/include/linux/fs.h
291
@@ -1669,8 +1669,8 @@ static inline int break_lease(struct ino
295
-extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs,
296
- struct file *filp);
297
+extern int do_truncate(struct dentry *, struct vfsmount *, loff_t start,
298
+ unsigned int time_attrs, struct file *filp);
299
extern long do_sys_open(int dfd, const char __user *filename, int flags,
301
extern struct file *filp_open(const char *, int, int);
302
@@ -1830,7 +1830,7 @@ extern int do_remount_sb(struct super_bl
304
extern sector_t bmap(struct inode *, sector_t);
306
-extern int notify_change(struct dentry *, struct iattr *);
307
+extern int notify_change(struct dentry *, struct vfsmount *, struct iattr *);
308
extern int inode_permission(struct inode *, int);
309
extern int generic_permission(struct inode *, int,
310
int (*check_acl)(struct inode *, int));
313
@@ -1778,7 +1778,7 @@ static int __remove_suid(struct path *pa
314
struct iattr newattrs;
316
newattrs.ia_valid = ATTR_FORCE | kill;
317
- return notify_change(path->dentry, &newattrs);
318
+ return notify_change(path->dentry, path->mnt, &newattrs);
321
int file_remove_suid(struct file *file)