From: Kyungwook Boo <bookyungwook@gmail.com>
To: Sudarsana Kalluru <skalluru@marvell.com>,
Manish Chopra <manishc@marvell.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: MMIO region out-of-bounds access in bnx2x_init_shmem()
Date: Mon, 3 Mar 2025 19:41:14 +0900 [thread overview]
Message-ID: <987ba865-3517-4e2e-8e32-6e46482d019a@gmail.com> (raw)
Hello,
It seems there's an issue in bnx2x_init_shmem() that allows an MMIO access
address offset to be set directly from the device without either range check or
filtering, potentially leading to an out-of-bounds MMIO region access.
In bnx2x_init_shmem(), bp->common.shmem_base is assigned from an MMIO read:
bp->common.shmem_base = REG_RD(bp, MISC_REG_SHARED_MEM_ADDR);
This shmem_base value is then used to calculate an address for another MMIO
read:
if (bp->common.shmem_base) {
val = SHMEM_RD(bp, validity_map[BP_PORT(bp)]); // Out-of-bounds access here
/*
in bnx2x.h,
#define SHMEM_ADDR(bp, field) (bp->common.shmem_base + \
offsetof(struct shmem_region, field))
#define SHMEM_RD(bp, field) REG_RD(bp, SHMEM_ADDR(bp, field))
*/
If shmem_base was set with an unexpected large value, causing an MMIO region
out-of-bounds read access.
Futhermore, I think similar issue could occur also at shmem2_base case:
// in bnx2x_get_common_hwinfo()
bp->common.shmem2_base = REG_RD(bp, (BP_PATH(bp) ?
MISC_REG_GENERIC_CR_1 :
MISC_REG_GENERIC_CR_0));
...
if (SHMEM2_RD(bp, size) >
(u32)offsetof(struct shmem2_region, lfa_host_addr[BP_PORT(bp)]))
It seems that a range check patch is needed for shmem_base and shmem2_base, but
I am not entirely sure what the correct range should be.
Could you check this?
Best regards,
Kyungwook Boo
reply other threads:[~2025-03-03 10:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=987ba865-3517-4e2e-8e32-6e46482d019a@gmail.com \
--to=bookyungwook@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=manishc@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=skalluru@marvell.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 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.