Skip to content

Commit cedc1bf

Browse files
LorenzoBianconikuba-moo
authored andcommitted
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e6e3eb5 commit cedc1bf

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

drivers/net/ethernet/airoha/airoha_eth.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2962,6 +2962,8 @@ static int airoha_register_gdm_devices(struct airoha_eth *eth)
29622962
return err;
29632963
}
29642964

2965+
set_bit(DEV_STATE_REGISTERED, &eth->state);
2966+
29652967
return 0;
29662968
}
29672969

drivers/net/ethernet/airoha/airoha_eth.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ enum {
8888

8989
enum {
9090
DEV_STATE_INITIALIZED,
91+
DEV_STATE_REGISTERED,
9192
};
9293

9394
enum {

drivers/net/ethernet/airoha/airoha_ppe.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,13 @@ int airoha_ppe_setup_tc_block_cb(struct airoha_ppe_dev *dev, void *type_data)
13681368
struct airoha_eth *eth = ppe->eth;
13691369
int err = 0;
13701370

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+
13711378
mutex_lock(&flow_offload_mutex);
13721379

13731380
if (!eth->npu)

0 commit comments

Comments
 (0)