* [PATCH net] sfc: Don't invoke xdp_do_flush() from netpoll.
@ 2024-10-02 12:58 Sebastian Andrzej Siewior
2024-10-02 13:36 ` Edward Cree
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-10-02 12:58 UTC (permalink / raw)
To: netdev, linux-net-drivers, bpf
Cc: David S. Miller, Toke Høiland-Jørgensen,
Alexei Starovoitov, Daniel Borkmann, Edward Cree, Eric Dumazet,
Jakub Kicinski, Jesper Dangaard Brouer, John Fastabend,
Martin Habets, Paolo Abeni, Thomas Gleixner, Yury Vostrikov
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: 401cb7dae8130 ("net: Reference bpf_redirect_info via task_struct on PREEMPT_RT.")
Reported-by: Yury Vostrikov <mon@unformed.ru>
Closes: https://lore.kernel.org/5627f6d1-5491-4462-9d75-bc0612c26a22@app.fastmail.com
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
drivers/net/ethernet/sfc/efx_channels.c | 3 ++-
drivers/net/ethernet/sfc/siena/efx_channels.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/sfc/efx_channels.c b/drivers/net/ethernet/sfc/efx_channels.c
index c9e17a8208a90..f1723a6fb082b 100644
--- a/drivers/net/ethernet/sfc/efx_channels.c
+++ b/drivers/net/ethernet/sfc/efx_channels.c
@@ -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) &&
diff --git a/drivers/net/ethernet/sfc/siena/efx_channels.c b/drivers/net/ethernet/sfc/siena/efx_channels.c
index a7346e965bfe7..d120b3c83ac07 100644
--- a/drivers/net/ethernet/sfc/siena/efx_channels.c
+++ b/drivers/net/ethernet/sfc/siena/efx_channels.c
@@ -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) &&
--
2.45.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] sfc: Don't invoke xdp_do_flush() from netpoll.
2024-10-02 12:58 [PATCH net] sfc: Don't invoke xdp_do_flush() from netpoll Sebastian Andrzej Siewior
@ 2024-10-02 13:36 ` Edward Cree
2024-10-03 22:44 ` Jakub Kicinski
2024-10-03 22:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Edward Cree @ 2024-10-02 13:36 UTC (permalink / raw)
To: Sebastian Andrzej Siewior, netdev, linux-net-drivers, bpf
Cc: David S. Miller, Toke Høiland-Jørgensen,
Alexei Starovoitov, Daniel Borkmann, Eric Dumazet, Jakub Kicinski,
Jesper Dangaard Brouer, John Fastabend, Martin Habets,
Paolo Abeni, Thomas Gleixner, Yury Vostrikov
On 02/10/2024 13:58, Sebastian Andrzej Siewior 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 because bpf_net_context was never assigned.
>
> 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 <mon@unformed.ru>
> Closes: https://lore.kernel.org/5627f6d1-5491-4462-9d75-bc0612c26a22@app.fastmail.com
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: Edward Cree <ecree.xilinx@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] sfc: Don't invoke xdp_do_flush() from netpoll.
2024-10-02 12:58 [PATCH net] sfc: Don't invoke xdp_do_flush() from netpoll Sebastian Andrzej Siewior
2024-10-02 13:36 ` Edward Cree
@ 2024-10-03 22:44 ` Jakub Kicinski
2024-10-03 22:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2024-10-03 22:44 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: netdev, linux-net-drivers, bpf, David S. Miller,
Toke Høiland-Jørgensen, Alexei Starovoitov,
Daniel Borkmann, Edward Cree, Eric Dumazet,
Jesper Dangaard Brouer, John Fastabend, Martin Habets,
Paolo Abeni, Thomas Gleixner, Yury Vostrikov
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] sfc: Don't invoke xdp_do_flush() from netpoll.
2024-10-02 12:58 [PATCH net] sfc: Don't invoke xdp_do_flush() from netpoll Sebastian Andrzej Siewior
2024-10-02 13:36 ` Edward Cree
2024-10-03 22:44 ` Jakub Kicinski
@ 2024-10-03 22:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-10-03 22:50 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: netdev, linux-net-drivers, bpf, davem, toke, ast, daniel,
ecree.xilinx, edumazet, kuba, hawk, john.fastabend,
habetsm.xilinx, pabeni, tglx, mon
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
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 because bpf_net_context was 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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-03 22:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-02 12:58 [PATCH net] sfc: Don't invoke xdp_do_flush() from netpoll Sebastian Andrzej Siewior
2024-10-02 13:36 ` Edward Cree
2024-10-03 22:44 ` Jakub Kicinski
2024-10-03 22:50 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).