OpenVZ Forum - RDF feed
type: channel
items: [patch 08/22] r/o bind mounts: elevate write count for some ioctls

[patch 08/22] r/o bind mounts: elevate write count for some ioctls
type: item
description: From: Dave Hansen <hansendc@us.ibm.com> Some ioctl()s can cause writes to the filesystem. Take these, and make them use mnt_want/drop_write() instead. We need to pass the filp one layer deeper in XFS, but somebody _just_ pulled it out in February because nobody was using it, so I don't feel guilty for adding it back. Signed-off-by: Dave Hansen <hansendc@us.ibm.com> --- --- fs/ext2/ioctl.c | 67 ++++++++++++++++++--------- fs/ext3/ioctl.c | 100 +++++++++++++++++++++++++++------------- fs/ext4/ioctl.c | 105 +++++++++++++++++++++++++++---------------- fs/fat/file.c | 9 ++- fs/hfsplus/ioctl.c | 39 +++++++++------ fs/jfs/ioctl.c | 33 ++++++++----- fs/ocfs2/ioctl.c | 11 ++-- fs/reiserfs/ioctl.c | 52 +++++++++++++-------- fs/xfs/linux-2.6/xfs_ioctl.c | 12 +++- fs/xfs/linux-2.6/xfs_iops.c | 7 -- fs/xfs/linux-2.6/xfs_lrw.c | 8 ++- 11 files changed, 281 insertions(+), 162 deletions(-) Index: 2.6.22-rc4-mm2-robindmount/fs/ext2/ioctl.c =================================================================== --- 2.6.22-rc4-mm2-robindmount.orig/fs/ext2/ioctl.c +++ 2.6.22-rc4-mm2-robindmount/fs/ext2/ioctl.c @@ -12,6 +12,7 @@ #include <linux/time.h> #include <linux/sched.h> #include <linux/compat.h> +#include <linux/mount.h> #include <linux/smp_lock.h> #include <asm/current.h> #include <asm/uaccess.h> @@ -23,6 +24,7 @@ int ext2_ioctl (struct inode * inode, st struct ext2_inode_info *ei = EXT2_I(inode); unsigned int flags; unsigned short rsv_window_size; + int ret; ext2_debug ("cmd = %u, arg = %lu\n", cmd, arg); @@ -34,14 +36,19 @@ int ext2_ioctl (struct inode * inode, st case EXT2_IOC_SETFLAGS: { unsigned int oldflags; - if (IS_RDONLY(inode)) - return -EROFS; - - if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER)) - return -EACCES; + ret = mnt_want_write(filp->f_vfsmnt); + if (ret) + return ret; + + if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER)) { + ret = -EACCES; + goto setflags_out; + } - if (get_user(flags, (int __user *) arg)) - return -EFAULT; + if (get_user…
creator: Cedric Le Goater
date: 2007-06-07T15:25:35-00:00