From: sashiko-bot@kernel.org
To: wei.fang@oss.nxp.com
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH net-next 09/15] net: enetc: add MAC address filtering support for VFs of ENETC v4
Date: Sat, 06 Jun 2026 07:24:40 +0000 [thread overview]
Message-ID: <20260606072441.4BB8D1F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260605065550.3038579-10-wei.fang@oss.nxp.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] A Time-Of-Check to Time-Of-Use (TOCTOU) race condition in `enetc_msg_handle_rxmsg` allows a malicious VF to trigger a heap out-of-bounds read in `enetc_msg_set_vf_mac_hash_filter` by changing the message length between allocation and use.
--
commit 46d6bb311e4a8bcc15dcd4d622db8e4c46a5ec75
Author: Wei Fang <wei.fang@nxp.com>
net: enetc: add MAC address filtering support for VFs of ENETC v4
Adds VSI-to-PSI mailbox message support to allow VFs to request MAC filter
configuration from the PF on ENETC v4. Introduces two new command IDs to
program the MAC hash filter table and configure promiscuous mode.
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc_msg.c b/drivers/net/ethernet/freescale/enetc/enetc_msg.c
> index 49c1ca14735c9..7dcb1dcdec84d 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc_msg.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc_msg.c
[ ... ]
> @@ -101,6 +101,115 @@ static u16 enetc_msg_set_vf_primary_mac_addr(struct enetc_pf *pf, int vf_id,
[ ... ]
> +static u16 enetc_msg_set_vf_mac_hash_filter(struct enetc_pf *pf, int vf_id,
> + void *vf_msg)
> +{
[ ... ]
> + } else if (type == ENETC_MAC_FILTER_TYPE_ALL) {
> + if (!msg->hdr.len) {
> + pf_msg = FIELD_PREP(ENETC_PF_MSG_CLASS_ID,
> + ENETC_MSG_CLASS_ID_INVALID_MSG_LEN);
> + goto vf_state_unlock;
> + }
> +
> + pf->ops->set_si_mac_hash_filter(hw, si_id, UC, hash_tbl);
> + hash_tbl = (u64)msg->hash_tbl[3] << 32 | msg->hash_tbl[2];
[Severity: High]
Can a malicious VF trigger a heap out-of-bounds read here?
Looking at enetc_msg_handle_rxmsg(), which handles the message allocation, it
reads msg_hdr->len from DMA memory to calculate the size:
u32 msg_size = ENETC_MSG_SIZE(msg_hdr->len);
...
msg = kzalloc_objs(*msg, msg_size);
...
memcpy(msg, msg_swbd->vaddr, msg_size);
If the VF modifies the length in DMA memory to a non-zero value between the
msg_size calculation and the memcpy, the copied msg->hdr.len will differ from
the size actually allocated.
If the buffer was allocated as 32 bytes (because the initial length was 0),
this check for !msg->hdr.len will pass, and the subsequent read of
msg->hash_tbl[3] (at offset 32) will read out of bounds.
If this object is placed at the end of a slab page next to an unmapped page,
could this cause a panic, leading to a guest-to-host denial of service?
Additionally, would the leaked kernel heap data be programmed into the MAC hash
filter, potentially creating an information leak?
> + pf->ops->set_si_mac_hash_filter(hw, si_id, MC, hash_tbl);
> + }
> +
> +vf_state_unlock:
> + mutex_unlock(&vf_state->lock);
> +
> + return pf_msg;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260605065550.3038579-1-wei.fang@oss.nxp.com?part=9
next prev parent reply other threads:[~2026-06-06 7:24 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 6:55 [PATCH net-next 00/15] net: enetc: SR-IOV improvements and ENETC v4 VF support wei.fang
2026-06-05 6:55 ` [PATCH net-next 01/15] net: enetc: add trusted " wei.fang
2026-06-06 7:24 ` sashiko-bot
2026-06-06 13:37 ` Wei Fang (OSS)
2026-06-05 6:55 ` [PATCH net-next 02/15] net: enetc: move msg_task and msg_int_name to struct enetc_si wei.fang
2026-06-05 6:55 ` [PATCH net-next 03/15] net: enetc: add link status message support to PF driver wei.fang
2026-06-06 7:24 ` sashiko-bot
2026-06-06 14:05 ` Wei Fang (OSS)
2026-06-05 6:55 ` [PATCH net-next 04/15] net: enetc: add link speed " wei.fang
2026-06-06 7:24 ` sashiko-bot
2026-06-05 6:55 ` [PATCH net-next 05/15] net: enetc: use enetc_set_si_hw_addr() to set VF MAC address wei.fang
2026-06-05 6:55 ` [PATCH net-next 06/15] net: enetc: relocate enetc_pf_set_vf_mac() for common PF support wei.fang
2026-06-05 6:55 ` [PATCH net-next 07/15] net: enetc: add .ndo_set_vf_mac() to the enetc v4 driver wei.fang
2026-06-05 6:55 ` [PATCH net-next 08/15] net: enetc: move mac_filter from struct enetc_pf to struct enetc_si wei.fang
2026-06-06 7:24 ` sashiko-bot
2026-06-07 2:52 ` Wei Fang (OSS)
2026-06-05 6:55 ` [PATCH net-next 09/15] net: enetc: add MAC address filtering support for VFs of ENETC v4 wei.fang
2026-06-06 7:24 ` sashiko-bot [this message]
2026-06-05 6:55 ` [PATCH net-next 10/15] net: enetc: simplify and rename PSIIER enable/disable helpers wei.fang
2026-06-05 6:55 ` [PATCH net-next 11/15] net: enetc: restore VF MAC promiscuous mode after FLR for ENETC v4 wei.fang
2026-06-06 7:24 ` sashiko-bot
2026-06-05 6:55 ` [PATCH net-next 12/15] net: enetc: add VF support for i.MX94 and i.MX95 wei.fang
2026-06-06 7:24 ` sashiko-bot
2026-06-07 3:53 ` Wei Fang (OSS)
2026-06-05 6:55 ` [PATCH net-next 13/15] net: enetc: implement ndo_set_rx_mode_async for ENETC v4 VF wei.fang
2026-06-06 7:24 ` sashiko-bot
2026-06-07 4:01 ` Wei Fang (OSS)
2026-06-05 6:55 ` [PATCH net-next 14/15] net: enetc: add PSI-to-VSI link status notification support for VF wei.fang
2026-06-06 7:24 ` sashiko-bot
2026-06-05 6:55 ` [PATCH net-next 15/15] net: enetc: add ndo_get_vf_config() support wei.fang
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=20260606072441.4BB8D1F00898@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=imx@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wei.fang@oss.nxp.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.