All of lore.kernel.org
 help / color / mirror / Atom feed
* ksmbd_smb_request can be removed
@ 2021-09-21  3:49 ronnie sahlberg
  2021-09-21  4:47 ` Namjae Jeon
  0 siblings, 1 reply; 2+ messages in thread
From: ronnie sahlberg @ 2021-09-21  3:49 UTC (permalink / raw)
  To: linux-cifs, Namjae Jeon

In smb_common.c you have this function :   ksmbd_smb_request() which
is called from connection.c once you have read the initial 4 bytes for
the next length+smb2 blob.

It checks the first byte of this 4 byte preamble for valid values,
i.e. a NETBIOSoverTCP SESSION_MESSAGE or a SESSION_KEEP_ALIVE.

We don't need to check this for ksmbd since it only implements SMB2
over TCP port 445.
The netbios stuff was only used in very old servers when SMB ran over
TCP port 139.
Now that we run over TCP port 445, this is actually not a NB header anymore
and you can just treat it as a 4 byte length field that must be less
than 16Mbyte.

I.e. you can change it to just be :
bool ksmbd_smb_request(struct ksmbd_conn *conn)
{
    return conn->request_buf[0] == 0;
}

and remove the references to the RFC1002 constants that no longer applies.

(See MS-SMB2 2.1)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: ksmbd_smb_request can be removed
  2021-09-21  3:49 ksmbd_smb_request can be removed ronnie sahlberg
@ 2021-09-21  4:47 ` Namjae Jeon
  0 siblings, 0 replies; 2+ messages in thread
From: Namjae Jeon @ 2021-09-21  4:47 UTC (permalink / raw)
  To: ronnie sahlberg; +Cc: linux-cifs

2021-09-21 12:49 GMT+09:00, ronnie sahlberg <ronniesahlberg@gmail.com>:
> In smb_common.c you have this function :   ksmbd_smb_request() which
> is called from connection.c once you have read the initial 4 bytes for
> the next length+smb2 blob.
>
> It checks the first byte of this 4 byte preamble for valid values,
> i.e. a NETBIOSoverTCP SESSION_MESSAGE or a SESSION_KEEP_ALIVE.
>
> We don't need to check this for ksmbd since it only implements SMB2
> over TCP port 445.
> The netbios stuff was only used in very old servers when SMB ran over
> TCP port 139.
> Now that we run over TCP port 445, this is actually not a NB header anymore
> and you can just treat it as a 4 byte length field that must be less
> than 16Mbyte.
>
> I.e. you can change it to just be :
> bool ksmbd_smb_request(struct ksmbd_conn *conn)
> {
>     return conn->request_buf[0] == 0;
> }
>
> and remove the references to the RFC1002 constants that no longer applies.
>
> (See MS-SMB2 2.1)
Okay, Thanks for your review, I will fix it.
Thanks!
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-21  4:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-21  3:49 ksmbd_smb_request can be removed ronnie sahlberg
2021-09-21  4:47 ` Namjae Jeon

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.