From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Guangshuo Li <lgs201920130244@gmail.com>
Cc: Scott Branden <scott.branden@broadcom.com>,
Arnd Bergmann <arnd@arndb.de>, Olof Johansson <olof@lixom.net>,
Desmond Yan <desmond.yan@broadcom.com>,
bcm-kernel-feedback-list@broadcom.com,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] misc: bcm-vk: validate entry_size before memcpy_fromio()
Date: Mon, 29 Dec 2025 11:34:05 +0100 [thread overview]
Message-ID: <2025122907-tamale-coveting-a44b@gregkh> (raw)
In-Reply-To: <20251219141157.59826-1-lgs201920130244@gmail.com>
On Fri, Dec 19, 2025 at 10:11:57PM +0800, Guangshuo Li wrote:
> The driver trusts the 'num' and 'entry_size' fields read from BAR2 and
> uses them directly to compute the length for memcpy_fromio() without
> any bounds checking. If these fields get corrupted or otherwise contain
> invalid values, num * entry_size can exceed the size of
> proc_mon_info.entries and lead to a potential out-of-bounds write.
But we trust the hardware to get this right, is this suddenly a new
threat-model that you need to worry about for this type of device? This
is a PCI device, so it is not normally "dynamic" for most types of
systems.
And is this the _only_ place that we trust the data from the device? If
so, are all other data paths fixed up?
> Add validation for 'entry_size' by ensuring it is non-zero and that
> num * entry_size does not exceed the size of proc_mon_info.entries.
>
> Fixes: ff428d052b3b ("misc: bcm-vk: add get_card_info, peerlog_info, and proc_mon_info")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> ---
> drivers/misc/bcm-vk/bcm_vk_dev.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/misc/bcm-vk/bcm_vk_dev.c b/drivers/misc/bcm-vk/bcm_vk_dev.c
> index a16b99bdaa13..a4a74c10f02b 100644
> --- a/drivers/misc/bcm-vk/bcm_vk_dev.c
> +++ b/drivers/misc/bcm-vk/bcm_vk_dev.c
> @@ -439,6 +439,7 @@ static void bcm_vk_get_proc_mon_info(struct bcm_vk *vk)
> struct device *dev = &vk->pdev->dev;
> struct bcm_vk_proc_mon_info *mon = &vk->proc_mon_info;
> u32 num, entry_size, offset, buf_size;
> + size_t max_bytes;
> u8 *dst;
>
> /* calculate offset which is based on peerlog offset */
> @@ -458,6 +459,9 @@ static void bcm_vk_get_proc_mon_info(struct bcm_vk *vk)
> num, BCM_VK_PROC_MON_MAX);
> return;
> }
> + if (!entry_size || (size_t)num > max_bytes / entry_size) {
> + return;
> + }
Any reason you didn't use checkpatch.pl on your submission? Please
always do so.
And what tool found this issue? That always must be documented. And
how was this tested?
thanks,
greg k-h
prev parent reply other threads:[~2025-12-29 10:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-19 14:11 Guangshuo Li
2025-12-22 16:41 ` Scott Branden
2025-12-29 10:34 ` Greg Kroah-Hartman [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=2025122907-tamale-coveting-a44b@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=arnd@arndb.de \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=desmond.yan@broadcom.com \
--cc=lgs201920130244@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=olof@lixom.net \
--cc=scott.branden@broadcom.com \
--cc=stable@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 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®