From ea6a67ef64451d2da298f15baa35865b4bb6372a Mon Sep 17 00:00:00 2001 From: Pisit Preechapramoth Date: Tue, 28 Jul 2026 21:58:58 +0900 Subject: ntfs: reject unprivileged writes to reserved $LX* xattrs Reject setxattr of the reserved $LXUID, $LXGID, $LXMOD and $LXDEV names from userspace unless the caller has CAP_SYS_ADMIN. Fixes: fc053f05ca28 ("ntfs: add reparse and ea operations") Signed-off-by: Pisit Preechapramoth Signed-off-by: Namjae Jeon --- fs/ntfs/ea.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/ntfs/ea.c b/fs/ntfs/ea.c index 4fbea76afe7e..fc6cec7ce130 100644 --- a/fs/ntfs/ea.c +++ b/fs/ntfs/ea.c @@ -808,6 +808,12 @@ err_out: return err; } +static bool ntfs_is_reserved_lxattr(const char *name) +{ + return !strcmp(name, "$LXUID") || !strcmp(name, "$LXGID") || + !strcmp(name, "$LXMOD") || !strcmp(name, "$LXDEV"); +} + static int ntfs_setxattr(const struct xattr_handler *handler, struct mnt_idmap *idmap, struct dentry *unused, struct inode *inode, const char *name, const void *value, @@ -820,6 +826,9 @@ static int ntfs_setxattr(const struct xattr_handler *handler, if (NVolShutdown(ni->vol)) return -EIO; + if (ntfs_is_reserved_lxattr(name) && !capable(CAP_SYS_ADMIN)) + return -EPERM; + if (!strcmp(name, SYSTEM_DOS_ATTRIB)) { if (sizeof(u8) != size) { err = -EINVAL; -- cgit v1.2.3