ixgbe: fix memory leak and use-after-free in ixgbe_recovery_probe()
Subsystems (3)
PATCH 1/1 ixgbe: fix memory leak and use-after-free in ixgbe_recovery_probe()
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().
---
Cc: Koichiro Den <[email protected]>
--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +1 -1
@@ -11510,10 +11510,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);
Signature · 1 line
2.51.0
Quoted 49 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Kohei Enju
Sent: Sunday, August 31, 2025 10:33 PM
To: [email protected]; [email protected]
Cc: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Wegrzyn, Stefan <[email protected]>; Mateusz Polchlopek <[email protected]>; Jagielski, Jedrzej <[email protected]>; [email protected]; Kohei Enju <[email protected]>; Koichiro Den <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-net v1] ixgbe: fix memory leak and use-after-free inixgbe_recovery_probe()The error path of
ixgbe_recovery_probe()has two memory bugs.For non-E610 adapters, the function jumps to
clean_up_probewithout callingdevlink_free(), leaking the devlink instance and its embedded adapter structure.For E610 adapters,
devlink_free()is called atshutdown_aci, butclean_up_probethen accessesadapter->state, sometimes triggering use-after-free because adapter is embedded in devlink. This UAF is similar to the one recently reported inixgbe_remove(). (Link)Fix both issues by moving
devlink_free()afteradapter->stateaccess, aligning with the cleanup order inixgbe_probe().Fixes 29cb3b8d95c7 ("ixgbe: add E610 implementation of FW recoverymode")
Signed-off-by Kohei Enju <[email protected]>---
Cc: Koichiro Den <[email protected]>--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0
-0
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static int ixgbe_recovery_probe(struct · line 11517
Quoted 9 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0
-1@@ -11510,10 +11510,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);
I'd add a guard here: if (adapter->devlink)
What do you think?
Quoted 6 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +1
-0+devlink_free (adapter->devlink);pci_release_mem_regions (pdev);drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0
-1if (disable_dev)pci_disable_device (pdev); --2.51.0
Quoted 15 lines · Aleksandr
Quoted 15 lines
[...]
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0
-1@@ -11510,10 +11510,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-
Quoted 4 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static int ixgbe_recovery_probe(struct · line 11517
Quoted 2 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0
-0>state);free_netdev (netdev);I'd add a guard here: if (
adapter->devlink)
What do you think?
Thank you for the review.
Currently ixgbe_recovery_probe() is only called from one location, ixgbe_probe(), and also always adapter->devlink is not NULL in this path since this is called after ixgbe_allocate_devlink(). In other words, if ixgbe_allocate_devlink() fails, ixgbe_recovery_probe() never be called.
So I've thought that the guard might not be necessary like error handling in ixgbe_probe(), but could you let me know your concern if I'm overlooking something?
Thanks,
Kohei.
Quoted 6 lines
Quoted 6 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +1
-0+devlink_free (adapter->devlink);pci_release_mem_regions (pdev);drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0
-1if (disable_dev)pci_disable_device (pdev); --2.51.0
Loktionov, Aleksandr
Reviewed-byQuoted 78 lines
-----Original Message-----
From: Kohei Enju <[email protected]>
Sent: Monday, September 1, 2025 10:38 AM
To: Loktionov, Aleksandr <[email protected]>
Cc: [email protected]; Nguyen, Anthony L <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; intel-wired- [email protected]; Jagielski, Jedrzej <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Kitszel, Przemyslaw <[email protected]>; Wegrzyn, Stefan <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-net v1] ixgbe: fix memory leak and use-after-free inixgbe_recovery_probe()Quoted 30 lines · Aleksandr
Quoted 29 lines
[...]
(quoted diff) +0
-0
b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.cindex
ff6e8ebda5ba..08368e2717c2100644---
a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c+++
b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c(quoted diff) +0
-1@@ -11510,10 +11510,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-Quoted 7 lines
Quoted 3 lines
Quoted 1 line
state);
free_netdev(netdev);I'd add a guard here: if (
adapter->devlink)What do you think?
Thank you for the review.
Currently
ixgbe_recovery_probe()is only called from one location,
ixgbe_probe(), and also alwaysadapter->devlinkis not NULL in this pathsince this is called after
ixgbe_allocate_devlink(). In other words, if
ixgbe_allocate_devlink()fails,ixgbe_recovery_probe()never be called.
Quoted 6 lines
So I've thought that the guard might not be necessary like error
handling in
ixgbe_probe(), but could you let me know your concern if I'moverlooking something?
Good day, Kohei
Thank you for the explanation.
You are technically right (today), and not having the guard doesn't make the patch incorrect!
That said, error-paths tend to evolve. A tiny if (adapter->devlink) { devlink_free(...); adapter->devlink = NULL; }
makes this code resilient to future refactors or partial init/unwind changes and prevents potential double-free if another label ever frees it earlier. I'm fine either way for this fix, but I'd prefer the guard+NULL for robustness and consistency with typical probe unwind patterns.
Quoted 20 lines
Thanks,
Kohei.
Quoted 11 lines
Quoted 11 lines
(quoted diff) +1
-1+ devlink_free(adapter->devlink); pci_release_mem_regions(pdev); if (disable_dev) pci_disable_device(pdev); --2.51.0
From: Kohei Enju <[email protected]>
Sent: Sunday, August 31, 2025 10:33 PM
Quoted 36 lines
The error path of
ixgbe_recovery_probe()has two memory bugs.For non-E610 adapters, the function jumps to
clean_up_probewithout callingdevlink_free(), leaking the devlink instance and its embedded adapter structure.For E610 adapters,
devlink_free()is called atshutdown_aci, butclean_up_probethen accessesadapter->state, sometimes triggering use-after-free because adapter is embedded in devlink. This UAF is similar to the one recently reported inixgbe_remove(). (Link)Fix both issues by moving
devlink_free()afteradapter->stateaccess, aligning with the cleanup order inixgbe_probe().Fixes 29cb3b8d95c7 ("ixgbe: add E610 implementation of FW recovery mode")Signed-off-by Kohei Enju <[email protected]>---
Cc: Koichiro Den <[email protected]>
---drivers/net/ethernet/intel/ixgbe/ixgbe_main.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0
-0@@ -11510,10 +11510,10 @@ static int ixgbe_recovery_probe(struct ixgbe_adapter *adapter)
shutdown_aci:mutex_destroy(&adapter->hw.aci.lock); ixgbe_release_hw_control(adapter);drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0
-1-devlink_free (adapter->devlink);
clean_up_probe:disable_dev = !test_and_set_bit(__IXGBE_DISABLED, &adapter->state); free_netdev(netdev);drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +1
-0+devlink_free (adapter->devlink);
Quoted 5 lines
pci_release_mem_regions(pdev); if (disable_dev) pci_disable_device(pdev);Signature · 1 line
2.51.0
Much thanks for finding and fixing it!
Quoted 15 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Kohei Enju
Sent: 01 September 2025 02:03
To: [email protected]; [email protected]
Cc: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Wegrzyn, Stefan <[email protected]>; Mateusz Polchlopek <[email protected]>; Jagielski, Jedrzej <[email protected]>; [email protected]; Kohei Enju <[email protected]>; Koichiro Den <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-net v1] ixgbe: fix memory leak and use-after-free inixgbe_recovery_probe()The error path of
ixgbe_recovery_probe()has two memory bugs.For non-E610 adapters, the function jumps to
clean_up_probewithout callingdevlink_free(), leaking the devlink instance and its embedded adapter structure.For E610 adapters,
devlink_free()is called atshutdown_aci, butclean_up_probethen accessesadapter->state, sometimes triggering use-after-free because adapter is embedded in devlink. This UAF is similar to the one recently reported inixgbe_remove(). (Link)Fix both issues by moving
devlink_free()afteradapter->stateaccess, aligning with the cleanup order inixgbe_probe().
Quoted 9 lines
Fixes 29cb3b8d95c7 ("ixgbe: add E610 implementation of FW recovery mode")Signed-off-by Kohei Enju <[email protected]>---
Cc: Koichiro Den <[email protected]>
---drivers/net/ethernet/intel/ixgbe/ixgbe_main.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 63 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Kohei Enju
Sent: Sunday, August 31, 2025 10:33 PM
To: [email protected]; [email protected]
Cc: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Wegrzyn, Stefan <[email protected]>; Mateusz Polchlopek <[email protected]>; Jagielski, Jedrzej <[email protected]>; [email protected]; Kohei Enju <[email protected]>; Koichiro Den <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-net v1] ixgbe: fix memory leak and use-after-free inixgbe_recovery_probe()The error path of
ixgbe_recovery_probe()has two memory bugs.For non-E610 adapters, the function jumps to
clean_up_probewithout callingdevlink_free(), leaking the devlink instance and its embedded adapter structure.For E610 adapters,
devlink_free()is called atshutdown_aci, butclean_up_probethen accessesadapter->state, sometimes triggering use- after-free because adapter is embedded in devlink. This UAF is similar to the one recently reported inixgbe_remove(). (Link)Fix both issues by moving
devlink_free()afteradapter->stateaccess, aligning with the cleanup order inixgbe_probe().Fixes 29cb3b8d95c7 ("ixgbe: add E610 implementation of FW recoverymode")
Signed-off-by Kohei Enju <[email protected]>---
Cc: Koichiro Den <[email protected]>--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +1
-1@@ -11510,10 +11510,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);drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0
-1if (disable_dev)pci_disable_device (pdev); --
Quoted 1 line
2.51.0