xfs: reject invalid flags combinations in XFS_IOC_ATTRMULTI_BY_HANDLE
authorChristoph Hellwig <hch@lst.de>
Tue, 7 Jan 2020 23:25:38 +0000 (15:25 -0800)
committerDarrick J. Wong <darrick.wong@oracle.com>
Thu, 9 Jan 2020 18:55:18 +0000 (10:55 -0800)
While the flags field in the ABI and the on-disk format allows for
multiple namespace flags, that is a logically invalid combination that
scrub complains about.  Reject it at the ioctl level, as all other
interface already get this right at higher levels.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
fs/xfs/xfs_ioctl.c
fs/xfs/xfs_ioctl32.c

index edfbdb8f85e22c552fe7b8277da9cfc0c0490407..17b4a981be4db68f171863a1724f1f7ab5e23503 100644 (file)
@@ -462,6 +462,11 @@ xfs_attrmulti_by_handle(
 
        error = 0;
        for (i = 0; i < am_hreq.opcount; i++) {
+               if ((ops[i].am_flags & ATTR_ROOT) &&
+                   (ops[i].am_flags & ATTR_SECURE)) {
+                       ops[i].am_error = -EINVAL;
+                       continue;
+               }
                ops[i].am_flags &= ~ATTR_KERNEL_FLAGS;
 
                ops[i].am_error = strncpy_from_user((char *)attr_name,
index 20b3edc10f48f97aa7a19e9f33e055698d90382f..769581a79c5885105524f121f93f2207ac4eb15f 100644 (file)
@@ -450,6 +450,11 @@ xfs_compat_attrmulti_by_handle(
 
        error = 0;
        for (i = 0; i < am_hreq.opcount; i++) {
+               if ((ops[i].am_flags & ATTR_ROOT) &&
+                   (ops[i].am_flags & ATTR_SECURE)) {
+                       ops[i].am_error = -EINVAL;
+                       continue;
+               }
                ops[i].am_flags &= ~ATTR_KERNEL_FLAGS;
 
                ops[i].am_error = strncpy_from_user((char *)attr_name,