All of lore.kernel.org
 help / color / mirror / Atom feed
From: ChenXiaoSong <chenxiaosong.chenxiaosong@linux.dev>
To: Namjae Jeon <linkinjeon@kernel.org>, David Howells <dhowells@redhat.com>
Cc: sfrench@samba.org, smfrench@gmail.com, linkinjeon@samba.org,
	pc@manguebit.org, ronniesahlberg@gmail.com,
	sprasad@microsoft.com, tom@talpey.com, bharathsm@microsoft.com,
	senozhatsky@chromium.org, linux-cifs@vger.kernel.org,
	ChenXiaoSong <chenxiaosong@kylinos.cn>
Subject: Re: [PATCH] smb/server: fix SMB2_MIN_SUPPORTED_HEADER_SIZE value
Date: Fri, 19 Dec 2025 18:42:43 +0800	[thread overview]
Message-ID: <056E09CC-95A0-4775-82AB-3DB8756CA94F@linux.dev> (raw)
In-Reply-To: <CAKYAXd_owC9vmSF+ukH-GgG5mWwFWGtwrXNT-8gfUZGHVDTcRA@mail.gmail.com>

OK, I will send v2 soon.
Thanks,
ChenXiaoSong.

On December 19, 2025 6:32:18 PM GMT+08:00, Namjae Jeon <linkinjeon@kernel.org> wrote:
>On Fri, Dec 19, 2025 at 5:18 PM David Howells <dhowells@redhat.com> wrote:
>>
>> Namjae Jeon <linkinjeon@kernel.org> wrote:
>>
>> > > We should rename them to `SMB1_MIN_SUPPORTED_PDU_SIZE` and
>> > > `SMB2_MIN_SUPPORTED_PDU_SIZE`.
>> > >
>> > > But we "should not" add "+4" to them.
>> > Not adding the +4 will trigger a slab-out-of-bounds issue.
>> > You should check ksmbd_smb2_check_message() and
>> > ksmbd_negotiate_smb_dialect() as well as ksmbd_conn_handler_loop().
>> > ...
>> > >    pdu_size = get_rfc1002_len(hdr_buf);
>> > >    ...
>> > >    if (pdu_size < SMB1_MIN_SUPPORTED_HEADER_SIZE)
>> > >    ...
>> > >    if (pdu_size < SMB2_MIN_SUPPORTED_HEADER_SIZE)
>>
>> As previously mentioned, the problem I have with the +4 accounting for the
>> RFC1002 header is that the size value in pdu_size does not include the size of
>> the RFC1002 header, so the comparison seems to be allowing an overlong header.
>>
>> However, I think the +4 actually makes sense for SMB2/3 - assuming the +4
>> isn't actually for the RFC1002 size, but is rather for the StructureSize of
>> the operation header that follows immediately after the smb2_hdr.
>Right.
>>
>> If that's the case, I would guess that the SMB1 variant might want a +2 to
>> allow for the BCC field...  but according to the code in cifs side that I've
>> looked at, some servers may only provide half a BCC field - or maybe even
>> forget to put it in entirely.
>ksmbd only handles SMB1 negotiate requests in smb1 protocol, And the
>BCC (Byte Count) field of smb1 negotiate request must be greater than
>or equal to 2. This is why I originally treated any SMB1 request
>smaller than smb_hdr + 4 as an invalid packet. However, even if we add
>+2, it will be no problem because ksmbd_negotiate_smb_dialect() checks
>to verify if the BCC field is less than 2.
>
>ChenXiaoSong, If you agree with this, Can you make the v2 patch ?
>
>Thanks.
>>
>> David
>>

  reply	other threads:[~2025-12-19 10:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-18 17:10 [PATCH] smb/server: fix SMB2_MIN_SUPPORTED_HEADER_SIZE value chenxiaosong.chenxiaosong
2025-12-19  0:16 ` Namjae Jeon
2025-12-19  0:59   ` ChenXiaoSong
2025-12-19  1:16     ` Namjae Jeon
2025-12-19  1:30       ` ChenXiaoSong
2025-12-19  1:42         ` Namjae Jeon
2025-12-19  1:45           ` ChenXiaoSong
2025-12-19  8:17       ` David Howells
2025-12-19 10:32         ` Namjae Jeon
2025-12-19 10:42           ` ChenXiaoSong [this message]
2025-12-19 10:50           ` David Howells
2025-12-19 11:52             ` Namjae Jeon
2025-12-19 13:53               ` ChenXiaoSong

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=056E09CC-95A0-4775-82AB-3DB8756CA94F@linux.dev \
    --to=chenxiaosong.chenxiaosong@linux.dev \
    --cc=bharathsm@microsoft.com \
    --cc=chenxiaosong@kylinos.cn \
    --cc=dhowells@redhat.com \
    --cc=linkinjeon@kernel.org \
    --cc=linkinjeon@samba.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=pc@manguebit.org \
    --cc=ronniesahlberg@gmail.com \
    --cc=senozhatsky@chromium.org \
    --cc=sfrench@samba.org \
    --cc=smfrench@gmail.com \
    --cc=sprasad@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.