All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Yang Zi <2959243019@qq.com>
Cc: elder@kernel.org, gregkh@linuxfoundation.org,
	greybus-dev@lists.linaro.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] greybus: operation: Fix NULL pointer dereference in gb_operation_message_alloc()
Date: Tue, 25 Aug 2026 16:12:08 +0200	[thread overview]
Message-ID: <ao2iuKpS3YPspthU@hovoldconsulting.com> (raw)
In-Reply-To: <tencent_4F423FBD3FCE6066A8538BB3CFBCB0C41E09@qq.com>

On Tue, Aug 25, 2026 at 05:23:09PM +0800, Yang Zi wrote:
> gb_connection_recv() reads msg_size from the received message header but
> only rejects it when it is larger than the received buffer
> ("size < msg_size"); it does not reject msg_size smaller than the message
> header itself.  A malicious or corrupted header.size of 0 passes that
> check and is forwarded to gb_operation_create_incoming() with size 0.
> 
> There, request_size = size - sizeof(struct gb_operation_msg_hdr)
> underflows to SIZE_MAX - 7, and in gb_operation_message_alloc()
> message_size = payload_size + sizeof(*header) wraps back around to 0.
> The "message_size > hd->buffer_size_max" check is therefore bypassed,
> kzalloc(0) returns ZERO_SIZE_PTR, and gb_operation_message_init() writes
> header->size to that pointer.
> 
> KASAN report:
> 
>     BUG: KASAN: null-ptr-deref in gb_operation_message_init drivers/greybus/operation.c:340 [inline] [greybus]
>     BUG: KASAN: null-ptr-deref in gb_operation_message_alloc+0xab4/0xdb0 drivers/greybus/operation.c:385 [greybus]
>     Write of size 2 at addr 0000000000000010 by task syz.0.1/1100
> 
> Fix this by rejecting messages whose claimed size is smaller than the
> message header in gb_connection_recv(), and additionally make
> gb_operation_message_alloc() overflow-safe by comparing the payload size
> against hd->buffer_size_max - sizeof(*header) before adding the header
> size.
> 
> Signed-off-by: Yang Zi <2959243019@qq.com>

How was this issue found and fixed? Did you use an LLM and are missing
an Assisted-by tag?

Based on a quick glance, this look correct, but your patch is corrupt
and cannot be applied. (This appears to be the case with all the 30+
patches you sent out today.)

Please fix your mail setup and send a v2 (try sending it to yourself
first and make sure you can apply it and run checkpatch on it). You
should look into using git-send-email.

Johan

      reply	other threads:[~2026-08-25 14:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25  9:23 [PATCH] greybus: operation: Fix NULL pointer dereference in gb_operation_message_alloc() Yang Zi
2026-08-25 14:12 ` Johan Hovold [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=ao2iuKpS3YPspthU@hovoldconsulting.com \
    --to=johan@kernel.org \
    --cc=2959243019@qq.com \
    --cc=elder@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=greybus-dev@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    /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.