]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: bnxt: fix a potential use-after-free in bnxt_init_tc
authorDinghao Liu <dinghao.liu@zju.edu.cn>
Mon, 4 Dec 2023 02:40:04 +0000 (10:40 +0800)
committerJakub Kicinski <kuba@kernel.org>
Wed, 6 Dec 2023 03:43:42 +0000 (19:43 -0800)
When flow_indr_dev_register() fails, bnxt_init_tc will free
bp->tc_info through kfree(). However, the caller function
bnxt_init_one() will ignore this failure and call
bnxt_shutdown_tc() on failure of bnxt_dl_register(), where
a use-after-free happens. Fix this issue by setting
bp->tc_info to NULL after kfree().

Fixes: 627c89d00fb9 ("bnxt_en: flow_offload: offload tunnel decap rules via indirect callbacks")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Link: https://lore.kernel.org/r/20231204024004.8245-1-dinghao.liu@zju.edu.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c

index 38d89d80b4a9c7ed2470b6ce6ddb8a3557e9069e..273c9ba48f09a179ee175fbab10fde84f0738836 100644 (file)
@@ -2075,6 +2075,7 @@ destroy_flow_table:
        rhashtable_destroy(&tc_info->flow_table);
 free_tc_info:
        kfree(tc_info);
+       bp->tc_info = NULL;
        return rc;
 }