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 9C63E3A7843; Thu, 2 Jul 2026 16:41:33 +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=1783010499; cv=none; b=aTilFUas48VowuFKw9cb/q1+eWTlp21GnsPzoj5UQIC5E78rQoweofX4LhJ7WDu5KeEQphMoOECZplArNTBfFyHu6qMCiKDieETKJ/2II8aG1puJjsWAyqWTIeepWWZZ7wpqEBHnsh8uHYKDTE7H6PXdOW7mwlkQqmilYPIoiYQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783010499; c=relaxed/simple; bh=lCHzAI9Fd23eih7Riv/GecJ0DBmYTOOqrqwcwnJqrAw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TEreIqgLnUTNdaxhMR8vp1eR6WHsYXz3NoFQbWUexdSdACrHbVUeeYiOPi5fbyB2s7QlsNBTxyYLVn+N2oUF8PuidxS8J7CWEmlGxrGpqXDbc5AOSgIi1fHRO6xLoAGGki91qOUPm4OP2Ov3r8sfHl+DuTXRzyj5tyQtJCkelgM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=s1ddt3AN; 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="s1ddt3AN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FA5C1F00ACF; Thu, 2 Jul 2026 16:41:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1783010493; bh=pXPC5r52j92yqvf3G+j6Z5y0wA177TLPbaHVCImSX5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=s1ddt3ANUBzaQFq9cgTqW1Bjg5Ie9aWryZtO3FXH/F2FCx/zAySWaBjCms6FHLXS3 9pCBvxLqHru32ZKjjMaccMCxnn2mC7kLbXHeWyaEnSP90D0kwmzY5ujxgplRGYFDaj DQwWhw8ctfY60lbBmcyuEu7Fg7o2ctS2xmlk9Yos= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zhen Yan , Konstantin Komarov Subject: [PATCH 6.12 130/204] ntfs3: reject direct userspace writes to reserved $LX* xattrs Date: Thu, 2 Jul 2026 18:19:47 +0200 Message-ID: <20260702155121.385022222@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260702155118.667618796@linuxfoundation.org> References: <20260702155118.667618796@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.12-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 @@ -829,6 +829,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 */ @@ -933,6 +939,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);