Linux USB
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Shunbo Shi <shishunbo@cmss.chinamobile.com>
Cc: dan@pereq.eu, elder@kernel.org, gregkh@linuxfoundation.org,
	greybus-dev@lists.linaro.org, johan@kernel.org,
	linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev,
	linux-usb@vger.kernel.org,
	syzbot+0b456664585fa81a47f6@syzkaller.appspotmail.com,
	syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH v3] greybus: verify the received message size covers the message header
Date: Sat, 14 Nov 2026 08:01:29 +0300	[thread overview]
Message-ID: <avfrKSBbpEp7vQyO@stanley.mountain> (raw)
In-Reply-To: <20261113234739.1432-1-shishunbo@cmss.chinamobile.com>

On Fri, Nov 13, 2026 at 11:47:39PM +0000, Shunbo Shi wrote:
> In gb_connection_recv(), the size of the received data is checked
> against sizeof(struct gb_operation_msg_hdr) and against the message
> size encoded in the header (msg_size), but msg_size itself is never
> checked against the header size.
> 
> If a peer sends a message whose header claims a size smaller than
> the header itself (e.g. header.size == 3), the two existing checks
> both pass (size >= sizeof(header) and size >= msg_size), and the
> message is dispatched with the undersized msg_size.
> 
> In gb_operation_create_incoming(), this leads to an unsigned
> integer underflow in:
> 
> 	request_size = size - sizeof(struct gb_operation_msg_hdr);
> 
> The underflowed request_size then wraps back around in
> gb_operation_message_alloc():
> 
> 	message_size = payload_size + sizeof(*header);
> 
> causing kzalloc() to allocate a buffer that is too small to hold
> the message header.  When the response is later prepared in
> gb_operation_response_alloc(), reading
> request_header->operation_id reads past the end of the undersized
> allocation, triggering a KASAN slab-out-of-bounds report.
> 
> Link: https://lore.kernel.org/all/sashiko-outbox-210716@kernel.org/T/
> Fixes: d90c25b0a279 ("greybus: let operation layer examine incoming data")
> Reported-by: syzbot+0b456664585fa81a47f6@syzkaller.appspotmail.com
> Closes: https://syzbot.org/bug?extid=0b456664585fa81a47f6
> Signed-off-by: Shunbo Shi <shishunbo@cmss.chinamobile.com>
> ---
> Changes in v3:
> - combine the two separate conditions and unify the error message
>  as suggested by dan. Thanks!

Thanks!

Reviewed-by: Dan Carpenter <error27@gmail.com>

regards,
dan carpenter


      parent reply	other threads:[~2026-11-14  5:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12  5:56 [syzbot] [greybus?] [usb?] KASAN: slab-out-of-bounds Read in gb_operation_work syzbot
2026-11-12  8:22 ` [PATCH] greybus: verify the received message size covers the message header Shunbo Shi
2026-11-12  8:27   ` sashiko-bot
2026-11-12  8:43   ` Dan Carpenter
2026-11-13 23:47     ` [PATCH v3] " Shunbo Shi
2026-11-13 23:51       ` sashiko-bot
2026-11-14  5:01       ` Dan Carpenter [this message]

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=avfrKSBbpEp7vQyO@stanley.mountain \
    --to=error27@gmail.com \
    --cc=dan@pereq.eu \
    --cc=elder@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=greybus-dev@lists.linaro.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=linux-usb@vger.kernel.org \
    --cc=shishunbo@cmss.chinamobile.com \
    --cc=syzbot+0b456664585fa81a47f6@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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