All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] smb: client: don't let the mfsymlinks probe overwrite an earlier error
@ 2026-12-02 19:55 ` bob via B4 Relay
  0 siblings, 0 replies; 3+ messages in thread
From: bob @ 2026-12-02 19:55 UTC (permalink / raw)
  To: Paulo Alcantara, Namjae Jeon, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, Bharath SM, David Howells
  Cc: linux-cifs, samba-technical, bob

Commit 7c4bf530aefa ("smb: client: avoid breaking the file lease when
probing mfsymlinks") switched the Minshall+French symlink probe in
cifs_get_fattr() and smb311_posix_get_fattr() from storing its result in
a throw-away 'tmprc' to assigning it to 'rc':

	if (sbflags & CIFS_MOUNT_MF_SYMLINKS) {
		rc = cifs_check_mf_symlink(...);
	}

At that point 'rc' may already hold an error from the reparse point
handling above (reparse_info_to_fattr() or the reparse handling in
smb311_posix_get_fattr()), which fills in the fattr and still returns
the error. cifs_check_mf_symlink() returns 0 for everything that does
not look like an mfsymlink (it only fails with -ENOMEM), so the earlier
error is lost.

Example, on a mount with "mfsymlinks": the server returns a malformed
symlink reparse point and parse_reparse_point() fails with -EIO.
reparse_info_to_fattr() still fills the fattr afterwards, with the mode
taken from the reparse tag (S_IFLNK) and no target. The probe is skipped
by couldbe_mf_symlink() and returns 0, so the caller sees success. A new
lookup then instantiates a symlink without a target (readlink() fails
with -EOPNOTSUPP instead of the lookup failing), and a revalidation
keeps serving the previously cached target. Before the commit above the
probe result was ignored, so without the cifsacl and modefromsid mount
options the reparse error was returned.

With those options the same error can already be overwritten by the
following cifs_acl_to_fattr() assignment in cifs_get_fattr(). That is
older than the commit above and is not addressed here.

Only run the probe when no error has been seen so far, so that the
earlier error is returned as it was before.

This issue was found by manual code review with the help of an AI coding
assistant (Claude Opus 5.5), which also drafted this patch. It has been
compile-tested with W=1 and smatch on x86_64 allmodconfig (no new
warnings; smatch reports the same two pre-existing warnings in this file
before and after). It has not been runtime-tested and no reproducer was
built: the failure needs a server returning a malformed reparse point on
an mfsymlinks mount.

Fixes: 7c4bf530aefa ("smb: client: avoid breaking the file lease when probing mfsymlinks")
Signed-off-by: bob <bobmcd@tuta.io>
---
smb: client: don't let the mfsymlinks probe overwrite an earlier error
---
 fs/smb/client/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index 2647785ec1e4..70f3a86014a5 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -1440,7 +1440,7 @@ static int cifs_get_fattr(struct cifs_open_info_data *data,
 
 
 	/* check for Minshall+French symlinks */
-	if (sbflags & CIFS_MOUNT_MF_SYMLINKS) {
+	if (!rc && (sbflags & CIFS_MOUNT_MF_SYMLINKS)) {
 		rc = cifs_check_mf_symlink(xid, tcon, cifs_sb, full_path,
 					   *inode, fattr);
 	}
@@ -1540,7 +1540,7 @@ static int smb311_posix_get_fattr(struct cifs_open_info_data *data,
 	 * 3. Tweak fattr based on mount options
 	 */
 	/* check for Minshall+French symlinks */
-	if (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_MF_SYMLINKS) {
+	if (!rc && (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_MF_SYMLINKS)) {
 		rc = cifs_check_mf_symlink(xid, tcon, cifs_sb, full_path,
 					   inode, fattr);
 	}

---
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
change-id: 20261203-fix-c1-cifs-mfsymlinks-rc-9b4332e99de2

Best regards,
--  
bob <bobmcd@tuta.io>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-02 23:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 19:55 [PATCH] smb: client: don't let the mfsymlinks probe overwrite an earlier error bob
2026-12-02 19:55 ` bob via B4 Relay
2026-12-02 23:52 ` Paulo Alcantara

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.