apparmor/kernel-patches/for-mainline/vfs-notify_change.diff

400 lines
12 KiB
Diff
Raw Normal View History

2007-04-05 10:04:00 +00:00
From: Tony Jones <tonyj@suse.de>
Subject: Add a vfsmount parameter to notify_change()
The vfsmount parameter must be set appropriately for files visibile
outside the kernel. Files that are only used in a filesystem (e.g.,
reiserfs xattr files) will have a NULL vfsmount.
Signed-off-by: Tony Jones <tonyj@suse.de>
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
Signed-off-by: John Johansen <jjohansen@suse.de>
2007-04-05 10:04:00 +00:00
---
fs/attr.c | 3 ++-
fs/ecryptfs/inode.c | 4 +++-
fs/exec.c | 3 ++-
fs/fat/file.c | 2 +-
fs/hpfs/namei.c | 2 +-
2007-11-19 23:18:48 +00:00
fs/namei.c | 2 +-
2007-04-05 10:04:00 +00:00
fs/nfsd/vfs.c | 8 ++++----
fs/open.c | 28 +++++++++++++++-------------
fs/reiserfs/xattr.c | 6 +++---
fs/sysfs/file.c | 2 +-
2008-07-02 20:24:33 +00:00
fs/utimes.c | 17 +++++++----------
2007-04-05 10:04:00 +00:00
include/linux/fs.h | 6 +++---
mm/filemap.c | 2 +-
mm/tiny-shmem.c | 2 +-
2008-07-02 20:24:33 +00:00
14 files changed, 45 insertions(+), 42 deletions(-)
2007-04-05 10:04:00 +00:00
--- a/fs/attr.c
+++ b/fs/attr.c
2007-05-09 12:51:20 +00:00
@@ -100,7 +100,8 @@ int inode_setattr(struct inode * inode,
}
EXPORT_SYMBOL(inode_setattr);
-int notify_change(struct dentry * dentry, struct iattr * attr)
+int notify_change(struct dentry *dentry, struct vfsmount *mnt,
+ struct iattr *attr)
{
struct inode *inode = dentry->d_inode;
2007-11-19 23:18:48 +00:00
mode_t mode = inode->i_mode;
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
2008-07-02 20:24:33 +00:00
@@ -843,6 +843,7 @@ static int ecryptfs_setattr(struct dentr
{
int rc = 0;
struct dentry *lower_dentry;
+ struct vfsmount *lower_mnt;
struct inode *inode;
struct inode *lower_inode;
struct ecryptfs_crypt_stat *crypt_stat;
2008-07-02 20:24:33 +00:00
@@ -853,6 +854,7 @@ static int ecryptfs_setattr(struct dentr
inode = dentry->d_inode;
lower_inode = ecryptfs_inode_to_lower(inode);
2007-07-03 11:56:24 +00:00
lower_dentry = ecryptfs_dentry_to_lower(dentry);
+ lower_mnt = ecryptfs_dentry_to_lower_mnt(dentry);
mutex_lock(&crypt_stat->cs_mutex);
if (S_ISDIR(dentry->d_inode->i_mode))
crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED);
2008-07-02 20:24:33 +00:00
@@ -904,7 +906,7 @@ static int ecryptfs_setattr(struct dentr
2007-11-19 23:18:48 +00:00
ia->ia_valid &= ~ATTR_MODE;
2008-07-02 20:24:33 +00:00
mutex_lock(&lower_dentry->d_inode->i_mutex);
- rc = notify_change(lower_dentry, ia);
+ rc = notify_change(lower_dentry, lower_mnt, ia);
2008-07-02 20:24:33 +00:00
mutex_unlock(&lower_dentry->d_inode->i_mutex);
out:
fsstack_copy_attr_all(inode, lower_inode, NULL);
2007-04-05 10:04:00 +00:00
--- a/fs/exec.c
+++ b/fs/exec.c
2008-07-02 20:24:33 +00:00
@@ -1772,7 +1772,8 @@ int do_coredump(long signr, int exit_cod
2007-04-05 10:04:00 +00:00
goto close_fail;
if (!file->f_op->write)
goto close_fail;
- if (!ispipe && do_truncate(file->f_path.dentry, 0, 0, file) != 0)
+ if (!ispipe &&
+ do_truncate(file->f_path.dentry, file->f_path.mnt, 0, 0, file) != 0)
goto close_fail;
2007-11-19 23:18:48 +00:00
retval = binfmt->core_dump(signr, regs, file, core_limit);
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -92,7 +92,7 @@ int fat_generic_ioctl(struct inode *inod
}
/* This MUST be done before doing anything irreversible... */
- err = notify_change(filp->f_path.dentry, &ia);
+ err = notify_change(filp->f_path.dentry, filp->f_path.mnt, &ia);
if (err)
goto up;
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -426,7 +426,7 @@ again:
/*printk("HPFS: truncating file before delete.\n");*/
newattrs.ia_size = 0;
newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
- err = notify_change(dentry, &newattrs);
+ err = notify_change(dentry, NULL, &newattrs);
put_write_access(inode);
if (!err)
goto again;
2007-04-05 10:04:00 +00:00
--- a/fs/namei.c
+++ b/fs/namei.c
2008-07-02 20:24:33 +00:00
@@ -1666,7 +1666,7 @@ int may_open(struct nameidata *nd, int a
2007-04-05 10:04:00 +00:00
if (!error) {
DQUOT_INIT(inode);
2007-11-19 23:18:48 +00:00
- error = do_truncate(dentry, 0,
2008-07-02 20:24:33 +00:00
+ error = do_truncate(dentry, nd->path.mnt, 0,
2007-11-19 23:18:48 +00:00
ATTR_MTIME|ATTR_CTIME|ATTR_OPEN,
NULL);
2007-04-05 10:04:00 +00:00
}
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
2008-07-02 20:24:33 +00:00
@@ -387,7 +387,7 @@ nfsd_setattr(struct svc_rqst *rqstp, str
err = nfserr_notsync;
if (!check_guard || guardtime == inode->i_ctime.tv_sec) {
fh_lock(fhp);
- host_err = notify_change(dentry, iap);
2008-07-02 20:24:33 +00:00
+ host_err = notify_change(dentry, fhp->fh_export->ex_path.mnt, iap);
err = nfserrno(host_err);
fh_unlock(fhp);
}
2007-11-19 23:18:48 +00:00
@@ -943,13 +943,13 @@ out:
return err;
}
-static void kill_suid(struct dentry *dentry)
+static void kill_suid(struct dentry *dentry, struct vfsmount *mnt)
{
struct iattr ia;
2007-11-19 23:18:48 +00:00
ia.ia_valid = ATTR_KILL_SUID | ATTR_KILL_SGID | ATTR_KILL_PRIV;
mutex_lock(&dentry->d_inode->i_mutex);
- notify_change(dentry, &ia);
+ notify_change(dentry, mnt, &ia);
mutex_unlock(&dentry->d_inode->i_mutex);
}
2007-11-19 23:18:48 +00:00
@@ -1008,7 +1008,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, s
/* clear setuid/setgid flag after write */
if (host_err >= 0 && (inode->i_mode & (S_ISUID | S_ISGID)))
- kill_suid(dentry);
2008-07-02 20:24:33 +00:00
+ kill_suid(dentry, exp->ex_path.mnt);
if (host_err >= 0 && stable) {
static ino_t last_ino;
--- a/fs/open.c
+++ b/fs/open.c
2008-07-02 20:24:33 +00:00
@@ -195,8 +195,8 @@ out:
return error;
}
-int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
- struct file *filp)
+int do_truncate(struct dentry *dentry, struct vfsmount *mnt, loff_t length,
+ unsigned int time_attrs, struct file *filp)
{
int err;
struct iattr newattrs;
2008-07-02 20:24:33 +00:00
@@ -216,7 +216,7 @@ int do_truncate(struct dentry *dentry, l
2007-05-09 12:51:20 +00:00
newattrs.ia_valid |= should_remove_suid(dentry);
mutex_lock(&dentry->d_inode->i_mutex);
- err = notify_change(dentry, &newattrs);
+ err = notify_change(dentry, mnt, &newattrs);
mutex_unlock(&dentry->d_inode->i_mutex);
return err;
}
2008-07-02 20:24:33 +00:00
@@ -272,7 +272,7 @@ static long do_sys_truncate(const char _
error = locks_verify_truncate(inode, NULL, length);
if (!error) {
DQUOT_INIT(inode);
2008-07-02 20:24:33 +00:00
- error = do_truncate(nd.path.dentry, length, 0, NULL);
+ error = do_truncate(nd.path.dentry, nd.path.mnt, length, 0, NULL);
}
2007-11-19 23:18:48 +00:00
put_write_and_out:
2008-07-02 20:24:33 +00:00
@@ -327,7 +327,8 @@ static long do_sys_ftruncate(unsigned in
error = locks_verify_truncate(inode, file, length);
if (!error)
- error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
+ error = do_truncate(dentry, file->f_path.mnt, length,
+ ATTR_MTIME|ATTR_CTIME, file);
out_putf:
fput(file);
out:
2008-07-02 20:24:33 +00:00
@@ -590,7 +591,7 @@ asmlinkage long sys_fchmod(unsigned int
mode = inode->i_mode;
newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
- err = notify_change(dentry, &newattrs);
+ err = notify_change(dentry, file->f_path.mnt, &newattrs);
mutex_unlock(&inode->i_mutex);
2008-07-02 20:24:33 +00:00
out_drop_write:
@@ -627,7 +628,7 @@ asmlinkage long sys_fchmodat(int dfd, co
mode = inode->i_mode;
newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
2008-07-02 20:24:33 +00:00
- error = notify_change(nd.path.dentry, &newattrs);
+ error = notify_change(nd.path.dentry, nd.path.mnt, &newattrs);
mutex_unlock(&inode->i_mutex);
2008-07-02 20:24:33 +00:00
out_drop_write:
@@ -643,7 +644,8 @@ asmlinkage long sys_chmod(const char __u
return sys_fchmodat(AT_FDCWD, filename, mode);
}
-static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
+static int chown_common(struct dentry * dentry, struct vfsmount *mnt,
+ uid_t user, gid_t group)
{
struct inode * inode;
int error;
2008-07-02 20:24:33 +00:00
@@ -670,7 +672,7 @@ static int chown_common(struct dentry *
2007-11-19 23:18:48 +00:00
newattrs.ia_valid |=
ATTR_KILL_SUID | ATTR_KILL_SGID | ATTR_KILL_PRIV;
mutex_lock(&inode->i_mutex);
- error = notify_change(dentry, &newattrs);
+ error = notify_change(dentry, mnt, &newattrs);
mutex_unlock(&inode->i_mutex);
out:
return error;
2008-07-02 20:24:33 +00:00
@@ -687,7 +689,7 @@ asmlinkage long sys_chown(const char __u
error = mnt_want_write(nd.path.mnt);
if (error)
2008-07-02 20:24:33 +00:00
goto out_release;
- error = chown_common(nd.path.dentry, user, group);
+ error = chown_common(nd.path.dentry, nd.path.mnt, user, group);
mnt_drop_write(nd.path.mnt);
out_release:
path_put(&nd.path);
@@ -712,7 +714,7 @@ asmlinkage long sys_fchownat(int dfd, co
error = mnt_want_write(nd.path.mnt);
if (error)
2008-07-02 20:24:33 +00:00
goto out_release;
- error = chown_common(nd.path.dentry, user, group);
+ error = chown_common(nd.path.dentry, nd.path.mnt, user, group);
mnt_drop_write(nd.path.mnt);
out_release:
path_put(&nd.path);
@@ -731,7 +733,7 @@ asmlinkage long sys_lchown(const char __
error = mnt_want_write(nd.path.mnt);
if (error)
2008-07-02 20:24:33 +00:00
goto out_release;
- error = chown_common(nd.path.dentry, user, group);
+ error = chown_common(nd.path.dentry, nd.path.mnt, user, group);
mnt_drop_write(nd.path.mnt);
out_release:
path_put(&nd.path);
@@ -755,7 +757,7 @@ asmlinkage long sys_fchown(unsigned int
goto out_fput;
dentry = file->f_path.dentry;
2007-11-19 23:18:48 +00:00
audit_inode(NULL, dentry);
- error = chown_common(dentry, user, group);
+ error = chown_common(dentry, file->f_path.mnt, user, group);
2008-07-02 20:24:33 +00:00
mnt_drop_write(file->f_path.mnt);
out_fput:
fput(file);
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
2008-07-02 20:24:33 +00:00
@@ -459,7 +459,7 @@ reiserfs_xattr_set(struct inode *inode,
newattrs.ia_size = buffer_size;
newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
2007-11-19 23:18:48 +00:00
mutex_lock_nested(&xinode->i_mutex, I_MUTEX_XATTR);
2008-07-02 20:24:33 +00:00
- err = notify_change(dentry, &newattrs);
+ err = notify_change(dentry, NULL, &newattrs);
if (err)
goto out_filp;
2008-07-02 20:24:33 +00:00
@@ -790,7 +790,7 @@ reiserfs_chown_xattrs_filler(void *buf,
}
if (!S_ISDIR(xafile->d_inode->i_mode))
- err = notify_change(xafile, attrs);
2008-07-02 20:24:33 +00:00
+ err = notify_change(xafile, NULL, attrs);
dput(xafile);
return err;
2008-07-02 20:24:33 +00:00
@@ -834,7 +834,7 @@ int reiserfs_chown_xattrs(struct inode *
goto out_dir;
}
- err = notify_change(dir, attrs);
+ err = notify_change(dir, NULL, attrs);
unlock_kernel();
out_dir:
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
2008-07-02 20:24:33 +00:00
@@ -585,7 +585,7 @@ int sysfs_chmod_file(struct kobject *kob
2007-11-19 23:18:48 +00:00
newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
- rc = notify_change(victim, &newattrs);
+ rc = notify_change(victim, NULL, &newattrs);
2007-11-19 23:18:48 +00:00
if (rc == 0) {
mutex_lock(&sysfs_mutex);
--- a/fs/utimes.c
+++ b/fs/utimes.c
2008-07-02 20:24:33 +00:00
@@ -56,11 +56,10 @@ long do_utimes(int dfd, char __user *fil
2007-05-09 12:51:20 +00:00
{
int error;
struct nameidata nd;
- struct dentry *dentry;
+ struct path path;
struct inode *inode;
struct iattr newattrs;
struct file *f = NULL;
2008-07-02 20:24:33 +00:00
- struct vfsmount *mnt;
error = -EINVAL;
if (times && (!nsec_valid(times[0].tv_nsec) ||
@@ -80,20 +79,18 @@ long do_utimes(int dfd, char __user *fil
2007-05-09 12:51:20 +00:00
f = fget(dfd);
if (!f)
goto out;
- dentry = f->f_path.dentry;
2008-07-02 20:24:33 +00:00
- mnt = f->f_path.mnt;
2007-05-09 12:51:20 +00:00
+ path = f->f_path;
} else {
error = __user_walk_fd(dfd, filename, (flags & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW, &nd);
if (error)
goto out;
2008-07-02 20:24:33 +00:00
- dentry = nd.path.dentry;
- mnt = nd.path.mnt;
+ path = nd.path;
}
2007-05-09 12:51:20 +00:00
- inode = dentry->d_inode;
+ inode = path.dentry->d_inode;
2008-07-02 20:24:33 +00:00
- error = mnt_want_write(mnt);
+ error = mnt_want_write(path.mnt);
if (error)
goto dput_and_out;
@@ -154,10 +151,10 @@ long do_utimes(int dfd, char __user *fil
}
}
mutex_lock(&inode->i_mutex);
2007-05-09 12:51:20 +00:00
- error = notify_change(dentry, &newattrs);
+ error = notify_change(path.dentry, path.mnt, &newattrs);
mutex_unlock(&inode->i_mutex);
2008-07-02 20:24:33 +00:00
mnt_drop_write_and_out:
- mnt_drop_write(mnt);
+ mnt_drop_write(path.mnt);
dput_and_out:
2007-05-09 12:51:20 +00:00
if (f)
2008-07-02 20:24:33 +00:00
fput(f);
2007-04-05 10:04:00 +00:00
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
2008-07-02 20:24:33 +00:00
@@ -1596,8 +1596,8 @@ static inline int break_lease(struct ino
2007-04-05 10:04:00 +00:00
/* fs/open.c */
-extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs,
- struct file *filp);
+extern int do_truncate(struct dentry *, struct vfsmount *, loff_t start,
+ unsigned int time_attrs, struct file *filp);
2007-11-19 23:18:48 +00:00
extern long do_sys_open(int dfd, const char __user *filename, int flags,
2007-04-05 10:04:00 +00:00
int mode);
extern struct file *filp_open(const char *, int, int);
2008-07-02 20:24:33 +00:00
@@ -1751,7 +1751,7 @@ extern int do_remount_sb(struct super_bl
2007-04-05 10:04:00 +00:00
#ifdef CONFIG_BLOCK
extern sector_t bmap(struct inode *, sector_t);
#endif
-extern int notify_change(struct dentry *, struct iattr *);
+extern int notify_change(struct dentry *, struct vfsmount *, struct iattr *);
extern int permission(struct inode *, int, struct nameidata *);
extern int generic_permission(struct inode *, int,
int (*check_acl)(struct inode *, int));
--- a/mm/filemap.c
+++ b/mm/filemap.c
2008-07-02 20:24:33 +00:00
@@ -1665,7 +1665,7 @@ static int __remove_suid(struct path *pa
struct iattr newattrs;
newattrs.ia_valid = ATTR_FORCE | kill;
- return notify_change(path->dentry, &newattrs);
+ return notify_change(path->dentry, path->mnt, &newattrs);
}
int remove_suid(struct path *path)
--- a/mm/tiny-shmem.c
+++ b/mm/tiny-shmem.c
2008-07-02 20:24:33 +00:00
@@ -80,7 +80,7 @@ struct file *shmem_file_setup(char *name
2007-11-19 23:18:48 +00:00
inode->i_nlink = 0; /* It is unlinked */
/* notify everyone as to the change of file size */
- error = do_truncate(dentry, size, 0, file);
+ error = do_truncate(dentry, file->f_path.mnt, size, 0, file);
if (error < 0)
goto close_file;