@@ -46,6 +46,7 @@ struct ksmbd_work {
u64 compound_fid;
u64 compound_pfid;
u64 compound_sid;
+ u32 compound_tid;
const struct cred *saved_cred;
@@ -97,7 +97,6 @@ int smb2_get_ksmbd_tcon(struct ksmbd_work *work)
unsigned int cmd = le16_to_cpu(req_hdr->Command);
int tree_id;
- work->tcon = NULL;
if (cmd == SMB2_TREE_CONNECT_HE ||
cmd == SMB2_CANCEL_HE ||
cmd == SMB2_LOGOFF_HE) {
@@ -110,13 +109,26 @@ int smb2_get_ksmbd_tcon(struct ksmbd_work *work)
return -ENOENT;
}
+ if (req_hdr->Flags & SMB2_FLAGS_RELATED_OPERATIONS) {
+ if (!work->tcon) {
+ pr_err("Missing tcon\n");
+ return -EINVAL;
+ }
+ return 1;
+ }
+
+ work->tcon = NULL;
+ work->compound_tid = 0;
+
tree_id = le32_to_cpu(req_hdr->Id.SyncId.TreeId);
+
work->tcon = ksmbd_tree_conn_lookup(work->sess, tree_id);
if (!work->tcon) {
pr_err("Invalid tid %d\n", tree_id);
return -EINVAL;
}
+ work->compound_tid = tree_id;
return 1;
}
Also track the tcon id of compound requests. Cc: Namjae Jeon <linkinjeon@kernel.org> Cc: Tom Talpey <tom@talpey.com> Cc: Ronnie Sahlberg <ronniesahlberg@gmail.com> Cc: Steve French <smfrench@gmail.com> Cc: Hyunchul Lee <hyc.lee@gmail.com> Signed-off-by: Ralph Boehme <slow@samba.org> --- fs/ksmbd/ksmbd_work.h | 1 + fs/ksmbd/smb2pdu.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-)