Commit 55e80246 authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Jakub Kicinski

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: 401cb7da ("net: Reference bpf_redirect_info via task_struct on PREEMPT_RT.")
Reported-by: default avatarYury Vostrikov <mon@unformed.ru>
Closes: https://lore.kernel.org/5627f6d1-5491-4462-9d75-bc0612c26a22@app.fastmail.comSigned-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: default avatarEdward Cree <ecree.xilinx@gmail.com>
Link: https://patch.msgid.link/20241002125837.utOcRo6Y@linutronix.deSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent a842e443
...@@ -1260,6 +1260,7 @@ static int efx_poll(struct napi_struct *napi, int budget) ...@@ -1260,6 +1260,7 @@ static int efx_poll(struct napi_struct *napi, int budget)
spent = efx_process_channel(channel, budget); spent = efx_process_channel(channel, budget);
if (budget)
xdp_do_flush(); xdp_do_flush();
if (spent < budget) { if (spent < budget) {
......
...@@ -1285,6 +1285,7 @@ static int efx_poll(struct napi_struct *napi, int budget) ...@@ -1285,6 +1285,7 @@ static int efx_poll(struct napi_struct *napi, int budget)
spent = efx_process_channel(channel, budget); spent = efx_process_channel(channel, budget);
if (budget)
xdp_do_flush(); xdp_do_flush();
if (spent < budget) { if (spent < budget) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment