From nobody Mon Jun 8 04:24:19 2026 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ECC0EDF59 for ; Sun, 7 Jun 2026 02:33:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780799631; cv=none; b=nidvTvy/Sqoy00nkJUHs7lNtnCWIwPowBVlMYp2oqehrhS8zbPxvsTxb+E+obTDVng2C+aZNKpBfqJICY5CnKPjhLFy8tq0iMoPkO8nLB1fvjRvuyOX5cIXnszsVUZDP9xlkoyom4NlRtUWeENiGKeaTd68FvDEI1yvUp2aIKHs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780799631; c=relaxed/simple; bh=TYRFTol04DcTPCQsfZGY9eXn4uQ6nAvd6tpADfLwihE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=G3p2eVE5Bbux7UYwOgEFLZwIMvN5/+mlu0QW6TGMztbeNcMW7OTXUtJRFcFjBSto8KvlQ5dxJ0LeEfaCJGKZ56qcZiqqrYlhOxkCz7TVLRICetdoa85s1ceEPlLGO1xUF55sFprPqeDYSSNEiwf6pMinsKxMeEn3KIqio38LOxM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=s6INLNKd; arc=none smtp.client-ip=209.85.214.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="s6INLNKd" Received: by mail-pl1-f194.google.com with SMTP id d9443c01a7336-2c0c35980fdso32434235ad.2 for ; Sat, 06 Jun 2026 19:33:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780799628; x=1781404428; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sf8jhK6nc/0IRduDkKHSSZmTS2M+HMVohcyT9/mAbFY=; b=s6INLNKdxI1g+ISpzdDYnVRgqxiCxJe5feqmGg55oQ77ny2H6Hl5fOc1cyu4OWI71q F5h7ZT7cCE6OVyYQTJs7Spmvg4bukWhiDJLFU4mC6P7LwA276UI7iJ7HpIdnkcjjzZ+b W+gQxVF2DxyLpsNHzGrXfC0EYqicatbEB4ul7VFoPswNcPY4ezgAEUqin+fyPErFxvix ge7VJ+o9SxzLkWcgnRhTDaFEWG3QU4x1nTzerBWEHckH7ibZ16mZCldyriG8xNUZvuAu 0LZtzGdvc+fQQVzIwRrNF/4Etn5lK5l+VMSs6XnqpaXGh0J1FDH7jPk8ZUZmDpd+Wvtn t21Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780799628; x=1781404428; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=sf8jhK6nc/0IRduDkKHSSZmTS2M+HMVohcyT9/mAbFY=; b=YDDwzLmffLfgUsW3LfKB8tJXccsh+w3zcELlwJt+voHLXn8YvlKkphqaf2RHSZeD1k n1HfbGMRS5MGzYhwFuwX3mC3ZjfUOzGP/3Sy3NJcVOmHpfH4wM3AcqrZu7K441Yl5Cba 9Q9ubus9MHwo902+AVd1NsD9Et2BeUQRtO0aMgxFVRtQIIH9OLAOOq4//yo73A+PX/Ox WSfRziBvQTNtU6z0o8e0xSnYe7ilGeBIK4LYiDLFPdplD588wj9G2JWgYX0fts3aQbL6 R4a/WQUXstzuvwT+Qzxdb3QW7mRGqj1AaKuSth8VoQjWftzptYF1g0h0iaSK2Di620Cy UZWQ== X-Forwarded-Encrypted: i=1; AFNElJ8e5TOj2snkoSbf7y5M2T9WSnmcZSmqJF242iKyD5Xzxu+7yQhqoS0h+iN6TfTr17Vhl5yR3GMPRzKAGVE=@vger.kernel.org X-Gm-Message-State: AOJu0YxxwFiRtJUI5XbI2OC32Khl51dSFuDoAs/rugkdWWhJwO0PfGMn XqlfK/bDbxhpDcKUrtEDaKEJwd0D0lZHDxpserKLOqG6vg9rYy7KF25DrLnG7ds0Cn1UwQ== X-Gm-Gg: Acq92OHwECnblmc6KcAYlf8QKK/cHSFDYM5M+G1gTzO5sUehvSfJg/jTpOt3SSeVE3z /c7PSMb1J5CrOkAG+c/Rp7eH+LMjTZ64raeF30opu5V8I56PWYgMfiD2Dsh3l1lr93aJH9U2oZq anvCQQJQKRpTvaXP+1FezDrIuIqvEu95j0/mHBlQwWHyZ0gTnx7P0vyICx9s6s18nBOgNN1z4Ry gJyk1KY/RLzKQ2Ggr4XlhG0rWDLkbat3LynVvwPdR2gjd+3JNxnfDORTCLpbb2XIk8M1WRNyDcr kWvdLGbI022oQ6VAs4suvUmj8B8geXFgLdmuFn0g0VAisiUapqWrrAyIn59Qri3awEz+1CacdFn 6lBS7t7ZHoIhuwTWSZymr9zOowX0qpQvd0UdEtiH2oRm09az0TNgLmvj8i20XVzvsXNIEhNopn1 msFJqQICy7uxyMWkVDlU1ej97UjHZ/IT5o/W9UrpOBPv6jOKQUF/hgJC3OurwcUbY= X-Received: by 2002:a17:903:22c9:b0:2bf:2015:5b93 with SMTP id d9443c01a7336-2c1e82125f8mr106857595ad.11.1780799628294; Sat, 06 Jun 2026 19:33:48 -0700 (PDT) Received: from LAPTOP-F6NHKUER.antgroup-inc.local ([8.141.222.131]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c16609e636sm137611035ad.51.2026.06.06.19.33.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jun 2026 19:33:47 -0700 (PDT) From: Zhen Yan To: Konstantin Komarov Cc: ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] ntfs3: reject direct userspace writes to reserved $LX* xattrs Date: Sun, 7 Jun 2026 10:33:39 +0800 Message-Id: <20260607023339.6728-1-sdjasjbuaa@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- Willy, thanks for the review. Replying to your points: - Tested on v7.1-rc5: builds clean (W=3D1, no warnings), checkpatch clean, and the original reproducer no longer triggers -- the setxattr() calls now return -EPERM and uid/gid/mode survive an inode reload. Internal WSL metadata is unaffected: ntfs_save_wsl_perm() writes via ntfs_set_ea(), not ntfs_setxattr(). - Resent via git format-patch / git send-email so whitespace is no longer mangled, with no PoC in the body and security@ dropped. fs/ntfs3/xattr.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c index 9eeac0ab2..0bc633025 100644 --- a/fs/ntfs3/xattr.c +++ b/fs/ntfs3/xattr.c @@ -851,6 +851,14 @@ static int ntfs_getxattr(const struct xattr_handler *h= andler, struct dentry *de, return err; } =20 +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 */ @@ -955,6 +963,11 @@ static noinline int ntfs_setxattr(const struct xattr_h= andler *handler, goto out; } =20 + if (ntfs_is_reserved_lxattr(name)) { + err =3D -EPERM; + goto out; + } + /* Deal with NTFS extended attribute. */ err =3D ntfs_set_ea(inode, name, strlen(name), value, size, flags, 0, NULL); --=20 2.25.1