Re: [PATCH v7 3/9] ksmbd: add and use ksmbd_smb2_cur_pdu_buflen() in ksmbd_smb2_check_message()

Namjae Jeon
2021-10-05T07:29:56Z

2021-10-05 14:03 GMT+09:00, Ralph Boehme <slow@samba.org>:
> No change in behaviour.
>
> Cc: Namjae Jeon <linkinjeon@kernel.org>
> Cc: Tom Talpey <tom@talpey.com>
> Cc: Ronnie Sahlberg <ronniesahlberg@gmail.com>
> Cc: Steve French <smfrench@gmail.com>
> Cc: Hyunchul Lee <hyc.lee@gmail.com>
> Signed-off-by: Ralph Boehme <slow@samba.org>
> ---
> fs/ksmbd/smb2misc.c | 36 +++++++++++++++++++++++++++---------
> fs/ksmbd/smb2pdu.h | 1 +
> 2 files changed, 28 insertions(+), 9 deletions(-)
>
> diff --git a/fs/ksmbd/smb2misc.c b/fs/ksmbd/smb2misc.c
> index 2cc031c39514..7ed266eb6c5e 100644
> --- a/fs/ksmbd/smb2misc.c
> +++ b/fs/ksmbd/smb2misc.c
> @@ -333,14 +333,7 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work)
> struct smb2_hdr *hdr = &pdu->hdr;
> int command;
> __u32 clc_len; /* calculated length */
> - __u32 len = get_rfc1002_len(pdu);
> -
> - if (le32_to_cpu(hdr->NextCommand) > 0) {
> - len = le32_to_cpu(hdr->NextCommand);
> - } else if (work->next_smb2_rcv_hdr_off) {
> - len -= work->next_smb2_rcv_hdr_off;
> - len = round_up(len, 8);
> - }
> + __u32 len = ksmbd_smb2_cur_pdu_buflen(work);
>
> if (check_smb2_hdr(hdr))
> return 1;
> @@ -395,7 +388,7 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work)
> * Some windows servers (win2016) will pad also the final
> * PDU in a compound to 8 bytes.
> */
> - if (ALIGN(clc_len, 8) == len)
> + if (ALIGN(clc_len, 8) == ALIGN(len, 8))
Can I know why you align rfc1002 len with 8 here ?

Thanks!