From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4CCF33B951; Thu, 2 Jul 2026 16:54:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783011245; cv=none; b=qQnI7zco0MC6kNzY7c6MboIV9aduEYkkc0vhh4iqfC9WmlGbQablcBrMkVZgiOdx6CTBnKY4RLGVXkjoj0oMkdke7cv5EofpacNJRN8h+v6bPuPgLWAriL5RYCYWB/31AzIVbzvlSf9jhK+R5COQWu9kDOTAZ0RbaSV6ZK1ak1w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783011245; c=relaxed/simple; bh=y8+88TC+56h5Khg8hhn35vL69UmUl97WU7ptz8joX+0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HOt2Me9em0YDch7u5x/aNzXMIqrm/2+BbYS9ev+Qsulhes9O6u5Ir+WrXFLV6WMUjj53zCnj6Ip0BP4UB5sQo7lHoa7u5oGfPdeqUGkou9KV8dll5euBawoyZegM1iHSUo3frFxD28a+eHbxZlNO+0GVyRYvE17msyWezaTvHnE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=DuDIrZwD; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="DuDIrZwD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D40FF1F000E9; Thu, 2 Jul 2026 16:54:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1783011244; bh=3eMs2+SlL9axELr7YIbAOaVhofwul20b1ykfQ/sm7iQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DuDIrZwD+pbAeAEZH9LboctYhQfk7bzRXm6mtl7OCPpHOl1X0UllWwfTZMfGAMKu8 +eZPnJCGI8if/VrdKQeqDY+vq/reXtQzlq/fEiEcelWPXTUVXsUPd4nlmQNoiFlTG5 9Ii7VntY2/s3jsLhPkSbVIIWDMd6MotLMiRZF3Cc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zhen Yan , Konstantin Komarov Subject: [PATCH 6.18 034/108] ntfs3: reject direct userspace writes to reserved $LX* xattrs Date: Thu, 2 Jul 2026 18:20:31 +0200 Message-ID: <20260702155112.814674380@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260702155112.110058792@linuxfoundation.org> References: <20260702155112.110058792@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Konstantin Komarov commit 5b08dccecf825cbf905f348bc6ccb497507e28e2 upstream. NTFS3 uses $LXUID, $LXGID, $LXMOD and $LXDEV as internal WSL permission metadata and reloads them into i_uid, i_gid and i_mode from ntfs_get_wsl_perm(). Because the empty-prefix xattr handler also lets file owners call setxattr() on these names directly, an unprivileged writer on a writable ntfs3 mount can plant root ownership and S_ISUID on their own file and gain euid 0 after inode reload. Reject direct userspace writes to the reserved $LX* names. Internal ntfs3 metadata updates are unchanged because ntfs_save_wsl_perm() writes them via ntfs_set_ea() directly. Signed-off-by: Zhen Yan [almaz.alexandrovich@paragon-software.com: added an additional check for non privileged users] Signed-off-by: Konstantin Komarov Signed-off-by: Greg Kroah-Hartman --- fs/ntfs3/xattr.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/fs/ntfs3/xattr.c +++ b/fs/ntfs3/xattr.c @@ -845,6 +845,12 @@ 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"); +} + /* * ntfs_setxattr - inode_operations::setxattr */ @@ -949,6 +955,12 @@ set_new_fa: goto out; } + /* Do not allow non privileged users to change $LXUID/$LXGID... */ + if (ntfs_is_reserved_lxattr(name) && !capable(CAP_SYS_ADMIN)) { + err = -EPERM; + goto out; + } + /* Deal with NTFS extended attribute. */ err = ntfs_set_ea(inode, name, strlen(name), value, size, flags, 0, NULL);