mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: asmadeus@codewreck.org,
	Dominique Martinet via B4 Relay
	<devnull+asmadeus.codewreck.org@kernel.org>,
	Eric Van Hensbergen <ericvh@kernel.org>,
	Latchesar Ionkov <lucho@ionkov.net>,
	Christian Schoenebeck <linux_oss@crudebyte.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Michael Grzeschik <m.grzeschik@pengutronix.de>
Cc: stable@vger.kernel.org, Yuhao Jiang <danisjiang@gmail.com>,
	security@kernel.org, v9fs@lists.linux.dev,
	linux-kernel@vger.kernel.org,
	Dominique Martinet <asmadeus@codewreck.org>
Subject: Re: [PATCH v3] net/9p: Fix buffer overflow in USB transport layer
Date: Sun, 22 Jun 2025 13:02:20 -0700	[thread overview]
Message-ID: <659844BA-48EF-47E1-8D66-D4CA98359BBF@kernel.org> (raw)
In-Reply-To: <20250622-9p-usb_overflow-v3-1-ab172691b946@codewreck.org>



On June 22, 2025 6:39:56 AM PDT, Dominique Martinet via B4 Relay <devnull+asmadeus.codewreck.org@kernel.org> wrote:
> [...]
>Add validation in usb9pfs_rx_complete() to ensure req->actual does not
>exceed the buffer capacity before copying data.
> [...]
>+	if (req_size > p9_rx_req->rc.capacity) {
>+		dev_err(&cdev->gadget->dev,
>+			"%s received data size %u exceeds buffer capacity %zu\n",
>+			ep->name, req_size, p9_rx_req->rc.capacity);
>+		req_size = 0;
>+		status = REQ_STATUS_ERROR;
>+	}
> 
>-	p9_rx_req->rc.size = req->actual;
>+	memcpy(p9_rx_req->rc.sdata, req->buf, req_size);

Is rc.sdata always rc.capacity sized? If so, this world be a good first adopter of the __counted_by annotation for pointer struct members, available in Clang trunk and soon in GCC:
https://gcc.gnu.org/pipermail/gcc-patches/2025-May/683696.html

-Kees

 

-- 
Kees Cook

  reply	other threads:[~2025-06-22 20:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-22 13:39 Dominique Martinet via B4 Relay
2025-06-22 20:02 ` Kees Cook [this message]
2025-06-22 20:39   ` asmadeus
2025-06-22 21:20     ` Christian Schoenebeck
2025-06-22 21:37       ` asmadeus

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=659844BA-48EF-47E1-8D66-D4CA98359BBF@kernel.org \
    --to=kees@kernel.org \
    --cc=asmadeus@codewreck.org \
    --cc=danisjiang@gmail.com \
    --cc=devnull+asmadeus.codewreck.org@kernel.org \
    --cc=ericvh@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux_oss@crudebyte.com \
    --cc=lucho@ionkov.net \
    --cc=m.grzeschik@pengutronix.de \
    --cc=security@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=v9fs@lists.linux.dev \
    /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

all inboxes | Powered by JetHome®