xfs
[Top] [All Lists]

[PATCH 2/7] xfs: use mnt_want_write in compat_attrmulti ioctl

To: xfs@xxxxxxxxxxx
Subject: [PATCH 2/7] xfs: use mnt_want_write in compat_attrmulti ioctl
From: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Date: Fri, 09 Jan 2009 17:11:06 -0500
References: <20090109221104.237540000@xxxxxxxxxxxxxxxxxxxxxx>
User-agent: quilt/0.46-1
The compat version of the attrmulti ioctl needs to ask for and then
later release write access to the mount just like the native version,
otherwise we could potentially write to read-only mounts.


Signed-off-by: Christoph Hellwig <hch@xxxxxx>

Index: xfs/fs/xfs/linux-2.6/xfs_ioctl32.c
===================================================================
--- xfs.orig/fs/xfs/linux-2.6/xfs_ioctl32.c     2008-12-29 01:25:19.000000000 
+0000
+++ xfs/fs/xfs/linux-2.6/xfs_ioctl32.c  2008-12-29 01:26:24.000000000 +0000
@@ -17,6 +17,7 @@
  */
 #include <linux/compat.h>
 #include <linux/ioctl.h>
+#include <linux/mount.h>
 #include <asm/uaccess.h>
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -458,15 +459,23 @@
                                        &ops[i].am_length, ops[i].am_flags);
                        break;
                case ATTR_OP_SET:
+                       ops[i].am_error = mnt_want_write(parfilp->f_path.mnt);
+                       if (ops[i].am_error)
+                               break;
                        ops[i].am_error = xfs_attrmulti_attr_set(
                                        dentry->d_inode, attr_name,
                                        compat_ptr(ops[i].am_attrvalue),
                                        ops[i].am_length, ops[i].am_flags);
+                       mnt_drop_write(parfilp->f_path.mnt);
                        break;
                case ATTR_OP_REMOVE:
+                       ops[i].am_error = mnt_want_write(parfilp->f_path.mnt);
+                       if (ops[i].am_error)
+                               break;
                        ops[i].am_error = xfs_attrmulti_attr_remove(
                                        dentry->d_inode, attr_name,
                                        ops[i].am_flags);
+                       mnt_drop_write(parfilp->f_path.mnt);
                        break;
                default:
                        ops[i].am_error = EINVAL;

-- 

<Prev in Thread] Current Thread [Next in Thread>