Skip to content

iflib: Fix panic when netmap VALE drops packets to iflib driver#2264

Open
TeddyEngel wants to merge 1 commit into
freebsd:mainfrom
TeddyEngel:fix/294726-netmap-vale-iflib-crash
Open

iflib: Fix panic when netmap VALE drops packets to iflib driver#2264
TeddyEngel wants to merge 1 commit into
freebsd:mainfrom
TeddyEngel:fix/294726-netmap-vale-iflib-crash

Conversation

@TeddyEngel

Copy link
Copy Markdown
Contributor

When a netmap VALE switch drops packets destined for an iflib-based network driver (e.g., vmxnet3, igb, em), the kernel panics with a page fault in the driver's isc_txd_encap() function.

The crash occurs because:

  1. nm_vale_flush() drops oversized packets by setting slot->len = 0
  2. iflib_netmap_txsync() processes the zero-length slot but seg_idx stays 0 since len == 0
  3. isc_txd_encap() is called with pi->ipi_nsegs = 0
  4. The driver loops zero times but unconditionally sets the EOP flag on an uninitialized descriptor pointer

To fix, we skip zero-length packets (seg_idx == 0) at end-of-packet. Advance nm_i to consume the netmap slot but not nic_i, avoiding gaps in the NIC descriptor ring.

The fix is in iflib rather than individual drivers because all iflib drivers assume nsegs > 0, and we want to protect all drivers with a single fix.

Tested on FreeBSD 16.0-CURRENT using the reproducer script from the bug report.

PR: 294726

@TeddyEngel

Copy link
Copy Markdown
Contributor Author

CI failures seem unrelated to this PR - they're in lib/libc/gen/getcap.c (conflicting types for cgetent/cgetfirst/cgetnext). Same failures also appeared on PR #2263. Style Checker and commit checks pass.

PR: 294726
Signed-off-by: Teddy Engel <engel.teddy@gmail.com>
@TeddyEngel TeddyEngel force-pushed the fix/294726-netmap-vale-iflib-crash branch from 516c025 to e1aabd5 Compare June 6, 2026 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant