mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-28 13:34:38 +08:00
75aab4e10a
The page recycle code, incorrectly, relied on that a page fragment
could not be freed inside xdp_do_redirect(). This assumption leads to
that page fragments that are used by the stack/XDP redirect can be
reused and overwritten.
To avoid this, store the page count prior invoking xdp_do_redirect().
Longer explanation:
Intel NICs have a recycle mechanism. The main idea is that a page is
split into two parts. One part is owned by the driver, one part might
be owned by someone else, such as the stack.
t0: Page is allocated, and put on the Rx ring
+---------------
used by NIC ->| upper buffer
(rx_buffer) +---------------
| lower buffer
+---------------
page count == USHRT_MAX
rx_buffer->pagecnt_bias == USHRT_MAX
t1: Buffer is received, and passed to the stack (e.g.)
+---------------
| upper buff (skb)
+---------------
used by NIC ->| lower buffer
(rx_buffer) +---------------
page count == USHRT_MAX
rx_buffer->pagecnt_bias == USHRT_MAX - 1
t2: Buffer is received, and redirected
+---------------
| upper buff (skb)
+---------------
used by NIC ->| lower buffer
(rx_buffer) +---------------
Now, prior calling xdp_do_redirect():
page count == USHRT_MAX
rx_buffer->pagecnt_bias == USHRT_MAX - 2
This means that buffer *cannot* be flipped/reused, because the skb is
still using it.
The problem arises when xdp_do_redirect() actually frees the
segment. Then we get:
page count == USHRT_MAX - 1
rx_buffer->pagecnt_bias == USHRT_MAX - 2
From a recycle perspective, the buffer can be flipped and reused,
which means that the skb data area is passed to the Rx HW ring!
To work around this, the page count is stored prior calling
xdp_do_redirect().
Note that this is not optimal, since the NIC could actually reuse the
"lower buffer" again. However, then we need to track whether
XDP_REDIRECT consumed the buffer or not.
Fixes:
|
||
---|---|---|
.. | ||
i40e_adminq_cmd.h | ||
i40e_adminq.c | ||
i40e_adminq.h | ||
i40e_alloc.h | ||
i40e_client.c | ||
i40e_common.c | ||
i40e_dcb_nl.c | ||
i40e_dcb.c | ||
i40e_dcb.h | ||
i40e_ddp.c | ||
i40e_debugfs.c | ||
i40e_devids.h | ||
i40e_diag.c | ||
i40e_diag.h | ||
i40e_ethtool.c | ||
i40e_hmc.c | ||
i40e_hmc.h | ||
i40e_lan_hmc.c | ||
i40e_lan_hmc.h | ||
i40e_main.c | ||
i40e_nvm.c | ||
i40e_osdep.h | ||
i40e_prototype.h | ||
i40e_ptp.c | ||
i40e_register.h | ||
i40e_status.h | ||
i40e_trace.h | ||
i40e_txrx_common.h | ||
i40e_txrx.c | ||
i40e_txrx.h | ||
i40e_type.h | ||
i40e_virtchnl_pf.c | ||
i40e_virtchnl_pf.h | ||
i40e_xsk.c | ||
i40e_xsk.h | ||
i40e.h | ||
Makefile |