Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Hex Rabbit <h3xrabbit@gmail.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
	linkinjeon@kernel.org, sfrench@samba.org, tom@talpey.com,
	linux-cifs@vger.kernel.org
Subject: Re: [PATCH] ksmbd: fix slab-out-of-bounds read in smb2_handle_negotiate
Date: Thu, 18 May 2023 09:33:40 +0900	[thread overview]
Message-ID: <20230518003340.GD20467@google.com> (raw)
In-Reply-To: <CAF3ZFef4gmEVZR5riwdB1bkB4CccziGw3g18cyz7Sim4xw+ZDw@mail.gmail.com>

On (23/05/17 19:45), Hex Rabbit wrote:
>    The out-of-bounds access is triggered by `req->DialectCount` memory
>    access,
>    sender can construct a malformed packet that only has a single 
>    `smb2_negotiate_req.StructureSize` field after the smb2 header.

Oh, I see, is that what you did in your reproducer?

>    Referring to the payload I showed below, since the function is 
>    assuming that the entire `smb2_negotiate_req` structure is presented, 
>    it will read above the `StructureSize` field (2400) and trigger KASAN. 
>    So check against `smb2_buf_len` first will ensure entire structure 
>    is inside the buffer, hope this make sense!
>    ```
>    00000000: 0000 0042 fe53 4d42 4000 0000 0000 0000  ...B.SMB@.......
>    00000010: 0000 0000 0000 0000 0000 0000 0000 0000  ................
>    00000020: 0000 0000 0000 0000 0000 0000 0000 0000  ................
>    00000030: 0000 0000 0000 0000 0000 0000 0000 0000  ................
>    00000040: 0000 0000 2400                                              
>    ....$.
>    ```
>    sorry for not providing full symbolized stack trace first

Thanks for clarifications. Maybe would be nice to have some of these
lines in the commit message.

>    Call Trace:
>    dump_stack_lvl (lib/dump_stack.c:107)
>    print_report (mm/kasan/report.c:352 mm/kasan/report.c:462)
>    kasan_report (mm/kasan/report.c:574)
>    smb2_handle_negotiate (fs/ksmbd/smb2pdu.c:1060)

I'm still puzzled by smb2_handle_negotiate+0x35d7/0x3e60 in the original
stack trace. 0x35d7/0x3e60 certainly doesn't translate to "start of the
function" to me, but what do I know :)

  parent reply	other threads:[~2023-05-18  0:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-17  9:59 [PATCH] ksmbd: fix slab-out-of-bounds read in smb2_handle_negotiate HexRabbit
2023-05-17 10:17 ` Namjae Jeon
2023-05-17 11:02   ` Sergey Senozhatsky
2023-05-17 11:05 ` Sergey Senozhatsky
2023-05-17 11:13   ` Sergey Senozhatsky
     [not found]     ` <CAF3ZFef4gmEVZR5riwdB1bkB4CccziGw3g18cyz7Sim4xw+ZDw@mail.gmail.com>
2023-05-18  0:33       ` Sergey Senozhatsky [this message]
2023-05-18  8:43         ` Hex Rabbit

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=20230518003340.GD20467@google.com \
    --to=senozhatsky@chromium.org \
    --cc=h3xrabbit@gmail.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=sfrench@samba.org \
    --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