summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPisit Preechapramoth <kml.delusion501@slmail.me>2026-07-28 21:58:58 +0900
committerNamjae Jeon <linkinjeon@kernel.org>2026-08-19 18:16:45 +0900
commitea6a67ef64451d2da298f15baa35865b4bb6372a (patch)
treee7ec33cfd87a9b6644de822cfde592dec6248f6a
parent19cac7902a8ab748e15f98ddaafcf5f8882be21d (diff)
downloadlinux-ea6a67ef64451d2da298f15baa35865b4bb6372a.tar.gz
linux-ea6a67ef64451d2da298f15baa35865b4bb6372a.zip
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 <kml.delusion501@slmail.me> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
-rw-r--r--fs/ntfs/ea.c9
1 files changed, 9 insertions, 0 deletions
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;