linux/drivers/net/ethernet/broadcom/bnxt
Eric Dumazet a51d233ccd bnxt_en: fix DMA mapping length for padded small packets
Stefan Fleischmann reported Intel IOMMU DMA Read faults on BCM57412
NetXtreme-E NICs when transmitting packets on VLAN/macvlan interfaces:

  DMAR: [DMA Read NO_PASID] Request device [18:00.0] fault addr 0xfc499000
        [fault reason 0x06] PTE Read access is not set
  bnxt_en 0000:18:00.0 eno1np0: Abandoning msg {0xb4 0x41a} len: 0 due to firmware status: 0x2000001
  ...
  NETDEV WATCHDOG: eno1np0 (bnxt_en): transmit queue 0 timed out

The fault address (0xfc499000) is on an exact 4KB page boundary,
pointing to a DMA read buffer overrun.

In bnxt_start_xmit(), packets smaller than BNXT_MIN_PKT_SIZE (52 bytes),
such as 42-byte untagged ARP frames, are padded:

    if (length < BNXT_MIN_PKT_SIZE) {
        pad = BNXT_MIN_PKT_SIZE - length;
        if (skb_pad(skb, pad))
            goto tx_kick_pending;
        length = BNXT_MIN_PKT_SIZE;
    }

    mapping = dma_map_single(&pdev->dev, skb->data, len, DMA_TO_DEVICE);
    ...
    dma_unmap_len_set(tx_buf, len, len);

However, 'len' was initialized earlier to skb_headlen(skb) (e.g. 42 bytes)
and is left unadjusted after padding. Consequently, dma_map_single() and
dma_unmap_len_set() map and track only 42 bytes.

Later, the hardware TX buffer descriptor is programmed with the padded length:

    txbd->tx_bd_len_flags_type =
        cpu_to_le32(((len + pad) << TX_BD_LEN_SHIFT) | flags |
                    TX_BD_FLAGS_PACKET_END);

The NIC DMA engine is thus instructed to read 52 bytes from a region where
only 42 bytes were DMA-mapped. If skb->data ends near the boundary of a 4KB
page (within 'pad' bytes of the next page), the hardware DMA read overruns
into the unmapped adjacent page, triggering an IOMMU fault.

This issue was exposed after commit 447cbe95eb ("vlan: fix skb_under_panic
and races when toggling HW VLAN offload") because reserving extra VLAN
headroom rounded LL_RESERVED_SPACE from 48 up to 64 bytes, shifting skb->data
offsets and potentially causing small frames to land right against page
boundaries.

Fix this by using skb_put_padto(skb, BNXT_MIN_PKT_SIZE) in
bnxt_start_xmit(), before skb_shinfo(skb)->nr_frags is sampled,
because padding might linearize the skb.
This ensures skb->len and skb_headlen(skb) reflect the padded size so
that dma_map_single() maps the full buffer and the descriptor length is
consistent. This also removes the temporary 'pad' variable and masking logic.

The padding is done after the SW USO branch, otherwise
bnxt_sw_udp_gso_xmit() would account the padding as UDP payload
and send it in extra segments.

Note that SW USO segments are still not padded: with IPv4, a segment
carrying less than 10 bytes of UDP payload (small gso_size, or a short
last segment) is sent as a frame shorter than BNXT_MIN_PKT_SIZE.
This is a separate issue, left for a followup patch.

Fixes: c0c050c58d ("bnxt_en: New Broadcom ethernet driver.")
Cc: stable@vger.kernel.org
Reported-by: Stefan Fleischmann <sfle@kth.se>
Closes: https://lore.kernel.org/netdev/20261004122616.56714cbd@nargothrond/
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
Link: https://patch.msgid.link/20261007051747.455273-1-edumazet@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-10-07 17:53:31 -07:00
..
bnxt_coredump.c bnxt_en: Always provide max entry and entry size in coredump segments 2025-11-04 17:25:19 -08:00
bnxt_coredump.h bnxt_en: Add err_qpc backing store handling 2025-09-18 13:09:43 +02:00
bnxt_dcb.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
bnxt_dcb.h eth: bnxt: fix warning for define in struct_group 2023-07-28 13:47:34 -07:00
bnxt_debugfs.c bnxt: move bnxt_hsi.h to include/linux/bnxt/hsi.h 2025-07-15 16:03:24 -07:00
bnxt_debugfs.h bnxt: move bnxt_hsi.h to include/linux/bnxt/hsi.h 2025-07-15 16:03:24 -07:00
bnxt_devlink.c devlink: pass param values by pointer 2026-05-25 14:03:06 -07:00
bnxt_devlink.h bnxt_en: Add devlink support for ENABLE_ROCE nvm parameter 2025-03-18 10:25:22 +01:00
bnxt_dim.c bnxt: move bnxt_hsi.h to include/linux/bnxt/hsi.h 2025-07-15 16:03:24 -07:00
bnxt_ethtool.c net: ethtool: keep rtnl_lock for the ioctl self test 2026-09-18 17:19:15 -07:00
bnxt_ethtool.h bnxt_en: ethtool: Support unset l4proto on ip4/ip6 ntuple rules 2024-11-06 17:39:59 -08:00
bnxt_fw_hdr.h
bnxt_gso.c bnxt_en: Prevent queue stop with deferred completions 2026-09-03 17:49:57 -07:00
bnxt_gso.h bnxt_en: Prevent queue stop with deferred completions 2026-09-03 17:49:57 -07:00
bnxt_hwmon.c bnxt_en: Fix call to hardware monitoring event handler 2026-08-22 12:32:59 -07:00
bnxt_hwmon.h bnxt_en: Do not call sleeping hwmon_notify_event() from NAPI 2023-10-22 11:41:45 +01:00
bnxt_hwrm.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
bnxt_hwrm.h bnxt: move bnxt_hsi.h to include/linux/bnxt/hsi.h 2025-07-15 16:03:24 -07:00
bnxt_nvm_defs.h
bnxt_ptp.c bnxt_en: Fix PTP PPS setting bug 2026-08-04 19:54:33 -07:00
bnxt_ptp.h bnxt_en: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set() 2025-09-24 18:13:02 -07:00
bnxt_sriov.c fwctl/bnxt_en: Move common definitions to include/linux/bnxt/ 2026-03-27 09:12:36 -03:00
bnxt_sriov.h bnxt_en: Optimize bnxt_sriov_disable() 2025-09-18 13:09:42 +02:00
bnxt_tc.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
bnxt_tc.h
bnxt_ulp.c bnxt_en: Handle partially initialized auxiliary devices 2026-07-17 12:43:57 +02:00
bnxt_vfr.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
bnxt_vfr.h bnxt_en: Allow to set switchdev mode without existing VFs 2023-04-13 11:04:51 +02:00
bnxt_xdp.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-04-02 11:03:13 -07:00
bnxt_xdp.h bnxt_en: Implement XDP RSS hash metadata extraction 2026-03-29 14:09:07 -07:00
bnxt.c bnxt_en: fix DMA mapping length for padded small packets 2026-10-07 17:53:31 -07:00
bnxt.h bnxt_en: Re-write the BARs following any type of PCIe errors 2026-10-07 17:52:01 -07:00
Makefile net: bnxt: Add boilerplate GSO code 2026-04-12 10:54:32 -07:00