From nobody Sat Feb 7 22:56:34 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D47D5199E94; Sun, 8 Jun 2025 17:01:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749402101; cv=none; b=RRMeNxgXNRdpeSXW8UjjEDFo1h0R8vGX+cCWOALzBZHwsgwjcH78SvXvHYvNmt2tQQaRidINslu2iBBiPy6WN+D1h82Gwyz4u9vEqCvFSVP25ziU5dqP0Hjgjf+0WAf8ghlKMGVYM+1vM4UFzQuxEJqhMpOUIUmEsEbrrs/XOAA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749402101; c=relaxed/simple; bh=b2gazy0Tgi+B9/Hsv9XFo1kh8OrtVCt9SXx0lJMHJek=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=WRqylj7KcagEjoJS9bRcJC/2mfCTYPWtwOHsR5EGOlkICwpbKVYau0vB/ufFzDYldNT2dNvAUDmnZGCqU3Qby9yjK9yqqksCZn7QOEj0af20aWiiNfDpS9yw89XtbPNG6GjpN/xAxPmqFJHeDhwkikgm1llOA3h5IIC5uTvsEZo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eSOc1ut7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eSOc1ut7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F034C4CEF4; Sun, 8 Jun 2025 17:01:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749402101; bh=b2gazy0Tgi+B9/Hsv9XFo1kh8OrtVCt9SXx0lJMHJek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eSOc1ut7/UuDjVB3bQcvHGY3c4udK+4sXBv4W3UWvIZhxS/3Y/FKWZWWRB8+VPSVv SkyNapUKJCZJqFPv9neh7TNbm8pQhH/+uOtMDJjCdMek2Zi8TVogKVdfSzYp3axIDs JsP4IyvKaWs4G48CqXvZMA0AhWjvtpxTcZSBMyKucAl2SSe0JKcZ1ytLZ0ldh7eXA7 AVRli4H0W7xDoe4WfHZtJkGRcY+fHISnl/gdQQRZjwjiaPGp82RGlrtZN1F6+GgvHf R1OVQZUAzTyIgNAwiLK1p11hoAMjT9SfSP78mmvW9LmwR8sx840W2TowYHJ72r/6Yq rA6Z7cpIsWu1g== Received: by pali.im (Postfix) id 4BE3CD70; Sun, 8 Jun 2025 19:01:38 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Steve French , Paulo Alcantara Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] cifs: Remove duplicate fattr->cf_dtype assignment from wsl_to_fattr() function Date: Sun, 8 Jun 2025 19:01:15 +0200 Message-Id: <20250608170119.6813-2-pali@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250608170119.6813-1-pali@kernel.org> References: <20250608170119.6813-1-pali@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Commit 8bd25b61c5a5 ("smb: client: set correct d_type for reparse DFS/DFSR and mount point") deduplicated assignment of fattr->cf_dtype member from all places to end of the function cifs_reparse_point_to_fattr(). The only one missing place which was not deduplicated is wsl_to_fattr(). Fix it. Fixes: 8bd25b61c5a5 ("smb: client: set correct d_type for reparse DFS/DFSR = and mount point") Signed-off-by: Pali Roh=C3=A1r --- fs/smb/client/reparse.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/smb/client/reparse.c b/fs/smb/client/reparse.c index d1d25f5f72ca..5351d3d9d538 100644 --- a/fs/smb/client/reparse.c +++ b/fs/smb/client/reparse.c @@ -1176,7 +1176,6 @@ static bool wsl_to_fattr(struct cifs_open_info_data *= data, if (!have_xattr_dev && (tag =3D=3D IO_REPARSE_TAG_LX_CHR || tag =3D=3D IO= _REPARSE_TAG_LX_BLK)) return false; =20 - fattr->cf_dtype =3D S_DT(fattr->cf_mode); return true; } =20 --=20 2.20.1 From nobody Sat Feb 7 22:56:34 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 ABAEF188CCA; Sun, 8 Jun 2025 17:01:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749402101; cv=none; b=EzCcBPwFI4xGxf9xu2PhAasjPASlf0QUw+1KXPJrnY79dEjOGLAf4Zf6e6puQgi3IjQD6Yz+adLT5/Uad1NlugLr6czdLCAJEA2YAAujFFSwX9wY7gR3E1aLo9DaDgLXCBeR3sswrWsHU7dtSE7wI3dHMw7iv8NGqQ1Z9mhQ6Ms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749402101; c=relaxed/simple; bh=txP9ftk5L5dLudeQxuPDS2ebH/GsVgeUwmT9SsYLnFI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=rHdpMkkQq69CCV3ckeGJ96NrcB8trkVrvsyEKhjyZpfM97yXJBfXCPs6J7ggxF2o2ZLR7sQACZCUYSppYamcFvv6f+cxLifm/FaO5dtv+4ips0lzdVCl7WU27OqLkrFVOwZR4wpbZ8oTVP0tJplD67VAHbEtMndk2nnGL54Td2o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fcAaoaje; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fcAaoaje" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34499C4CEF1; Sun, 8 Jun 2025 17:01:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749402101; bh=txP9ftk5L5dLudeQxuPDS2ebH/GsVgeUwmT9SsYLnFI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fcAaoajeJHq6Plb2/BGWixVXujx2VQvfNBT0hyojzxlCamSi4tvPwzMK0Ip6PJY9j Rnc7w+CpTpsk7MdzemVjcXlfw4z2mrNmTsJQF2q6+mQ1cVJYilsQBz0AW85LOC1m8g lpGL3l7rigrBD5egPqoDHjSO+x23a/zNjbRXIK4lRZ6OVJtwf1pOxesScUFJ3DRWnV WMeBEUFkgil4CiF4HS0SeVn2fDXRWh2UjfvY2qZUUsOQdG1LwnMKF1pQx7Odwthyoc vtHuAGGZ6SIO8kvFKf26uWZLNyr8bIk3Hc+Of8hIX6zZ2EKqRAgPx/5y+UNnDsGJY2 p5SgCdDBV6FMw== Received: by pali.im (Postfix) id 86C05DFA; Sun, 8 Jun 2025 19:01:38 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Steve French , Paulo Alcantara Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/5] cifs: Fix validation of EAs for WSL reparse points Date: Sun, 8 Jun 2025 19:01:16 +0200 Message-Id: <20250608170119.6813-3-pali@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250608170119.6813-1-pali@kernel.org> References: <20250608170119.6813-1-pali@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable When wsl_to_fattr() is called from readdir() then we should skip validation of WSL EAs because readdir FIND_FIRST/NEXT results do not provide EA values at all. For readdir() reply in this case return DT_UNKNOWN type instead of DT_REG (which is the result of failed WSL EAs validation). When validation is skipped and some required EAs are missing then returns true from wsl_to_fattr() function but do not set fattr->cf_mode. This makes readdir() to return DT_UNKNOWN type in the same way as it is doing NFS reparse point function. This change fixes readdir() result that for some WSL reparse points returns DT_REG due to missing EAs. After this change it returns DT_UNKNOWN, which is better than returning wrong type. Fixes: ef201e8759d2 ("cifs: Validate EAs for WSL reparse points") Signed-off-by: Pali Roh=C3=A1r --- fs/smb/client/reparse.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/fs/smb/client/reparse.c b/fs/smb/client/reparse.c index 5351d3d9d538..8d989e436517 100644 --- a/fs/smb/client/reparse.c +++ b/fs/smb/client/reparse.c @@ -1117,27 +1117,39 @@ static bool wsl_to_fattr(struct cifs_open_info_data= *data, u32 tag, struct cifs_fattr *fattr) { struct smb2_file_full_ea_info *ea; + bool ignore_missing_eas =3D false; bool have_xattr_dev =3D false; + umode_t reparse_mode_type =3D 0; u32 next =3D 0; =20 switch (tag) { case IO_REPARSE_TAG_LX_SYMLINK: - fattr->cf_mode |=3D S_IFLNK; + reparse_mode_type =3D S_IFLNK; break; case IO_REPARSE_TAG_LX_FIFO: - fattr->cf_mode |=3D S_IFIFO; + reparse_mode_type =3D S_IFIFO; break; case IO_REPARSE_TAG_AF_UNIX: - fattr->cf_mode |=3D S_IFSOCK; + reparse_mode_type =3D S_IFSOCK; break; case IO_REPARSE_TAG_LX_CHR: - fattr->cf_mode |=3D S_IFCHR; + reparse_mode_type =3D S_IFCHR; break; case IO_REPARSE_TAG_LX_BLK: - fattr->cf_mode |=3D S_IFBLK; + reparse_mode_type =3D S_IFBLK; break; + default: + return false; } =20 + /* + * When reparse buffer is not available then this is from readdir() call + * which does not provide EAs. readdir() can return DT_UNKNOWN type, + * which is signaled by no filling the fattr->cf_mode and returning true. + */ + if (!data->reparse.buf && !data->wsl.eas_len) + ignore_missing_eas =3D true; + if (!data->wsl.eas_len) goto out; =20 @@ -1162,7 +1174,7 @@ static bool wsl_to_fattr(struct cifs_open_info_data *= data, fattr->cf_gid =3D wsl_make_kgid(cifs_sb, v); else if (!strncmp(name, SMB2_WSL_XATTR_MODE, nlen)) { /* File type in reparse point tag and in xattr mode must match. */ - if (S_DT(fattr->cf_mode) !=3D S_DT(le32_to_cpu(*(__le32 *)v))) + if (S_DT(reparse_mode_type) !=3D S_DT(le32_to_cpu(*(__le32 *)v))) return false; fattr->cf_mode =3D (umode_t)le32_to_cpu(*(__le32 *)v); } else if (!strncmp(name, SMB2_WSL_XATTR_DEV, nlen)) { @@ -1174,8 +1186,9 @@ static bool wsl_to_fattr(struct cifs_open_info_data *= data, =20 /* Major and minor numbers for char and block devices are mandatory. */ if (!have_xattr_dev && (tag =3D=3D IO_REPARSE_TAG_LX_CHR || tag =3D=3D IO= _REPARSE_TAG_LX_BLK)) - return false; + return ignore_missing_eas; =20 + fattr->cf_mode |=3D reparse_mode_type; return true; } =20 --=20 2.20.1 From nobody Sat Feb 7 22:56:34 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 ABAA316C850; Sun, 8 Jun 2025 17:01:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749402101; cv=none; b=D9VE/Yly4hozw1krqIrD4jJHavMWwhiEfXXWhmb8auyy1IRpOQ8Kvc8akZI5PJ5UB8/ga1/YzX4MWbGEbz2VBLCRbvykUPCOx1Eglsf9o94++W5kAgZzN2Y5SXzAX5A4ZFtGqQBw3xMOxj+7sVEdWsIpmPywMbvk1MkbfYMMx1g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749402101; c=relaxed/simple; bh=dG+HAQQRyvd4jvroCu9QenmDzGqdwnSUb+X0lOm2yg8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=KTQlQCaOr5bMbO8BH0ci9CEXH7Adqt9RPrX6i8WcRdPosnUVN6TyX7XpVHOhFh6gMpSdw0c1Ma4oTtbSqrGFiPtLj+QOml2La8MUdK8WXHqfkZVTeIc6NEGGsOvuLAkZGp6g65nBfuaQqSX594GBEAz0b0jBBCCARy5CusDL8zA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g3UIWDUR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="g3UIWDUR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D06EC4CEF2; Sun, 8 Jun 2025 17:01:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749402101; bh=dG+HAQQRyvd4jvroCu9QenmDzGqdwnSUb+X0lOm2yg8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g3UIWDURt/XK3yyd4u9pO/LTCYu7Azv+Qe81b7qMwbxDuYvJ4zntx0S/3+XL4KeVZ nvjrmcmS76gDHGT2cRl0WT73e7pTmc9U5gGaZ4vfToQAAP4O1LWgHOHAGwHD7n4Usf ge07Dd/zAkNh3qOfgnl0DyKph3Er+CUDHCSFUbVFCvJrJ4UUPgFTCeHkLPHbCFJuvJ U6TA6DfsbYJ0ijpahm/hv7fxoK1rxQcfPlr0igBJ4eZUIJ1L3zdVuCdCAEA/5PyrqG 7yiw/kgzsJKom5tXSN+xpdTyQlYmKjX2PUE/WQuuOcyjmO+H6KwrQsfIJBSd7/OmFq m4OO8HJyjGDLw== Received: by pali.im (Postfix) id B56E3FA7; Sun, 8 Jun 2025 19:01:38 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Steve French , Paulo Alcantara Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/5] cifs: Fix validation of SMB2_OP_QUERY_WSL_EA response size Date: Sun, 8 Jun 2025 19:01:17 +0200 Message-Id: <20250608170119.6813-4-pali@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250608170119.6813-1-pali@kernel.org> References: <20250608170119.6813-1-pali@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Currently the SMB2_OP_QUERY_WSL_EA checks that response buffer has at least size SMB2_WSL_MIN_QUERY_EA_RESP_SIZE and maximally it is SMB2_WSL_MAX_QUERY_EA_RESP_SIZE. Constant SMB2_WSL_MIN_QUERY_EA_RESP_SIZE is defined wrongly because it expects that the there are at least 3 EAs. But WSL subsystem has only one mandatory EA: $LXMOD. So fix the SMB2_WSL_MIN_QUERY_EA_RESP_SIZE to be size of the structure of one EA. Relax also SMB2_WSL_MAX_QUERY_EA_RESP_SIZE, calculate maximum size from the size of the largest EA which is 8 bytes for $LXDEV. This change allows to recognize WSL CHR and BLK reparse points which have only $LXMOD and $LXDEV EAs (no $LXUID or $LXGID). WSL subsystem recognize such reparse points too. Fixes: ea41367b2a60 ("smb: client: introduce SMB2_OP_QUERY_WSL_EA") Signed-off-by: Pali Roh=C3=A1r --- fs/smb/client/smb2pdu.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h index 3c09a58dfd07..cdf0ab9ddbcd 100644 --- a/fs/smb/client/smb2pdu.h +++ b/fs/smb/client/smb2pdu.h @@ -425,24 +425,23 @@ struct smb2_create_ea_ctx { #define SMB2_WSL_XATTR_MODE "$LXMOD" #define SMB2_WSL_XATTR_DEV "$LXDEV" #define SMB2_WSL_XATTR_NAME_LEN 6 -#define SMB2_WSL_NUM_XATTRS 4 =20 #define SMB2_WSL_XATTR_UID_SIZE 4 #define SMB2_WSL_XATTR_GID_SIZE 4 #define SMB2_WSL_XATTR_MODE_SIZE 4 #define SMB2_WSL_XATTR_DEV_SIZE 8 =20 +/* minimal size: at least the smallest EA has to be present */ #define SMB2_WSL_MIN_QUERY_EA_RESP_SIZE \ - (ALIGN((SMB2_WSL_NUM_XATTRS - 1) * \ - (SMB2_WSL_XATTR_NAME_LEN + 1 + \ - sizeof(struct smb2_file_full_ea_info)), 4) + \ - SMB2_WSL_XATTR_NAME_LEN + 1 + sizeof(struct smb2_file_full_ea_info)) + (sizeof(struct smb2_file_full_ea_info) + SMB2_WSL_XATTR_NAME_LEN + 1 + 4) =20 +/* + * maximal size: all 4 EAs are present, + * beginning of each EA structure has to be aligned to 4 bytes, + * EAs have different size and can be returned in any other, + * use the largest EA size for aligning when calculating maximal size + */ #define SMB2_WSL_MAX_QUERY_EA_RESP_SIZE \ - (ALIGN(SMB2_WSL_MIN_QUERY_EA_RESP_SIZE + \ - SMB2_WSL_XATTR_UID_SIZE + \ - SMB2_WSL_XATTR_GID_SIZE + \ - SMB2_WSL_XATTR_MODE_SIZE + \ - SMB2_WSL_XATTR_DEV_SIZE, 4)) + 4 * ALIGN((sizeof(struct smb2_file_full_ea_info) + SMB2_WSL_XATTR_NAME_LE= N + 1 + 8), 4) =20 #endif /* _SMB2PDU_H */ --=20 2.20.1 From nobody Sat Feb 7 22:56:34 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 16CB71CF7AF; Sun, 8 Jun 2025 17:01:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749402103; cv=none; b=b49lea55eKnbni0CBTVwXxOX/RNM1TtZ8z+JSVy8/7NFivKOLlmZcm404laq6osZax4ho2bKqV3NschNccZT58bO4EywqflML61RFMDw2dbtfzr3eiw+pryoWT8U7iise3ryqRAretDcSW9+OjkDeROsjtqSR7PBALcfl6H2Vo8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749402103; c=relaxed/simple; bh=4fz3mfBElZAWsePM46+AzQNt4ktJShwT/EJVGIOHJTc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=QsT2mDUZcy617vsLOnVlC+tY5w6WBsQzcvRow4tjjL2/ytLLaaopqBOWo06SFeiv1kqMqYdAB68F5hYr43cDlHOkYVX0hTqhUKPB8y8hR/qUL2AbsRx6DdGDFX7aCAWTTFW6/tcugPyeyItPdh/9l7MgLMdtAe0B97MYn9faOqY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=e2ruSaKH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="e2ruSaKH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A6F3C4CEF5; Sun, 8 Jun 2025 17:01:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749402101; bh=4fz3mfBElZAWsePM46+AzQNt4ktJShwT/EJVGIOHJTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e2ruSaKHKmKBvwgickWxb51S8LUpxx35RkpF3eKLEBJkKU/oLRhXJBvtU0EmKgoR3 hlby20y/YGJ8rZe+1hP7HAGmz8I0J4ofeoZmd9NtqaLNcEYVxujjvkasjBbVaXecZ/ W0gGViii+TibcCTrXMI0noX0k3WFj7bGhIJ+TeGNEtyEAPQgOeHRFcly9tGeO1QQou yU22i034qq5tFMK3QFBdS1z7RAZFKU0UWIxpr5dAu1qLwWm4LJu19j9AtdV/6emWwf sANksGEl51vxi7ey0aznEnjN741HW/1/VyX2jhClI/DDB3lUa7e+DPjEM++CASYnMi NKcYkt4/xLWTQ== Received: by pali.im (Postfix) id DD5B310AE; Sun, 8 Jun 2025 19:01:38 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Steve French , Paulo Alcantara Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/5] cifs: Query EA $LXMOD in cifs_query_path_info() for WSL reparse points Date: Sun, 8 Jun 2025 19:01:18 +0200 Message-Id: <20250608170119.6813-5-pali@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250608170119.6813-1-pali@kernel.org> References: <20250608170119.6813-1-pali@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable EA $LXMOD is required for WSL non-symlink reparse points. Fixes: ef86ab131d91 ("cifs: Fix querying of WSL CHR and BLK reparse points = over SMB1") Signed-off-by: Pali Roh=C3=A1r --- fs/smb/client/smb1ops.c | 62 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/fs/smb/client/smb1ops.c b/fs/smb/client/smb1ops.c index df955cecdd4c..1f9166143ab1 100644 --- a/fs/smb/client/smb1ops.c +++ b/fs/smb/client/smb1ops.c @@ -659,14 +659,72 @@ static int cifs_query_path_info(const unsigned int xi= d, } =20 #ifdef CONFIG_CIFS_XATTR + /* + * For non-symlink WSL reparse points it is required to fetch + * EA $LXMOD which contains in its S_DT part the mandatory file type. + */ + if (!rc && data->reparse_point) { + struct smb2_file_full_ea_info *ea; + u32 next =3D 0; + + ea =3D (struct smb2_file_full_ea_info *)data->wsl.eas; + do { + ea =3D (void *)((u8 *)ea + next); + next =3D le32_to_cpu(ea->next_entry_offset); + } while (next); + if (le16_to_cpu(ea->ea_value_length)) { + ea->next_entry_offset =3D cpu_to_le32(ALIGN(sizeof(*ea) + + ea->ea_name_length + 1 + + le16_to_cpu(ea->ea_value_length), 4)); + ea =3D (void *)((u8 *)ea + le32_to_cpu(ea->next_entry_offset)); + } + + rc =3D CIFSSMBQAllEAs(xid, tcon, full_path, SMB2_WSL_XATTR_MODE, + &ea->ea_data[SMB2_WSL_XATTR_NAME_LEN + 1], + SMB2_WSL_XATTR_MODE_SIZE, cifs_sb); + if (rc =3D=3D SMB2_WSL_XATTR_MODE_SIZE) { + ea->next_entry_offset =3D cpu_to_le32(0); + ea->flags =3D 0; + ea->ea_name_length =3D SMB2_WSL_XATTR_NAME_LEN; + ea->ea_value_length =3D cpu_to_le16(SMB2_WSL_XATTR_MODE_SIZE); + memcpy(&ea->ea_data[0], SMB2_WSL_XATTR_MODE, SMB2_WSL_XATTR_NAME_LEN + = 1); + data->wsl.eas_len +=3D ALIGN(sizeof(*ea) + SMB2_WSL_XATTR_NAME_LEN + 1 + + SMB2_WSL_XATTR_MODE_SIZE, 4); + rc =3D 0; + } else if (rc >=3D 0) { + /* It is an error if EA $LXMOD has wrong size. */ + rc =3D -EINVAL; + } else { + /* + * In all other cases ignore error if fetching + * of EA $LXMOD failed. It is needed only for + * non-symlink WSL reparse points and wsl_to_fattr() + * handle the case when EA is missing. + */ + rc =3D 0; + } + } + /* * For WSL CHR and BLK reparse points it is required to fetch * EA $LXDEV which contains major and minor device numbers. */ if (!rc && data->reparse_point) { struct smb2_file_full_ea_info *ea; + u32 next =3D 0; =20 ea =3D (struct smb2_file_full_ea_info *)data->wsl.eas; + do { + ea =3D (void *)((u8 *)ea + next); + next =3D le32_to_cpu(ea->next_entry_offset); + } while (next); + if (le16_to_cpu(ea->ea_value_length)) { + ea->next_entry_offset =3D cpu_to_le32(ALIGN(sizeof(*ea) + + ea->ea_name_length + 1 + + le16_to_cpu(ea->ea_value_length), 4)); + ea =3D (void *)((u8 *)ea + le32_to_cpu(ea->next_entry_offset)); + } + rc =3D CIFSSMBQAllEAs(xid, tcon, full_path, SMB2_WSL_XATTR_DEV, &ea->ea_data[SMB2_WSL_XATTR_NAME_LEN + 1], SMB2_WSL_XATTR_DEV_SIZE, cifs_sb); @@ -676,8 +734,8 @@ static int cifs_query_path_info(const unsigned int xid, ea->ea_name_length =3D SMB2_WSL_XATTR_NAME_LEN; ea->ea_value_length =3D cpu_to_le16(SMB2_WSL_XATTR_DEV_SIZE); memcpy(&ea->ea_data[0], SMB2_WSL_XATTR_DEV, SMB2_WSL_XATTR_NAME_LEN + 1= ); - data->wsl.eas_len =3D sizeof(*ea) + SMB2_WSL_XATTR_NAME_LEN + 1 + - SMB2_WSL_XATTR_DEV_SIZE; + data->wsl.eas_len +=3D ALIGN(sizeof(*ea) + SMB2_WSL_XATTR_NAME_LEN + 1 + + SMB2_WSL_XATTR_MODE_SIZE, 4); rc =3D 0; } else if (rc >=3D 0) { /* It is an error if EA $LXDEV has wrong size. */ --=20 2.20.1 From nobody Sat Feb 7 22:56:34 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DD9C419ADBA; Sun, 8 Jun 2025 17:01:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749402102; cv=none; b=Znq7D09rZMFPejZ9Bz4QFXpJYDxJdtxsaewZW1kYKPyaf3sc/SYc4zPm145//00TtsTxKKRibmJjz1tM1DLeuE7ElHlKF1+yxTw+0pxIkuEpHE4oXlTJZe6/gUQb7xpmkcq1RMI/JOtVzRQKPwAQR++FBjUCSxf57M6cLry4jPI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749402102; c=relaxed/simple; bh=x1z4UyxTCtVi8S4w/KToWuSTzpJrpetpz98Zlw0Ewhs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=YbAVq5wUr68NacoDvM55FAHH7ijvjym6ZmwhPiG8horQChKaGpww2teasbtWUq24WFg0bnx4wCSgPVA2U1vlIl+4ISQ2P0u03czzS2a/Usrw+dcItPLQg7MuU4OHIdYyxgq6652I51+YGiVtpdDqa+Ockmx8tTiiHROiB2VYgfw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tA1gI075; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tA1gI075" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F2C3C4CEF6; Sun, 8 Jun 2025 17:01:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749402101; bh=x1z4UyxTCtVi8S4w/KToWuSTzpJrpetpz98Zlw0Ewhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tA1gI075IIeFWFRj7/qf6+iXfGXlmPYxxCZCKXkOw24TOjBmB2dxx9nqNIXtxRNKs S5bCv9m3dYvnHscTg1pNA3HN+1hZvYSvhR4Dh/lQfhUUqtoh+LB87HUk0eaPoZzUuF uqTnNPlKcHIc1fPTf2e/SHOnZcLIsVqku7+DEjvmUyC0MW+Gk75SfTdZ2mzilxQBNe L+ArvrGQL5pRkGA5GX0FY4P4w2Lvn4DYuO8AJ+W6IZpU9nNCBCzq3NvHDPhTHe9uGU SwlU66I1vkA7BXVD1ncwViVnNBRsnpRh0yqCgz2YnsQgNjoj25z7xYGHBo307tYyJZ nwvw0C4nGhN6w== Received: by pali.im (Postfix) id 2172C12DA; Sun, 8 Jun 2025 19:01:39 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Steve French , Paulo Alcantara Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/5] cifs: Validate presence of EA $LXMOD for WSL reparse points Date: Sun, 8 Jun 2025 19:01:19 +0200 Message-Id: <20250608170119.6813-6-pali@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250608170119.6813-1-pali@kernel.org> References: <20250608170119.6813-1-pali@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable S_DT part of EA $LXMOD is mandatory for all WSL reparse points except the WSL symlink and Win32 socket. Microsoft WSL subsystem does not recognize them without EA $LXMOD too, and treat such inodes as regular files. Fixes: ef201e8759d2 ("cifs: Validate EAs for WSL reparse points") Fixes: 78e26bec4d6d ("smb: client: parse uid, gid, mode and dev from WSL re= parse points") Signed-off-by: Pali Roh=C3=A1r --- fs/smb/client/reparse.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/smb/client/reparse.c b/fs/smb/client/reparse.c index 8d989e436517..3dffd5f0dc07 100644 --- a/fs/smb/client/reparse.c +++ b/fs/smb/client/reparse.c @@ -1118,6 +1118,7 @@ static bool wsl_to_fattr(struct cifs_open_info_data *= data, { struct smb2_file_full_ea_info *ea; bool ignore_missing_eas =3D false; + bool have_xattr_mode =3D false; bool have_xattr_dev =3D false; umode_t reparse_mode_type =3D 0; u32 next =3D 0; @@ -1177,6 +1178,7 @@ static bool wsl_to_fattr(struct cifs_open_info_data *= data, if (S_DT(reparse_mode_type) !=3D S_DT(le32_to_cpu(*(__le32 *)v))) return false; fattr->cf_mode =3D (umode_t)le32_to_cpu(*(__le32 *)v); + have_xattr_mode =3D true; } else if (!strncmp(name, SMB2_WSL_XATTR_DEV, nlen)) { fattr->cf_rdev =3D reparse_mkdev(v); have_xattr_dev =3D true; @@ -1188,6 +1190,16 @@ static bool wsl_to_fattr(struct cifs_open_info_data = *data, if (!have_xattr_dev && (tag =3D=3D IO_REPARSE_TAG_LX_CHR || tag =3D=3D IO= _REPARSE_TAG_LX_BLK)) return ignore_missing_eas; =20 + /* + * S_DT part of xattr MODE is mandatory for all WSL reparse points except= the WSL symlink. + * Microsoft WSL does not recognize them without xattr MODE too (except t= he WSL symlink). + * IO_REPARSE_TAG_AF_UNIX is here an exception because this reparse point= is used by both + * WSL subsystem and native NT/WinAPI subsystems. And NT/WinAPI creates A= F UNIX socket + * without the xattr MODE and recognize it also without the xattr MODE. + */ + if (!have_xattr_mode && (tag !=3D IO_REPARSE_TAG_AF_UNIX && tag !=3D IO_R= EPARSE_TAG_LX_SYMLINK)) + return ignore_missing_eas; + fattr->cf_mode |=3D reparse_mode_type; return true; } --=20 2.20.1