Skip to content

Commit 55e8024

Browse files
Sebastian Andrzej Siewiorkuba-moo
authored andcommitted
sfc: Don't invoke xdp_do_flush() from netpoll.
Yury reported a crash in the sfc driver originated from netpoll_send_udp(). The netconsole sends a message and then netpoll invokes the driver's NAPI function with a budget of zero. It is dedicated to allow driver to free TX resources, that it may have used while sending the packet. In the netpoll case the driver invokes xdp_do_flush() unconditionally, leading to crash because bpf_net_context was never assigned. Invoke xdp_do_flush() only if budget is not zero. Fixes: 401cb7d ("net: Reference bpf_redirect_info via task_struct on PREEMPT_RT.") Reported-by: Yury Vostrikov <[email protected]> Closes: https://lore.kernel.org/[email protected] Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Reviewed-by: Edward Cree <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent a842e44 commit 55e8024

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

drivers/net/ethernet/sfc/efx_channels.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,8 @@ static int efx_poll(struct napi_struct *napi, int budget)
12601260

12611261
spent = efx_process_channel(channel, budget);
12621262

1263-
xdp_do_flush();
1263+
if (budget)
1264+
xdp_do_flush();
12641265

12651266
if (spent < budget) {
12661267
if (efx_channel_has_rx_queue(channel) &&

drivers/net/ethernet/sfc/siena/efx_channels.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,8 @@ static int efx_poll(struct napi_struct *napi, int budget)
12851285

12861286
spent = efx_process_channel(channel, budget);
12871287

1288-
xdp_do_flush();
1288+
if (budget)
1289+
xdp_do_flush();
12891290

12901291
if (spent < budget) {
12911292
if (efx_channel_has_rx_queue(channel) &&

0 commit comments

Comments
 (0)