From: Namjae Jeon <linkinjeon@kernel.org>
To: gregkh@linuxfoundation.org, sashal@kernel.org
Cc: stable@vger.kernel.org, Li Nan <linan122@huawei.com>,
Tom Talpey <tom@talpey.com>, Namjae Jeon <linkinjeon@kernel.org>,
Steve French <stfrench@microsoft.com>
Subject: [PATCH 5.15.y 01/11] ksmbd: validate the zero field of packet header
Date: Sun, 21 Jan 2024 23:30:28 +0900 [thread overview]
Message-ID: <20240121143038.10589-2-linkinjeon@kernel.org> (raw)
In-Reply-To: <20240121143038.10589-1-linkinjeon@kernel.org>
From: Li Nan <linan122@huawei.com>
[ Upstream commit 516b3eb8c8065f7465f87608d37a7ed08298c7a5 ]
The SMB2 Protocol requires that "The first byte of the Direct TCP
transport packet header MUST be zero (0x00)"[1]. Commit 1c1bcf2d3ea0
("ksmbd: validate smb request protocol id") removed the validation of
this 1-byte zero. Add the validation back now.
[1]: [MS-SMB2] - v20230227, page 30.
https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-SMB2/%5bMS-SMB2%5d-230227.pdf
Fixes: 1c1bcf2d3ea0 ("ksmbd: validate smb request protocol id")
Signed-off-by: Li Nan <linan122@huawei.com>
Acked-by: Tom Talpey <tom@talpey.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
---
fs/ksmbd/smb_common.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/fs/ksmbd/smb_common.c b/fs/ksmbd/smb_common.c
index d160363c09eb..e90a1e8c1951 100644
--- a/fs/ksmbd/smb_common.c
+++ b/fs/ksmbd/smb_common.c
@@ -158,8 +158,12 @@ int ksmbd_verify_smb_message(struct ksmbd_work *work)
*/
bool ksmbd_smb_request(struct ksmbd_conn *conn)
{
- __le32 *proto = (__le32 *)smb2_get_msg(conn->request_buf);
+ __le32 *proto;
+ if (conn->request_buf[0] != 0)
+ return false;
+
+ proto = (__le32 *)smb2_get_msg(conn->request_buf);
if (*proto == SMB2_COMPRESSION_TRANSFORM_ID) {
pr_err_ratelimited("smb2 compression not support yet");
return false;
--
2.25.1
next prev parent reply other threads:[~2024-01-21 14:31 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-21 14:30 [PATCH 5.15.y 00/11] ksmbd: backport patches from 6.8-rc1 Namjae Jeon
2024-01-21 14:30 ` Namjae Jeon [this message]
2024-01-21 14:30 ` [PATCH 5.15.y 02/11] ksmbd: set v2 lease version on lease upgrade Namjae Jeon
2024-01-21 14:30 ` [PATCH 5.15.y 03/11] ksmbd: fix potential circular locking issue in smb2_set_ea() Namjae Jeon
2024-01-21 14:30 ` [PATCH 5.15.y 04/11] ksmbd: don't increment epoch if current state and request state are same Namjae Jeon
2024-01-21 14:30 ` [PATCH 5.15.y 05/11] ksmbd: don't allow O_TRUNC open on read-only share Namjae Jeon
2024-01-21 14:30 ` [PATCH 5.15.y 06/11] ksmbd: send lease break notification on FILE_RENAME_INFORMATION Namjae Jeon
2024-01-21 14:30 ` [PATCH 5.15.y 07/11] ksmbd: free ppace array on error in parse_dacl Namjae Jeon
2024-01-21 14:30 ` [PATCH 5.15.y 08/11] ksmbd: Add missing set_freezable() for freezable kthread Namjae Jeon
2024-01-21 14:30 ` [PATCH 5.15.y 09/11] ksmbd: validate mech token in session setup Namjae Jeon
2024-01-21 14:30 ` [PATCH 5.15.y 10/11] ksmbd: fix UAF issue in ksmbd_tcp_new_connection() Namjae Jeon
2024-01-21 14:30 ` [PATCH 5.15.y 11/11] ksmbd: only v2 leases handle the directory Namjae Jeon
2024-01-22 15:03 ` [PATCH 5.15.y 00/11] ksmbd: backport patches from 6.8-rc1 Greg KH
2024-01-22 23:28 ` Namjae Jeon
2024-01-26 1:25 ` Namjae Jeon
2024-01-26 1:36 ` Greg KH
2024-01-26 1:59 ` Namjae Jeon
2024-01-27 0:43 ` Greg KH
2024-01-27 0:48 ` Namjae Jeon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240121143038.10589-2-linkinjeon@kernel.org \
--to=linkinjeon@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linan122@huawei.com \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
--cc=stfrench@microsoft.com \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox