7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Namjae Jeon commit 19f8fd6b5ced33b02a083759e6901f9d6e8076df upstream. A failed multichannel binding can retain its target session on the work item so that the error response can be signed. Subsequent compound commands can then use that session together with a tree connection left over from an earlier command. Limit binding SESSION_SETUP requests to standalone messages during message validation, before smb2_sess_setup() can replace work->sess. Check both NextCommand and the current request offset to cover binding in the first, middle and last positions of a compound. The existing validation error path returns STATUS_INVALID_PARAMETER and stops processing the remaining commands. This intentionally limits support for compounded binding. It is not a protocol requirement that binding be standalone. Standalone binding and non-binding compounds retain their existing behavior, without changing session, tree or response encryption handling. Fixes: 4b706360ffb7 ("ksmbd: fix multichannel binding and enforce channel limit") Cc: stable@vger.kernel.org Reported-by: Zeng Adolph Signed-off-by: Namjae Jeon Signed-off-by: Greg Kroah-Hartman --- fs/smb/server/smb2misc.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/fs/smb/server/smb2misc.c +++ b/fs/smb/server/smb2misc.c @@ -501,6 +501,14 @@ int ksmbd_smb2_check_message(struct ksmb if (req_struct_size > len + 1) return 1; + if (command == SMB2_SESSION_SETUP_HE && + (work->next_smb2_rcv_hdr_off || next_cmd)) { + struct smb2_sess_setup_req *req = (void *)hdr; + + if (req->Flags & SMB2_SESSION_REQ_FLAG_BINDING) + return 1; + } + if (smb2_calc_size(hdr, &clc_len)) return 1;