]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
net: mana: Fix race on per-CQ variable napi work_done
authorHaiyang Zhang <haiyangz@microsoft.com>
Fri, 2 Dec 2022 19:43:10 +0000 (11:43 -0800)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 6 Dec 2022 10:21:34 +0000 (11:21 +0100)
commit18010ff776fa42340efc428b3ea6d19b3e7c7b21
tree4e6f6c28275e3b71daa8d15ca92bf1d794c79773
parent61d4f140943c47c1386ed89f7260e00418dfad9d
net: mana: Fix race on per-CQ variable napi work_done

After calling napi_complete_done(), the NAPIF_STATE_SCHED bit may be
cleared, and another CPU can start napi thread and access per-CQ variable,
cq->work_done. If the other thread (for example, from busy_poll) sets
it to a value >= budget, this thread will continue to run when it should
stop, and cause memory corruption and panic.

To fix this issue, save the per-CQ work_done variable in a local variable
before napi_complete_done(), so it won't be corrupted by a possible
concurrent thread after napi_complete_done().

Also, add a flag bit to advertise to the NIC firmware: the NAPI work_done
variable race is fixed, so the driver is able to reliably support features
like busy_poll.

Cc: stable@vger.kernel.org
Fixes: e1b5683ff62e ("net: mana: Move NAPI from EQ to CQ")
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Link: https://lore.kernel.org/r/1670010190-28595-1-git-send-email-haiyangz@microsoft.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/microsoft/mana/gdma.h
drivers/net/ethernet/microsoft/mana/mana_en.c