ksmbd: inherit FileIds in related compound requests
Subsystems (2)
Namjae Jeon
maintainerPATCH 1/1 ksmbd: inherit FileIds in related compound requests
MS-SMB2 specifies that subsequent related operations use the FileId from the preceding operation. Track FileIds from handle-bearing requests so related requests that use the all-ones placeholder resolve to the inherited handle.
Return STATUS_INVALID_HANDLE when a related request refers to a FileId but the preceding operation neither contained nor generated one.
Fixes e2f34481b24d ("cifsd: add server-side procedures for SMB3")
Reported-by Ronnie Sahlberg <[email protected]>
Signed-off-by Namjae Jeon <[email protected]>
--- fs/smb/server/ksmbd_work.h | 9 ++- fs/smb/server/server.c | 5 +- fs/smb/server/smb2pdu.c | 150 ++++++++++++++++++++++++++++--------- fs/smb/server/smb2pdu.h | 1 + 4 files changed, 126 insertions(+), 39 deletions(-)
fs/smb/server/ksmbd_work.h +5 -4
@@ -54,10 +54,7 @@ struct ksmbd_work {/* Current cmd hdr in compound rsp buf*/ int curr_smb2_rsp_hdr_off; -/* -* Current Local FID assigned compound response if SMB2 CREATE -* command is present in compound request -*/ +/* FileId generated or used by the previous operation in a compound. */ u64 compound_fid;u64 compound_pfid;u64 compound_sid;
@@ -93,6 +90,10 @@ struct ksmbd_work { bool asynchronous:1; bool need_invalidate_rkey:1; bool request_open_chseq_tracked:1; +/* The previous command carries a FileId or is a CREATE. */ + bool compound_fid_present:1; +/* A related command failed because there was no FileId to inherit. */ + bool compound_fid_missing:1; bool session_setup_reauth:1;/* Retain the binding decision for response signing and preauth hashing. */ bool session_setup_binding:1;
fs/smb/server/server.c +4 -1
@@ -157,7 +157,10 @@ static int __process_request(struct ksmbd_work *work, struct ksmbd_conn *conn, } } - ret = cmds->proc (work); +if (smb2_check_compound_fid (work)) + ret = -EBADF ; +else + ret = cmds->proc (work);if (conn->ops->inc_reqs) {struct smb2_hdr *rsp =ksmbd_resp_buf_curr (work);
fs/smb/server/smb2pdu.c +116 -34
182 lines not on this page · raw message
fs/smb/server/smb2pdu.h +1 -0
@@ -421,6 +421,7 @@ bool is_smb2_rsp(struct ksmbd_work *work);u16 get_smb2_cmd_val (struct ksmbd_work *work);void set_smb2_rsp_status (struct ksmbd_work *work,__le32 err);int init_smb2_rsp_hdr (struct ksmbd_work *work); +bool smb2_check_compound_fid (struct ksmbd_work *work);int smb2_allocate_rsp_buf (struct ksmbd_work *work);bool is_chained_smb2_message (struct ksmbd_work *work);int init_smb2_neg_rsp (struct ksmbd_work *work);
Signature · 1 line
2.25.1