sfc: Don't invoke xdp_do_flush() from netpoll.
Subsystems (4)
PATCH 1/1 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.
--- drivers/net/ethernet/sfc/efx_channels.c | 3 ++- drivers/net/ethernet/sfc/siena/efx_channels.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/sfc/efx_channels.c +2 -1
@@ -1260,7 +1260,8 @@ static int efx_poll(struct napi_struct *napi, int budget) spent =efx_process_channel (channel, budget); -xdp_do_flush (); +if (budget) +xdp_do_flush ();if (spent < budget) { if (efx_channel_has_rx_queue(channel) &&
drivers/net/ethernet/sfc/siena/efx_channels.c +2 -1
@@ -1285,7 +1285,8 @@ static int efx_poll(struct napi_struct *napi, int budget) spent =efx_process_channel (channel, budget); -xdp_do_flush (); +if (budget) +xdp_do_flush ();if (spent < budget) { if (efx_channel_has_rx_queue(channel) &&
Signature · 1 line
2.45.2
Quoted 9 lines · Sebastian Andrzej Siewior
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 becausebpf_net_contextwas never assigned.
Quoted 6 lines
Invoke
xdp_do_flush()only if budget is not zero.Fixes 401cb7dae8130 ("net: Reference bpf_redirect_info via task_struct on PREEMPT_RT.")Reported-by Yury Vostrikov <[email protected]>Signed-off-by Sebastian Andrzej Siewior <[email protected]>
Jakub Kicinski
maintainerQuoted 1 line · On Wed, 2 Oct 2024 14:58:37 +0200 Sebastian Andrzej Siewior wrote:
Fixes 401cb7dae8130 ("net: Reference bpf_redirect_info via task_struct on PREEMPT_RT.")
FTR I think this could have imploded even before, just a lot lower probability.
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Wed, 2 Oct 2024 14:58:37 +0200 you wrote:
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 becausebpf_net_contextwas never assigned.[...]
Here is the summary with links:
- [net] sfc: Don't invoke xdp_do_flush() from netpoll.
https://git.kernel.org/netdev/net/c/55e802468e1d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html