Skip to content

Commit ea9a46e

Browse files
committed
xfs: only return detailed fsmap info if the caller has CAP_SYS_ADMIN
There were a number of handwaving complaints that one could "possibly" use inode numbers and extent maps to fingerprint a filesystem hosting multiple containers and somehow use the information to guess at the contents of other containers and attack them. Despite the total lack of any demonstration that this is actually possible, it's easier to restrict access now and broaden it later, so use the rmapbt fsmap backends only if the caller has CAP_SYS_ADMIN. Unprivileged users will just have to make do with only getting the free space and static metadata placement information. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Carlos Maiolino <[email protected]>
1 parent 892d2a5 commit ea9a46e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

fs/xfs/xfs_fsmap.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,7 @@ xfs_getfsmap(
828828
struct xfs_fsmap dkeys[2]; /* per-dev keys */
829829
struct xfs_getfsmap_dev handlers[XFS_GETFSMAP_DEVS];
830830
struct xfs_getfsmap_info info = { NULL };
831+
bool use_rmap;
831832
int i;
832833
int error = 0;
833834

@@ -837,12 +838,14 @@ xfs_getfsmap(
837838
!xfs_getfsmap_is_valid_device(mp, &head->fmh_keys[1]))
838839
return -EINVAL;
839840

841+
use_rmap = capable(CAP_SYS_ADMIN) &&
842+
xfs_sb_version_hasrmapbt(&mp->m_sb);
840843
head->fmh_entries = 0;
841844

842845
/* Set up our device handlers. */
843846
memset(handlers, 0, sizeof(handlers));
844847
handlers[0].dev = new_encode_dev(mp->m_ddev_targp->bt_dev);
845-
if (xfs_sb_version_hasrmapbt(&mp->m_sb))
848+
if (use_rmap)
846849
handlers[0].fn = xfs_getfsmap_datadev_rmapbt;
847850
else
848851
handlers[0].fn = xfs_getfsmap_datadev_bnobt;

0 commit comments

Comments
 (0)