Skip to contentSkip to conversation

ice: fix double free in ice_sf_eth_activate() error path

PATCH In review Greg Kroah-Hartman 3 participants 3 messages Apr 9 – Apr 10

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ice: fix double free in ice_sf_eth_activate() error path

When auxiliary_device_add() fails, the aux_dev_uninit label calls auxiliary_device_uninit() and falls through to sf_dev_free and xa_erase. The uninit invokes ice_sf_dev_release(), which already frees sf_dev via kfree() and erases the entry from ice_sf_aux_id. The fall-through then double-frees sf_dev and double-erases the id.

This is reachable from userspace via the devlink port function state-set netlink command.

Fix this by returning right after uninit because the release callback handles all cleanup correctly.

Cc Tony Nguyen <[email protected]>
Cc Przemek Kitszel <[email protected]>
Cc Andrew Lunn <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc Piotr Raczynski <[email protected]>
Cc Jiri Pirko <[email protected]>
Cc Simon Horman <[email protected]>
Cc Michal Swiatkowski <[email protected]>
Fixes 177ef7f1e2a0 ("ice: base subfunction aux driver")
Cc stable <[email protected]>
Assisted-by gregkh_clanker_t1000
---
 drivers/net/ethernet/intel/ice/ice_sf_eth.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/intel/ice/ice_sf_eth.c +2 -0
index 2cf04bc6edce..6bc8aa896762 100644
@@ -304,7 +304,9 @@ ice_sf_eth_activate(struct ice_dynamic_port *dyn_port,
 	return 0;
 
 aux_dev_uninit:
+	/* ice_sf_dev_release() frees sf_dev and erases the xa entry */
 	auxiliary_device_uninit(&sf_dev->adev);
+	return err;
 sf_dev_free:
 	kfree(sf_dev);
 xa_erase:
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 68 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Greg Kroah-Hartman
Sent: Thursday, April 9, 2026 5:11 PM
To: [email protected]; [email protected]
Cc: [email protected]; Greg Kroah-Hartman <[email protected]>; 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]>; Piotr Raczynski <[email protected]>; Jiri Pirko <[email protected]>; Simon Horman <[email protected]>; Michal Swiatkowski <[email protected]>; stable <[email protected]>
Subject: [Intel-wired-lan] [PATCH net] ice: fix double free in ice_sf_eth_activate() error path

When auxiliary_device_add() fails, the aux_dev_uninit label calls auxiliary_device_uninit() and falls through to sf_dev_free and xa_erase.
The uninit invokes ice_sf_dev_release(), which already frees sf_dev via
kfree() and erases the entry from ice_sf_aux_id. The fall-through then double-frees sf_dev and double-erases the id.

This is reachable from userspace via the devlink port function state- set netlink command.

Fix this by returning right after uninit because the release callback handles all cleanup correctly.

Cc Tony Nguyen <[email protected]>
Cc Przemek Kitszel <[email protected]>
Cc Andrew Lunn <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc Piotr Raczynski <[email protected]>
Cc Jiri Pirko <[email protected]>
Cc Simon Horman <[email protected]>
Cc Michal Swiatkowski <[email protected]>
Fixes 177ef7f1e2a0 ("ice: base subfunction aux driver")
Cc stable <[email protected]>
Assisted-by gregkh_clanker_t1000
---
 drivers/net/ethernet/intel/ice/ice_sf_eth.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/intel/ice/ice_sf_eth.c +2 -0
index 2cf04bc6edce..6bc8aa896762 100644
@@ -304,7 +304,9 @@ ice_sf_eth_activate(struct ice_dynamic_port
 *dyn_port,
 	return 0;
 
 aux_dev_uninit:
+	/* ice_sf_dev_release() frees sf_dev and erases the xa entry */
 	auxiliary_device_uninit(&sf_dev->adev);
+	return err;
 sf_dev_free:
 	kfree(sf_dev);
Quoted 3 lines

xa_erase:
--
2.53.0

Reviewed-by on v1 1/1
#2 lore raw
In reply to Greg Kroah-Hartman

Dear Greg,

Thank you for the patch.

Am 09.04.26 um 17:11 schrieb Greg Kroah-Hartman:

Quoted 36 lines

When auxiliary_device_add() fails, the aux_dev_uninit label calls auxiliary_device_uninit() and falls through to sf_dev_free and xa_erase. The uninit invokes ice_sf_dev_release(), which already frees sf_dev via kfree() and erases the entry from ice_sf_aux_id. The fall-through then double-frees sf_dev and double-erases the id.

This is reachable from userspace via the devlink port function state-set netlink command.

Fix this by returning right after uninit because the release callback handles all cleanup correctly.

Cc Tony Nguyen <[email protected]>
Cc Przemek Kitszel <[email protected]>
Cc Andrew Lunn <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc Piotr Raczynski <[email protected]>
Cc Jiri Pirko <[email protected]>
Cc Simon Horman <[email protected]>
Cc Michal Swiatkowski <[email protected]>
Fixes 177ef7f1e2a0 ("ice: base subfunction aux driver")
Cc stable <[email protected]>
Assisted-by gregkh_clanker_t1000
---
  drivers/net/ethernet/intel/ice/ice_sf_eth.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/net/ethernet/intel/ice/ice_sf_eth.c +0 -0
index 2cf04bc6edce..6bc8aa896762 100644

drivers/net/ethernet/intel/ice/ice_sf_eth.c ice_sf_eth_activate(struct ice_dynamic_port *dyn_port, · line 312

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_sf_eth.c +2 -0
@@ -304,7 +304,9 @@ ice_sf_eth_activate(struct ice_dynamic_port *dyn_port,
  	return 0;
 
  aux_dev_uninit:
+	/* ice_sf_dev_release() frees sf_dev and erases the xa entry */
  	auxiliary_device_uninit(&sf_dev->adev);
+	return err;
  sf_dev_free:
  	kfree(sf_dev);
  xa_erase:

Kind regards,

Paul