mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Enzo Matsumiya <ematsumiya@suse.de>
To: shyckless@gmail.com
Cc: pc@manguebit.org, linkinjeon@kernel.org,
	linux-cifs@vger.kernel.org,  sprasad@microsoft.com,
	smfrench@gmail.com, ronniesahlberg@gmail.com,
	 bharathsm@microsoft.com, linux-kernel@vger.kernel.org,
	 daniel.birtwhistle@gehealthcare.com,
	samba-technical@lists.samba.org, tom@talpey.com
Subject: Re: [PATCH] smb: client: fail SMB2 responses with a bad signature
Date: Fri, 13 Nov 2026 09:16:56 -0300	[thread overview]
Message-ID: <avb81ry-kS6GfWkO@suse.de> (raw)
In-Reply-To: <20261113-smb2-sign-v1-1-937ee7c20f08@gmail.com>

On 11/13, Suyuan Wang via B4 Relay wrote:
>From: Suyuan Wang <stevewong@hust.edu.cn>
>
>smb2_check_receive() checks the response signature when signing is on,
>but a failed check is only logged:
>
>    rc = smb2_verify_signature(&rqst, server);
>    if (rc)
>            cifs_server_dbg(VFS, "SMB signature verification returned ...",
>                            rc);
>    ...
>    return map_smb2_to_linux_error(mid->resp_buf, log_error);
>
>The status from the response is returned as usual, and the caller goes
>on to use a response whose signature is wrong. This is the path for
>synchronous requests and for smb2_writev_callback(). On a signed but
>unencrypted connection, anyone who can modify the traffic can change
>e.g. a directory listing, and the client accepts it.
>
>Return the verification error instead.
>
>Unlike the SMB1 fix in commit dc96f01d54cc ("smb: client: terminate
>session upon failed client required signing"), don't reconnect: this
>runs in the thread that sent the request, and only cifsd should call
>cifs_reconnect(). And fail the request whichever side required signing,
>since a response with a bad signature can't be trusted either way.
>
>Found with a static analysis tool and checked by hand.
>
>Reported-by: Daniel Birtwhistle <daniel.birtwhistle@gehealthcare.com>
>Closes: https://lore.kernel.org/linux-cifs/SN4PR22MB28883DAF57E0B4D4BFB1C22AEEC42@SN4PR22MB2888.namprd22.prod.outlook.com/
>Fixes: 3c1bf7e48e9e ("CIFS: Enable signing in SMB2")
>Cc: stable@vger.kernel.org
>Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
>Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
>Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
>---
>We found this on our own and only saw Daniel's report afterwards.
>
>For SMB1 Steve wanted to keep just logging when the server, but not the
>client, required signing:
>https://lore.kernel.org/all/CAH2r5msfYRdaGAMuTbni-0T20tQi=N=fT4qxiaQ3siQ_WVm=Qg@mail.gmail.com/
>This patch doesn't make that exception. If you want it here too, I can
>send a v2 that remembers whether the client required signing.
>
>Tested in QEMU with Samba 4.15 (server signing = mandatory, mounted with
>vers=3.1.1,sign) and a proxy in between that renames a file in
>QUERY_DIRECTORY responses and leaves the signature as is. Before the
>patch the renamed file shows up in getdents64(), after it getdents64()
>fails with EACCES. Mount, read and write on the same connection still
>work, and lockdep stayed quiet.
>---
> fs/smb/client/smb2transport.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
>diff --git a/fs/smb/client/smb2transport.c b/fs/smb/client/smb2transport.c
>index 080864b24a0c..62121d7a44a8 100644
>--- a/fs/smb/client/smb2transport.c
>+++ b/fs/smb/client/smb2transport.c
>@@ -711,9 +711,11 @@ smb2_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
> 		int rc;
>
> 		rc = smb2_verify_signature(&rqst, server);
>-		if (rc)
>+		if (rc) {
> 			cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",
> 				 rc);
>+			return rc;
>+		}

Reading my reply to that other patch again https://lore.kernel.org/all/s4kmfu25glkgu44wl46e3q3bjvyhlbcvnlaiuqkuey4qlg4d5o@s7ispothcved/
I now think that, indeed, reconnecting on mismatching signatures might
be too much.

However, I still think the error should only be returned if signing is
required (*) AND rc == -EACCES.

Any other error should always be returned unconditionally.

(*) Note that "signing required" at that point means that either/both
client and server required signing, and the other side agreed -- it
doesn't really matter who asked for it.

> 	}
>
> 	return map_smb2_to_linux_error(mid->resp_buf, log_error);
>
>---

You might want to strip the lines below.

>base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47
>change-id: 20261113-smb2-sign-2f316c91c873
>
>Best regards,
>--
>Suyuan Wang <shyckless@gmail.com>


Cheers,

Enzo

      reply	other threads:[~2026-11-13 12:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 12:00 Suyuan Wang via B4 Relay
2026-11-13 12:16 ` Enzo Matsumiya [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=avb81ry-kS6GfWkO@suse.de \
    --to=ematsumiya@suse.de \
    --cc=bharathsm@microsoft.com \
    --cc=daniel.birtwhistle@gehealthcare.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pc@manguebit.org \
    --cc=ronniesahlberg@gmail.com \
    --cc=samba-technical@lists.samba.org \
    --cc=shyckless@gmail.com \
    --cc=smfrench@gmail.com \
    --cc=sprasad@microsoft.com \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®