diff options
author | Namjae Jeon <linkinjeon@kernel.org> | 2022-09-22 23:36:34 +0900 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2022-10-05 01:15:44 -0500 |
commit | af705ef2b0ded0d8f54c238fdf3c17a1d47ad924 (patch) | |
tree | bc61c27e0dc14e62b584bc8dc9c60bc25cc992ba /fs/ksmbd/auth.c | |
parent | 360c8ee6fefdb496fffd2c18bb9a96a376a1a804 (diff) | |
download | linux-af705ef2b0ded0d8f54c238fdf3c17a1d47ad924.tar.gz linux-af705ef2b0ded0d8f54c238fdf3c17a1d47ad924.tar.bz2 linux-af705ef2b0ded0d8f54c238fdf3c17a1d47ad924.zip |
ksmbd: fix encryption failure issue for session logoff response
If client send encrypted session logoff request on seal mount,
Encryption for that response fails.
ksmbd: Could not get encryption key
CIFS: VFS: cifs_put_smb_ses: Session Logoff failure rc=-512
Session lookup fails in ksmbd_get_encryption_key() because sess->state is
set to SMB2_SESSION_EXPIRED in session logoff. There is no need to do
session lookup again to encrypt the response. This patch change to use
ksmbd_session in ksmbd_work.
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/ksmbd/auth.c')
-rw-r--r-- | fs/ksmbd/auth.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/ksmbd/auth.c b/fs/ksmbd/auth.c index c5a5c7b90d72..2330d7754cf6 100644 --- a/fs/ksmbd/auth.c +++ b/fs/ksmbd/auth.c @@ -984,13 +984,16 @@ out: return rc; } -static int ksmbd_get_encryption_key(struct ksmbd_conn *conn, __u64 ses_id, +static int ksmbd_get_encryption_key(struct ksmbd_work *work, __u64 ses_id, int enc, u8 *key) { struct ksmbd_session *sess; u8 *ses_enc_key; - sess = ksmbd_session_lookup_all(conn, ses_id); + if (enc) + sess = work->sess; + else + sess = ksmbd_session_lookup_all(work->conn, ses_id); if (!sess) return -EINVAL; @@ -1078,9 +1081,10 @@ static struct scatterlist *ksmbd_init_sg(struct kvec *iov, unsigned int nvec, return sg; } -int ksmbd_crypt_message(struct ksmbd_conn *conn, struct kvec *iov, +int ksmbd_crypt_message(struct ksmbd_work *work, struct kvec *iov, unsigned int nvec, int enc) { + struct ksmbd_conn *conn = work->conn; struct smb2_transform_hdr *tr_hdr = smb2_get_msg(iov[0].iov_base); unsigned int assoc_data_len = sizeof(struct smb2_transform_hdr) - 20; int rc; @@ -1094,7 +1098,7 @@ int ksmbd_crypt_message(struct ksmbd_conn *conn, struct kvec *iov, unsigned int crypt_len = le32_to_cpu(tr_hdr->OriginalMessageSize); struct ksmbd_crypto_ctx *ctx; - rc = ksmbd_get_encryption_key(conn, + rc = ksmbd_get_encryption_key(work, le64_to_cpu(tr_hdr->SessionId), enc, key); |