]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ixgbe: fix memory leak and use-after-free in ixgbe_recovery_probe()
authorKohei Enju <enjuk@amazon.com>
Sun, 31 Aug 2025 20:33:11 +0000 (05:33 +0900)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Tue, 28 Oct 2025 19:49:59 +0000 (12:49 -0700)
The error path of ixgbe_recovery_probe() has two memory bugs.

For non-E610 adapters, the function jumps to clean_up_probe without
calling devlink_free(), leaking the devlink instance and its embedded
adapter structure.

For E610 adapters, devlink_free() is called at shutdown_aci, but
clean_up_probe then accesses adapter->state, sometimes triggering
use-after-free because adapter is embedded in devlink. This UAF is
similar to the one recently reported in ixgbe_remove(). (Link)

Fix both issues by moving devlink_free() after adapter->state access,
aligning with the cleanup order in ixgbe_probe().

Link: https://lore.kernel.org/intel-wired-lan/20250828020558.1450422-1-den@valinux.co.jp/
Fixes: 29cb3b8d95c7 ("ixgbe: add E610 implementation of FW recovery mode")
Signed-off-by: Kohei Enju <enjuk@amazon.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Reviewed-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
Tested-by: Rinitha S <sx.rinitha@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

index ca1ccc630001c09b6b82db009b99f481c1b83616..3190ce7e44c742d95af568dae6e1e35267b49794 100644 (file)
@@ -11507,10 +11507,10 @@ static int ixgbe_recovery_probe(struct ixgbe_adapter *adapter)
 shutdown_aci:
        mutex_destroy(&adapter->hw.aci.lock);
        ixgbe_release_hw_control(adapter);
-       devlink_free(adapter->devlink);
 clean_up_probe:
        disable_dev = !test_and_set_bit(__IXGBE_DISABLED, &adapter->state);
        free_netdev(netdev);
+       devlink_free(adapter->devlink);
        pci_release_mem_regions(pdev);
        if (disable_dev)
                pci_disable_device(pdev);