Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ethernet: rocker: fix sleep in atomic context bug in neigh_timer_handler

The function neigh_timer_handler() is a timer handler that runs in an
atomic context. When used by rocker, neigh_timer_handler() calls
"kzalloc(.., GFP_KERNEL)" that may sleep. As a result, the sleep in
atomic context bug will happen. One of the processes is shown below:

ofdpa_fib4_add()
...
neigh_add_timer()

(wait a timer)

neigh_timer_handler()
neigh_release()
neigh_destroy()
rocker_port_neigh_destroy()
rocker_world_port_neigh_destroy()
ofdpa_port_neigh_destroy()
ofdpa_port_ipv4_neigh()
kzalloc(sizeof(.., GFP_KERNEL) //may sleep

This patch changes the gfp_t parameter of kzalloc() from GFP_KERNEL to
GFP_ATOMIC in order to mitigate the bug.

Fixes: 00fc0c51e35b ("rocker: Change world_ops API and implementation to be switchdev independant")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Duoming Zhou and committed by
David S. Miller
c0955bf9 13a9d08c

+1 -1
+1 -1
drivers/net/ethernet/rocker/rocker_ofdpa.c
··· 1273 1273 bool removing; 1274 1274 int err = 0; 1275 1275 1276 - entry = kzalloc(sizeof(*entry), GFP_KERNEL); 1276 + entry = kzalloc(sizeof(*entry), GFP_ATOMIC); 1277 1277 if (!entry) 1278 1278 return -ENOMEM; 1279 1279