]> git.baikalelectronics.ru Git - kernel.git/commitdiff
xfs: fix misuse of the XFS_ATTR_INCOMPLETE flag
authorChristoph Hellwig <hch@lst.de>
Wed, 5 Oct 2022 07:00:55 +0000 (12:30 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Oct 2022 07:16:56 +0000 (09:16 +0200)
commit 08cd4677187e39329c5d994a5351bd77c287dc18 upstream.

XFS_ATTR_INCOMPLETE is a flag in the on-disk attribute format, and thus
in a different namespace as the ATTR_* flags in xfs_da_args.flags.
Switch to using a XFS_DA_OP_INCOMPLETE flag in op_flags instead.  Without
this users might be able to inject this flag into operations using the
attr by handle ioctl.

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>
Acked-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/xfs/libxfs/xfs_attr.c
fs/xfs/libxfs/xfs_attr_leaf.c
fs/xfs/libxfs/xfs_da_btree.h
fs/xfs/libxfs/xfs_da_format.h

index 510ca69746042b3a86fdd5a4897609fbf80d8280..c83ff610ecb6c3c92a91e11d50aa8b3a28967cb9 100644 (file)
@@ -1007,7 +1007,7 @@ restart:
                 * The INCOMPLETE flag means that we will find the "old"
                 * attr, not the "new" one.
                 */
-               args->flags |= XFS_ATTR_INCOMPLETE;
+               args->op_flags |= XFS_DA_OP_INCOMPLETE;
                state = xfs_da_state_alloc();
                state->args = args;
                state->mp = mp;
index 0c23127347acac0de8ad44de519b5e51d8dcf570..c86ddbf6d105b385ccf86aa7c44feda97ab12997 100644 (file)
@@ -2345,8 +2345,8 @@ xfs_attr3_leaf_lookup_int(
                 * If we are looking for INCOMPLETE entries, show only those.
                 * If we are looking for complete entries, show only those.
                 */
-               if ((args->flags & XFS_ATTR_INCOMPLETE) !=
-                   (entry->flags & XFS_ATTR_INCOMPLETE)) {
+               if (!!(args->op_flags & XFS_DA_OP_INCOMPLETE) !=
+                   !!(entry->flags & XFS_ATTR_INCOMPLETE)) {
                        continue;
                }
                if (entry->flags & XFS_ATTR_LOCAL) {
index ae0bbd20d9caf141a7ae7c57803c57006f9e3d58..eebbc66f4c05663d3441a6810f1887f96fd4bb14 100644 (file)
@@ -82,6 +82,7 @@ typedef struct xfs_da_args {
 #define XFS_DA_OP_OKNOENT      0x0008  /* lookup/add op, ENOENT ok, else die */
 #define XFS_DA_OP_CILOOKUP     0x0010  /* lookup to return CI name if found */
 #define XFS_DA_OP_ALLOCVAL     0x0020  /* lookup to alloc buffer if found  */
+#define XFS_DA_OP_INCOMPLETE   0x0040  /* lookup INCOMPLETE attr keys */
 
 #define XFS_DA_OP_FLAGS \
        { XFS_DA_OP_JUSTCHECK,  "JUSTCHECK" }, \
@@ -89,7 +90,8 @@ typedef struct xfs_da_args {
        { XFS_DA_OP_ADDNAME,    "ADDNAME" }, \
        { XFS_DA_OP_OKNOENT,    "OKNOENT" }, \
        { XFS_DA_OP_CILOOKUP,   "CILOOKUP" }, \
-       { XFS_DA_OP_ALLOCVAL,   "ALLOCVAL" }
+       { XFS_DA_OP_ALLOCVAL,   "ALLOCVAL" }, \
+       { XFS_DA_OP_INCOMPLETE, "INCOMPLETE" }
 
 /*
  * Storage for holding state during Btree searches and split/join ops.
index ae654e06b2fb693627311c8e59235d1f04e79773..cda10902df1e8542e70701ae0db816651217db2e 100644 (file)
@@ -740,8 +740,6 @@ struct xfs_attr3_icleaf_hdr {
 
 /*
  * Flags used in the leaf_entry[i].flags field.
- * NOTE: the INCOMPLETE bit must not collide with the flags bits specified
- * on the system call, they are "or"ed together for various operations.
  */
 #define        XFS_ATTR_LOCAL_BIT      0       /* attr is stored locally */
 #define        XFS_ATTR_ROOT_BIT       1       /* limit access to trusted attrs */