Commit 62e194ec authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Lachlan McIlroy

xfs: use mnt_want_write in compat_attrmulti ioctl

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <david@fromorbit.com>
parent ab596ad8
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
*/ */
#include <linux/compat.h> #include <linux/compat.h>
#include <linux/ioctl.h> #include <linux/ioctl.h>
#include <linux/mount.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "xfs.h" #include "xfs.h"
#include "xfs_fs.h" #include "xfs_fs.h"
...@@ -458,15 +459,23 @@ xfs_compat_attrmulti_by_handle( ...@@ -458,15 +459,23 @@ xfs_compat_attrmulti_by_handle(
&ops[i].am_length, ops[i].am_flags); &ops[i].am_length, ops[i].am_flags);
break; break;
case ATTR_OP_SET: 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( ops[i].am_error = xfs_attrmulti_attr_set(
dentry->d_inode, attr_name, dentry->d_inode, attr_name,
compat_ptr(ops[i].am_attrvalue), compat_ptr(ops[i].am_attrvalue),
ops[i].am_length, ops[i].am_flags); ops[i].am_length, ops[i].am_flags);
mnt_drop_write(parfilp->f_path.mnt);
break; break;
case ATTR_OP_REMOVE: 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( ops[i].am_error = xfs_attrmulti_attr_remove(
dentry->d_inode, attr_name, dentry->d_inode, attr_name,
ops[i].am_flags); ops[i].am_flags);
mnt_drop_write(parfilp->f_path.mnt);
break; break;
default: default:
ops[i].am_error = EINVAL; ops[i].am_error = EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment