freebsd-src/sys/dev/netmap
Tom Jones 73fdbfb911 netmap: Address errors on memory free in netmap_generic
netmap_generic keeps a pool of mbufs for handling transfers, these mbufs
have an external buffer attached to them.

If some cases other parts of the network stack can chain these mbufs,
when this happens the normal pool destructor function can end up
free'ing the pool mbufs twice:

- A first time if a pool mbuf has been chained with another mbuf when
  its chain is freed
- A second time when its entry in the pool is freed

Additionally, if other parts of the stack demote a pool mbuf its
interface reference will be cleared. In this case we deference a NULL
pointer when trying to free the mbuf through the destructor. Store a
reference to the adapter in ext_arg1 with the destructor callback so we
can find the correct adapter when free'ing a pool mbuf.

This change enables using netmap with epair interfaces.

Reviewed By:	vmaffione
MFC after:	1 week
Relnotes:	yes
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D44371
2024-03-26 09:55:55 +00:00
..
if_ptnet.c sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
if_re_netmap.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
if_vtnet_netmap.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
netmap.c sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
netmap_bdg.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
netmap_bdg.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
netmap_freebsd.c sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
netmap_generic.c netmap: Address errors on memory free in netmap_generic 2024-03-26 09:55:55 +00:00
netmap_kern.h netmap: Address errors on memory free in netmap_generic 2024-03-26 09:55:55 +00:00
netmap_kloop.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
netmap_legacy.c sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
netmap_mbq.c sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
netmap_mbq.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
netmap_mem2.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
netmap_mem2.h sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
netmap_monitor.c sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
netmap_null.c sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
netmap_offloadings.c sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
netmap_pipe.c sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
netmap_vale.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00