Skip to contentSkip to conversation

xfs: also reject BULKSTAT_SINGLE in a mount user namespace

PATCH In review Christoph Hellwig 2 participants 2 messages Mar 12, 2021 – Mar 14, 2021 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: also reject BULKSTAT_SINGLE in a mount user namespace

BULKSTAT_SINGLE exposed the ondisk uids/gids just like bulkstat, and can be called on any inode, including ones not visible in the current mount.

Fixes f736d93d76d3 ("xfs: support idmapped mounts")
---
 fs/xfs/xfs_itable.c | 6 ++++++
 1 file changed, 6 insertions(+)
fs/xfs/xfs_itable.c +6 -0
index ca310a125d1e14..3498b97fb06d31 100644
@@ -168,6 +168,12 @@ xfs_bulkstat_one(
 	};
 	int			error;
 
+	if (breq->mnt_userns != &init_user_ns) {
+		xfs_warn_ratelimited(breq->mp,
+			"bulkstat not supported inside of idmapped mounts.");
+		return -EINVAL;
+	}
+
 	ASSERT(breq->icount == 1);
 
 	bc.buf = kmem_zalloc(sizeof(struct xfs_bulkstat),
Signature · 1 line
2.30.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Christoph Hellwig

BULKSTAT_SINGLE exposed the ondisk uids/gids just like bulkstat, and can be called on any inode, including ones not visible in the current mount.

Fixes f736d93d76d3 ("xfs: support idmapped mounts")

Looks good to me,

--D

Quoted 24 lines
---
 fs/xfs/xfs_itable.c | 6 ++++++
 1 file changed, 6 insertions(+)
fs/xfs/xfs_itable.c +6 -0
index ca310a125d1e14..3498b97fb06d31 100644
@@ -168,6 +168,12 @@ xfs_bulkstat_one(
 	};
 	int			error;
 
+	if (breq->mnt_userns != &init_user_ns) {
+		xfs_warn_ratelimited(breq->mp,
+			"bulkstat not supported inside of idmapped mounts.");
+		return -EINVAL;
+	}
+
 	ASSERT(breq->icount == 1);
 
 	bc.buf = kmem_zalloc(sizeof(struct xfs_bulkstat),
Signature · 1 line
2.30.1