xfs: don't return XFS_ATTR_PARENT attributes via listxattr
authorAllison Henderson <allison.henderson@oracle.com>
Mon, 22 Apr 2024 16:47:52 +0000 (09:47 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 23 Apr 2024 14:46:59 +0000 (07:46 -0700)
Parent pointers are internal filesystem metadata.  They're not intended
to be directly visible to userspace, so filter them out of
xfs_xattr_put_listent so that they don't appear in listxattr.

Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
Inspired-by: Andrey Albershteyn <aalbersh@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
[djwong: change this to XFS_ATTR_PRIVATE_NSP_MASK per fsverity patchset]
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/libxfs/xfs_da_format.h
fs/xfs/xfs_xattr.c

index 1395ad1937c5357b6e9133e4b659f5a5780c0872..ebde6eb1da65d4a7cd500157c377e56025280ed6 100644 (file)
@@ -726,6 +726,9 @@ struct xfs_attr3_leafblock {
                                         XFS_ATTR_SECURE | \
                                         XFS_ATTR_PARENT)
 
+/* Private attr namespaces not exposed to userspace */
+#define XFS_ATTR_PRIVATE_NSP_MASK      (XFS_ATTR_PARENT)
+
 #define XFS_ATTR_ONDISK_MASK   (XFS_ATTR_NSP_ONDISK_MASK | \
                                 XFS_ATTR_LOCAL | \
                                 XFS_ATTR_INCOMPLETE)
index ba56a9e73144bf46793356fe0d08f3a9adf8acec..1e82d11d980f27d2e260314499d8af2319054c31 100644 (file)
@@ -229,6 +229,10 @@ xfs_xattr_put_listent(
 
        ASSERT(context->count >= 0);
 
+       /* Don't expose private xattr namespaces. */
+       if (flags & XFS_ATTR_PRIVATE_NSP_MASK)
+               return;
+
        if (flags & XFS_ATTR_ROOT) {
 #ifdef CONFIG_XFS_POSIX_ACL
                if (namelen == SGI_ACL_FILE_SIZE &&