Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: wei.fang@oss.nxp.com
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH v4 net-next 08/15] net: enetc: move mac_filter from struct enetc_pf to struct enetc_si
Date: Thu, 10 Sep 2026 10:37:27 +0000	[thread overview]
Message-ID: <20260910103727.9E5931F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260909100733.1139689-9-wei.fang@oss.nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Fallback path in enetc_sync_mac_filters() reads corrupted hash bitmap due to union overlap.
--

commit 5d26a4aca1dc2966f5003f268c0a69349efe5210
Author: Wei Fang <wei.fang@nxp.com>

net: enetc: move mac_filter from struct enetc_pf to struct enetc_si

The mac_filter array currently resides in struct enetc_pf and is used to
track unicast and multicast MAC address filters for the PF. Since struct
enetc_si is the common structure shared between the PF and VF drivers,
move mac_filter into struct enetc_si to prepare for MAC filter support
in the VF driver.

> diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
> index c467dc05510ef..523c713247805 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
[ ... ]
> @@ -60,10 +60,9 @@ static void enetc_add_mac_addr_em_filter(struct enetc_mac_filter *filter,
>  	filter->mac_addr_cnt++;
>  }
>  
> -static void enetc_sync_mac_filters(struct enetc_pf *pf)
> +static void enetc_sync_mac_filters(struct enetc_si *si)
>  {

[Severity: High]
This is a pre-existing issue, but since this patch refactors the mac_filter
storage, does the fallback path in enetc_sync_mac_filters() incorrectly read
corrupted hash data due to a union overlap?

Because mac_addr and mac_hash_table share a union in struct enetc_mac_filter:

struct enetc_mac_filter {
    union {
        char mac_addr[ETH_ALEN];
        DECLARE_BITMAP(mac_hash_table, ENETC_MADDR_HASH_TBL_SZ);
    };
    int mac_addr_cnt;
};

When there is exactly one unicast MAC address and the exact-match insertion
fails (e.g., due to a hardware timeout), the driver falls back to hash table
filtering. Because of the union overlap, it appears the fallback path will
read the raw MAC address bytes as a 64-bit hash table mask:

    /* exact match filter */
    if (em) {
        ...
        err = enetc_set_mac_flt_entry(si, pos, f->mac_addr, BIT(0));
        if (!err)
            continue;

        /* fallback to HT filtering */
        dev_warn(&si->pdev->dev, "fallback to HT filt (%d)\n", err);
    }

    bitmap_to_arr64(&hash, f->mac_hash_table, ENETC_MADDR_HASH_TBL_SZ);
    /* hash table filter, clear EM filter for UC entries */

Could this cause the device to drop valid packets or receive invalid ones by
programming the MAC address bytes as the hash bitmap?

> -	struct enetc_mac_filter *f = pf->mac_filter;
> -	struct enetc_si *si = pf->si;
> +	struct enetc_mac_filter *f = si->mac_filter;
>  	int i, pos;
>  
>  	pos = EMETC_MAC_ADDR_FILT_RES;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260909100733.1139689-1-wei.fang@oss.nxp.com?part=8

  reply	other threads:[~2026-09-10 10:37 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09 10:07 [PATCH v4 net-next 00/15] net: enetc: SR-IOV improvements and ENETC v4 VF support wei.fang
2026-09-09 10:07 ` [PATCH v4 net-next 01/15] net: enetc: add trusted " wei.fang
2026-09-10 11:20   ` netdev-bot+sashiko
2026-09-11  2:29     ` Wei Fang
2026-09-09 10:07 ` [PATCH v4 net-next 02/15] net: enetc: move msg_task and msg_int_name to struct enetc_si wei.fang
2026-09-11 20:14   ` Claudiu Manoil
2026-09-09 10:07 ` [PATCH v4 net-next 03/15] net: enetc: add link status message support to PF driver wei.fang
2026-09-10 11:20   ` netdev-bot+sashiko
2026-09-11  5:55     ` Wei Fang
2026-09-11 20:15   ` Claudiu Manoil
2026-09-09 10:07 ` [PATCH v4 net-next 04/15] net: enetc: add link speed " wei.fang
2026-09-10 11:20   ` netdev-bot+sashiko
2026-09-11  2:56     ` Wei Fang
2026-09-11 20:16   ` Claudiu Manoil
2026-09-09 10:07 ` [PATCH v4 net-next 05/15] net: enetc: use enetc_set_si_hw_addr() to set VF MAC address wei.fang
2026-09-09 10:07 ` [PATCH v4 net-next 06/15] net: enetc: relocate enetc_pf_set_vf_mac() for common PF support wei.fang
2026-09-09 10:07 ` [PATCH v4 net-next 07/15] net: enetc: add .ndo_set_vf_mac() to the enetc v4 driver wei.fang
2026-09-10 10:37   ` sashiko-bot
2026-09-09 10:07 ` [PATCH v4 net-next 08/15] net: enetc: move mac_filter from struct enetc_pf to struct enetc_si wei.fang
2026-09-10 10:37   ` sashiko-bot [this message]
2026-09-09 10:07 ` [PATCH v4 net-next 09/15] net: enetc: add MAC address filtering support for VFs of ENETC v4 wei.fang
2026-09-10 11:21   ` netdev-bot+sashiko
2026-09-11  6:13     ` Wei Fang
2026-09-09 10:07 ` [PATCH v4 net-next 10/15] net: enetc: simplify and rename PSIIER enable/disable helpers wei.fang
2026-09-09 10:07 ` [PATCH v4 net-next 11/15] net: enetc: restore VF MAC promiscuous mode after FLR for ENETC v4 wei.fang
2026-09-10 11:21   ` netdev-bot+sashiko
2026-09-11  6:23     ` Wei Fang
2026-09-11 20:17   ` Claudiu Manoil
2026-09-09 10:07 ` [PATCH v4 net-next 12/15] net: enetc: add VF support for i.MX94 and i.MX95 wei.fang
2026-09-10 10:37   ` sashiko-bot
2026-09-11  7:31     ` Wei Fang (OSS)
2026-09-09 10:07 ` [PATCH v4 net-next 13/15] net: enetc: implement ndo_set_rx_mode_async for ENETC v4 VF wei.fang
2026-09-10 10:37   ` sashiko-bot
2026-09-11  8:02     ` Wei Fang (OSS)
2026-09-10 11:21   ` netdev-bot+sashiko
2026-09-11  7:17     ` Wei Fang
2026-09-09 10:07 ` [PATCH v4 net-next 14/15] net: enetc: add PSI-to-VSI link status notification support for VF wei.fang
2026-09-09 10:07 ` [PATCH v4 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=20260910103727.9E5931F00893@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox