Re: [PATCH v2 1/2] smb: client: fail SMB2 responses with a bad signature
From: Paulo Alcantara
Date: Wed Nov 18 2026 - 17:03:39 EST
Suyuan Wang via B4 Relay <devnull+shyckless.gmail.com@xxxxxxxxxx>
writes:
> From: Suyuan Wang <stevewong@xxxxxxxxxxx>
>
> 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 and compound 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 or file attributes, and the client
> accepts it.
>
> Return the verification error instead. That alone is not enough for
> compound_send_recv(), which still hands the response buffer to the
> caller after check_receive() fails. smb2_compound_op() then maps the
> status from that buffer again and copies the payload out, and other
> callers look at the buffer on error too, e.g. smb2_open_file() parses
> a symlink target out of a STATUS_STOPPED_ON_SYMLINK response. So also
> mark the mid MID_RESPONSE_MALFORMED, and have compound_send_recv() handle
> it like a mid in a bad state: mark the earlier mids cancelled, so that a
> CREATE which did succeed gets its handle closed, and don't pass any
> response on.
>
> 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.
> ...
Applied.