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

Configure Feed

Select the types of activity you want to include in your feed.

net: airoha: Delay offloading until all net_devices are fully registered

Netfilter flowtable can theoretically try to offload flower rules as soon
as a net_device is registered while all the other ones are not
registered or initialized, triggering a possible NULL pointer dereferencing
of qdma pointer in airoha_ppe_set_cpu_port routine. Moreover, if
register_netdev() fails for a particular net_device, there is a small
race if Netfilter tries to offload flowtable rules before all the
net_devices are properly unregistered in airoha_probe() error patch,
triggering a NULL pointer dereferencing in airoha_ppe_set_cpu_port
routine. In order to avoid any possible race, delay offloading until
all net_devices are registered in the networking subsystem.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://patch.msgid.link/20260329-airoha-regiser-race-fix-v2-1-f4ebb139277b@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Lorenzo Bianconi and committed by
Jakub Kicinski
cedc1bf3 e6e3eb5e

+10
+2
drivers/net/ethernet/airoha/airoha_eth.c
··· 2962 2962 return err; 2963 2963 } 2964 2964 2965 + set_bit(DEV_STATE_REGISTERED, &eth->state); 2966 + 2965 2967 return 0; 2966 2968 } 2967 2969
+1
drivers/net/ethernet/airoha/airoha_eth.h
··· 88 88 89 89 enum { 90 90 DEV_STATE_INITIALIZED, 91 + DEV_STATE_REGISTERED, 91 92 }; 92 93 93 94 enum {
+7
drivers/net/ethernet/airoha/airoha_ppe.c
··· 1368 1368 struct airoha_eth *eth = ppe->eth; 1369 1369 int err = 0; 1370 1370 1371 + /* Netfilter flowtable can try to offload flower rules while not all 1372 + * the net_devices are registered or initialized. Delay offloading 1373 + * until all net_devices are registered in the system. 1374 + */ 1375 + if (!test_bit(DEV_STATE_REGISTERED, &eth->state)) 1376 + return -EBUSY; 1377 + 1371 1378 mutex_lock(&flow_offload_mutex); 1372 1379 1373 1380 if (!eth->npu)