From patchwork Fri Dec 27 17:38:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 13922063 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 C96031F193D; Fri, 27 Dec 2024 17:39:13 +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=1735321153; cv=none; b=WiqOd5i3Zo5irXhVTWEIBfotu5AZF2T/R/iZWbx6E1fZyGUk0YzqSaWSHPPfEisNC6pVNn7pVuTZ4sHjtYimnB88gs0IyHtFlEJjCrczgT3R9UtF3Te2xnWDyzw47atPkVv+fB3DFnZwN/o1VeaJcYYalPLh0kXolbSAfrd1TkQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735321153; c=relaxed/simple; bh=Pmk+Xvzz2GB6vpy3BvaB3JZVSZQ0honsC6HdZiuthvk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=oIxANOnVSQPm4PfxXpem6U+++eFp+/jtNsNJiVdyyAFu0S//x0h/72+5nbrCeFxQyYXsPO8i+nP/Yf6VPtE6pt9hHOPO1qwRWzapENgRjViU82tsiockFwowV3ykUIP3m7UXTA7QaLDYTUWwcKTNcn47hL4Vd0PWjALNHdVJdh0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LgMrkaUT; 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="LgMrkaUT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2456AC4CED0; Fri, 27 Dec 2024 17:39:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735321153; bh=Pmk+Xvzz2GB6vpy3BvaB3JZVSZQ0honsC6HdZiuthvk=; h=From:To:Cc:Subject:Date:From; b=LgMrkaUTtOcOc3va7THU1stKgi0pJz1EtfvDLQYnypylGVpc8eOr5JqmJyrRp0rn3 QZOgJmafekcbWwNa+T1CO70NJ2hoJiN/mgI0OK3+/VN5X0xt+qqhcjTyQQslly9m2Z mrXbYaRGxgs2+Z4bJTHsRgpbf6NfizQFG9D1ntkIdrG0UIR493ZKbaHCoZGPfAS50w vyY9KeWasD4m+ORce4DIckKPyqnYxHo7UGUXXHy0gKjJUi461Ofi3WNvI2v8oMnOSL mhaNvj4FxmAAv65fgeKgZ6LJTzuiN8GI0fFBnu2aKaR/s8I2+nhWcHwDHPr65ZFzRu +A+aNsaP8t85A== Received: by pali.im (Postfix) id 10B24787; Fri, 27 Dec 2024 18:39:04 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Steve French , Paulo Alcantara Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] cifs: Remove symlink member from cifs_open_info_data union Date: Fri, 27 Dec 2024 18:38:38 +0100 Message-Id: <20241227173841.22949-1-pali@kernel.org> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Member 'symlink' is part of the union in struct cifs_open_info_data. Its value is assigned on few places, but is always read throw another union member 'reparse_point'. So to make code more readable, always use only 'reparse_point' member and drop whole union structure. No function change. Signed-off-by: Pali Rohár --- fs/smb/client/cifsglob.h | 5 +---- fs/smb/client/inode.c | 2 +- fs/smb/client/smb1ops.c | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h index 5045ead02c43..e1deb5f6209d 100644 --- a/fs/smb/client/cifsglob.h +++ b/fs/smb/client/cifsglob.h @@ -251,10 +251,7 @@ struct cifs_cred { struct cifs_open_info_data { bool adjust_tz; - union { - bool reparse_point; - bool symlink; - }; + bool reparse_point; struct { /* ioctl response buffer */ struct { diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c index b295d161373c..ac408e3e0478 100644 --- a/fs/smb/client/inode.c +++ b/fs/smb/client/inode.c @@ -990,7 +990,7 @@ cifs_get_file_info(struct file *filp) /* TODO: add support to query reparse tag */ data.adjust_tz = false; if (data.symlink_target) { - data.symlink = true; + data.reparse_point = true; data.reparse.tag = IO_REPARSE_TAG_SYMLINK; } path = build_path_from_dentry(dentry, page); diff --git a/fs/smb/client/smb1ops.c b/fs/smb/client/smb1ops.c index 76e7353f2a72..73d4cc1534ff 100644 --- a/fs/smb/client/smb1ops.c +++ b/fs/smb/client/smb1ops.c @@ -546,7 +546,7 @@ static int cifs_query_path_info(const unsigned int xid, int rc; FILE_ALL_INFO fi = {}; - data->symlink = false; + data->reparse_point = false; data->adjust_tz = false; /* could do find first instead but this returns more info */ @@ -587,7 +587,7 @@ static int cifs_query_path_info(const unsigned int xid, /* Need to check if this is a symbolic link or not */ tmprc = CIFS_open(xid, &oparms, &oplock, NULL); if (tmprc == -EOPNOTSUPP) - data->symlink = true; + data->reparse_point = true; else if (tmprc == 0) CIFSSMBClose(xid, tcon, fid.netfid); } From patchwork Fri Dec 27 17:38:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 13922064 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 C959E1FB3; Fri, 27 Dec 2024 17:39:13 +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=1735321153; cv=none; b=MyA5Kq5C39r2kuqrRBqak4owJGESpbMuIRhNlT9N2u6JZ+Uf2Etb6sQepmMz+bgZWoLU8Dx89q6gIIZ5agfQMXl0hijHPMdZ/YSsedoQnefAKlnqvxslzwu6SF6cKAOd8VXxNfBAX7Jaxh7izzbpGQMoEWrPP2RFHPFWotswXag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735321153; c=relaxed/simple; bh=4KVOZna8Jhv7HiSZht1rqhXUxaXIYIXVZiZliXFd4Fg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ifS4kHp/MQb9/xiqvYhQboKQzu9sTpHQT+NzOSs7gyeATutKvdWYk/9sCLDIGNOdtsBzaZv8P56dNj9Wbg64v1I96NfhZut2Fd5/Ybiy7+MnKDZJhJhlk2rllCzKOLk8+YTaCJ0EwjJi6O+/QmfaQdkIU1GCwM2RbX+b08aThdA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YhPmTPFE; 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="YhPmTPFE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CCEEC4CED3; Fri, 27 Dec 2024 17:39:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735321153; bh=4KVOZna8Jhv7HiSZht1rqhXUxaXIYIXVZiZliXFd4Fg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YhPmTPFERUCe82DZQWiHD0sFgKyBFkZ1LzvdeHmR6RGrukLpRiCUPYDTuIhFHZiDf NoQoN5O3BrybXaW3QtvoJO5N6LtRWqR7NMr6j/7B8Akuo2v/aGZoaScnIcRHkqWbcK maZMzntM0OU0Iqit0OThvKo2iH9d05o6a6a+wlHASEocpEl9ifZWDFM0XxrqHLNtUU STxtjIeIsPXUvId35tSfrchlJcJJaxuE9E0G002CzWgoltuU6UdSALQ5EmGlUZX/QD ouGejQL36eriG8/JhLHfaI6/nKdloBMCjp6SXSj7nutL+rOOaRsMNszdAsSMjjQm17 IdgsgU31mMI0A== Received: by pali.im (Postfix) id 30705A7C; Fri, 27 Dec 2024 18:39:04 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Steve French , Paulo Alcantara Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] cifs: Simplify reparse point check in cifs_query_path_info() function Date: Fri, 27 Dec 2024 18:38:39 +0100 Message-Id: <20241227173841.22949-2-pali@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241227173841.22949-1-pali@kernel.org> References: <20241227173841.22949-1-pali@kernel.org> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 For checking if path is reparse point and setting data->reparse_point member, it is enough to check if ATTR_REPARSE is present. It is not required to call CIFS_open() without OPEN_REPARSE_POINT and checking for -EOPNOTSUPP error code. Signed-off-by: Pali Rohár --- fs/smb/client/smb1ops.c | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/fs/smb/client/smb1ops.c b/fs/smb/client/smb1ops.c index 73d4cc1534ff..3af3f64b0cba 100644 --- a/fs/smb/client/smb1ops.c +++ b/fs/smb/client/smb1ops.c @@ -564,32 +564,8 @@ static int cifs_query_path_info(const unsigned int xid, } if (!rc) { - int tmprc; - int oplock = 0; - struct cifs_fid fid; - struct cifs_open_parms oparms; - move_cifs_info_to_smb2(&data->fi, &fi); - - if (!(le32_to_cpu(fi.Attributes) & ATTR_REPARSE)) - return 0; - - oparms = (struct cifs_open_parms) { - .tcon = tcon, - .cifs_sb = cifs_sb, - .desired_access = FILE_READ_ATTRIBUTES, - .create_options = cifs_create_options(cifs_sb, 0), - .disposition = FILE_OPEN, - .path = full_path, - .fid = &fid, - }; - - /* Need to check if this is a symbolic link or not */ - tmprc = CIFS_open(xid, &oparms, &oplock, NULL); - if (tmprc == -EOPNOTSUPP) - data->reparse_point = true; - else if (tmprc == 0) - CIFSSMBClose(xid, tcon, fid.netfid); + data->reparse_point = le32_to_cpu(fi.Attributes) & ATTR_REPARSE; } return rc; From patchwork Fri Dec 27 17:38:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 13922065 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 6790D1F868E; Fri, 27 Dec 2024 17:39:14 +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=1735321154; cv=none; b=T+9os2fbCUiDkVvfUGPayxH3BrpJTALVb0gZqXGZuqW381a/MZ3uXXAc+mjBEdFhzJKp7osYxUXKgj34Z/LJuqMFc1ZyU0rTsw0FtUwUcf2+21hPMiUg5tzN4ZsSMWhernM3OrU2HEphrSU4GJTU2gDrJsXEN2lFUurvyB4a37Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735321154; c=relaxed/simple; bh=U6ONnIq8oDFK6RRa4Ear/9P7wspwRYBV3GKg4+Oo1ns=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=jwt5zJf0Rl0l0Go2EpkciHifA5NVM0SIM2iIDdJb96n5HmNfC0bHSeyCDgIXT9RcG6FURMunuiq0S0KdegsBfa4KsL7lsMNxikJuviAX7r2q96VJ2bjQbN9X1SNf6u/zHEXVyRYvZrFsnyjwoG/jEAjHsC5ITnKbg9HpgnMTYFA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=V03C+K8c; 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="V03C+K8c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C85B6C4CED6; Fri, 27 Dec 2024 17:39:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735321154; bh=U6ONnIq8oDFK6RRa4Ear/9P7wspwRYBV3GKg4+Oo1ns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V03C+K8cy7iCsnfO83gehhZLWUi41WtNpqWtrnQQ+qM1kH59TJ0kUfJ+ebrMC7EOr iz5KypKYnQW6FexM7mJzYChBea5khqUN8BAXZpVDRDS9q138nYiR0Tc2a9QKCEomoj 2X18AUVMrUYdJde9dzaS6YK1JDL5EXYWxIYtq/ydjCLzmPZJlFMcReDa3Tvml3752r kXb2orPVOH12pSe2duXoyDJrixoWualQgmrsPHfMQ3I+7I2ufiF7Y0HFEA76dVIeV4 wC1bv3JYkXOakfhCEXXJONKiw7i63N1Dwny+FvbReIb+CFShp2reCaLf3N1ZZ9NwvT VfDvsX02hD0ag== Received: by pali.im (Postfix) id 4D3B0A7F; Fri, 27 Dec 2024 18:39:04 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Steve French , Paulo Alcantara Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] cifs: Validate EAs for WSL reparse points Date: Fri, 27 Dec 2024 18:38:40 +0100 Message-Id: <20241227173841.22949-3-pali@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241227173841.22949-1-pali@kernel.org> References: <20241227173841.22949-1-pali@kernel.org> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Major and minor numbers for char and block devices are mandatory for stat. So check that the WSL EA $LXDEV is present for WSL CHR and BLK reparse points. WSL reparse point tag determinate type of the file. But file type is present also in the WSL EA $LXMOD. So check that both file types are same. Fixes: 78e26bec4d6d ("smb: client: parse uid, gid, mode and dev from WSL reparse points") Signed-off-by: Pali Rohár --- fs/smb/client/reparse.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/fs/smb/client/reparse.c b/fs/smb/client/reparse.c index 9fe9dd71a6fa..9e40f5709c7f 100644 --- a/fs/smb/client/reparse.c +++ b/fs/smb/client/reparse.c @@ -1105,11 +1105,12 @@ struct reparse_data_buffer *smb2_get_reparse_point_buffer(const struct kvec *rsp le32_to_cpu(io->OutputOffset)); } -static void wsl_to_fattr(struct cifs_open_info_data *data, +static bool wsl_to_fattr(struct cifs_open_info_data *data, struct cifs_sb_info *cifs_sb, u32 tag, struct cifs_fattr *fattr) { struct smb2_file_full_ea_info *ea; + bool have_xattr_dev = false; u32 next = 0; switch (tag) { @@ -1152,13 +1153,24 @@ static void wsl_to_fattr(struct cifs_open_info_data *data, fattr->cf_uid = wsl_make_kuid(cifs_sb, v); else if (!strncmp(name, SMB2_WSL_XATTR_GID, nlen)) fattr->cf_gid = wsl_make_kgid(cifs_sb, v); - else if (!strncmp(name, SMB2_WSL_XATTR_MODE, nlen)) + 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) != S_DT(le32_to_cpu(*(__le32 *)v))) + return false; fattr->cf_mode = (umode_t)le32_to_cpu(*(__le32 *)v); - else if (!strncmp(name, SMB2_WSL_XATTR_DEV, nlen)) + } else if (!strncmp(name, SMB2_WSL_XATTR_DEV, nlen)) { fattr->cf_rdev = reparse_mkdev(v); + have_xattr_dev = true; + } } while (next); out: + + /* Major and minor numbers for char and block devices are mandatory. */ + if (!have_xattr_dev && (tag == IO_REPARSE_TAG_LX_CHR || tag == IO_REPARSE_TAG_LX_BLK)) + return false; + fattr->cf_dtype = S_DT(fattr->cf_mode); + return true; } static bool posix_reparse_to_fattr(struct cifs_sb_info *cifs_sb, @@ -1221,7 +1233,9 @@ bool cifs_reparse_point_to_fattr(struct cifs_sb_info *cifs_sb, case IO_REPARSE_TAG_AF_UNIX: case IO_REPARSE_TAG_LX_CHR: case IO_REPARSE_TAG_LX_BLK: - wsl_to_fattr(data, cifs_sb, tag, fattr); + ok = wsl_to_fattr(data, cifs_sb, tag, fattr); + if (!ok) + return false; break; case IO_REPARSE_TAG_NFS: ok = posix_reparse_to_fattr(cifs_sb, fattr, data); From patchwork Fri Dec 27 17:38:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 13922066 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 695D11F8694; Fri, 27 Dec 2024 17:39:14 +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=1735321154; cv=none; b=trHEUxsPkZmowtKfju9XGvpr+bM54/0NYAF6G5bV4hGyP/Aba3XhPpPgAdLYIlxbOso6L82vf90pQJWC3+ozPSANfb1CVmYAyq1pJzg0gGDfRj2sob9Y9oncL6jooZUft5MgKM0DpXfM4j1a9Lb2FOQxfZcRhwV/XiDydm/BOug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735321154; c=relaxed/simple; bh=9RTNpJ8xTPExKH3XWGSwmzIJeLjvgQ22UjgGgcVzCZ4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=aWdsUPkmuJL3JD7s8fYaROO1ipp9dwdVUfjgsG+LzmGkeYDnzJeLHgAFRfpOpxMP5iqLQ9vZjjOfgc/N829LkJJMCkVnzah6Ifyq4fX9IntuP343MK8wH5nXxdCHqISqK+Mgq1D28DFXN1g0+1d2oQVMvZCwnJlZkGc/z3GTKYA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VPc6XoAC; 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="VPc6XoAC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 260B4C4CED0; Fri, 27 Dec 2024 17:39:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735321154; bh=9RTNpJ8xTPExKH3XWGSwmzIJeLjvgQ22UjgGgcVzCZ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VPc6XoACvgSsU1Qmf/agA/3TuRNHdGoh8a2TvROpP2hmcvxhz3ZBR/zSq/vhvgJl9 J5JC57PmBNSD9E8SNPI17WrIplNEaRDE1/gCBX0b5Q03tD5zAxhm4ca3v22MurfrNJ HZlBo9NjzV4tKGfb7FXff9vkkZ8rB6gNrEUfRwO+zZOxVJLEqZOYZZGJN8UChFLe86 vYt2e1acI1//zmkzTbzpq6EFhIR8AaiHbWElmRx5IRYWfea11Jzad3l8cSAWPUbTOA R9ZjrLbeDA4z7lUDpwZlyJGKqd7TYwuilQD7H++2uFn2a3RqEQTYZTrHIzBciEWTsH UDaf/xrYkMKyQ== Received: by pali.im (Postfix) id 794AFB9A; Fri, 27 Dec 2024 18:39:04 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Steve French , Paulo Alcantara Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] cifs: Fix querying of WSL CHR and BLK reparse points over SMB1 Date: Fri, 27 Dec 2024 18:38:41 +0100 Message-Id: <20241227173841.22949-4-pali@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241227173841.22949-1-pali@kernel.org> References: <20241227173841.22949-1-pali@kernel.org> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When reparse point in SMB1 query_path_info() callback was detected then query also for EA $LXDEV. In this EA are stored device major and minor numbers used by WSL CHR and BLK reparse points. Without major and minor numbers, stat() syscall does not work for char and block devices. Similar code is already in SMB2+ query_path_info() callback function. Signed-off-by: Pali Rohár --- fs/smb/client/smb1ops.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/fs/smb/client/smb1ops.c b/fs/smb/client/smb1ops.c index 3af3f64b0cba..c52fc4c1557c 100644 --- a/fs/smb/client/smb1ops.c +++ b/fs/smb/client/smb1ops.c @@ -568,6 +568,42 @@ static int cifs_query_path_info(const unsigned int xid, data->reparse_point = le32_to_cpu(fi.Attributes) & ATTR_REPARSE; } +#ifdef CONFIG_CIFS_XATTR + /* + * 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; + + ea = (struct smb2_file_full_ea_info *)data->wsl.eas; + rc = 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); + if (rc == SMB2_WSL_XATTR_DEV_SIZE) { + ea->next_entry_offset = cpu_to_le32(0); + ea->flags = 0; + ea->ea_name_length = SMB2_WSL_XATTR_NAME_LEN; + ea->ea_value_length = 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 = sizeof(*ea) + SMB2_WSL_XATTR_NAME_LEN + 1 + + SMB2_WSL_XATTR_DEV_SIZE; + rc = 0; + } else if (rc >= 0) { + /* It is an error if EA $LXDEV has wrong size. */ + rc = -EINVAL; + } else { + /* + * In all other cases ignore error if fetching + * of EA $LXDEV failed. It is needed only for + * WSL CHR and BLK reparse points and wsl_to_fattr() + * handle the case when EA is missing. + */ + rc = 0; + } + } +#endif + return rc; }