[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20251106065804.363242-1-pioooooooooip@gmail.com>
Date: Thu, 6 Nov 2025 15:58:04 +0900
From: Qianchang Zhao <pioooooooooip@...il.com>
To: Namjae Jeon <linkinjeon@...nel.org>,
linux-cifs@...r.kernel.org
Cc: Steve French <smfrench@...il.com>,
Sergey Senozhatsky <senozhatsky@...omium.org>,
Tom Talpey <tom@...pey.com>,
linux-kernel@...r.kernel.org,
stable@...r.kernel.org,
gregkh@...uxfoundation.org,
Qianchang Zhao <pioooooooooip@...il.com>,
Zhitong Liu <liuzhitong1993@...il.com>
Subject: [PATCH v2] ksmbd: clear 'encrypted' on encrypt_resp() failure to send plaintext error
When encrypt_resp() fails in the send path, we set STATUS_DATA_ERROR but
leave work->encrypted true. The send path then still assumes a valid
transform buffer and tries to build/send an encrypted reply.
Clear work->encrypted on failure to force a plaintext error reply.
The transform buffer (if allocated) is released by ksmbd_free_work_struct(),
so no explicit kvfree(tr_buf) is needed.
Reported-by: Qianchang Zhao <pioooooooooip@...il.com>
Reported-by: Zhitong Liu <liuzhitong1993@...il.com>
Cc: stable@...r.kernel.org
Signed-off-by: Qianchang Zhao <pioooooooooip@...il.com>
---
v2:
- Drop explicit kvfree(tr_buf); it is freed in ksmbd_free_work_struct().
- Keep only 'work->encrypted = false' and update the commit message.
fs/smb/server/server.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/smb/server/server.c b/fs/smb/server/server.c
index 40420544c..a7444a78f 100644
--- a/fs/smb/server/server.c
+++ b/fs/smb/server/server.c
@@ -244,8 +244,10 @@ static void __handle_ksmbd_work(struct ksmbd_work *work,
if (work->sess && work->sess->enc && work->encrypted &&
conn->ops->encrypt_resp) {
rc = conn->ops->encrypt_resp(work);
- if (rc < 0)
+ if (rc < 0) {
conn->ops->set_rsp_status(work, STATUS_DATA_ERROR);
+ work->encrypted = false;
+ }
}
if (work->sess)
ksmbd_user_session_put(work->sess);
--
2.34.1
Powered by blists - more mailing lists