ice: eswitch: fix use-after-free of metadata_dst in repr release
Subsystems (4)
PATCH v2 1/1 ice: eswitch: fix use-after-free of metadata_dst in repr release
ice_eswitch_release_repr() frees the port representor metadata_dst via metadata_dst_free(), which directly kfree()s the object and ignores the dst_entry refcount. The eswitch slow-path TX routine ice_eswitch_port_start_xmit() takes a reference on this dst with dst_hold() and attaches it to the skb via skb_dst_set(). If such an skb is still in flight (e.g. queued in a qdisc) when the representor is torn down, the metadata_dst is freed while the skb still points at it. When the skb is later freed, dst_release() operates on already-freed memory.
Replace metadata_dst_free() with dst_release() so the metadata_dst is freed only after the last reference is dropped. The dst subsystem frees metadata_dst objects from dst_destroy() once the refcount reaches zero (DST_METADATA is set by metadata_dst_alloc()).
Same class of bug and fix as commit c32b26aaa2f9 ("netfilter:nft_tunnel: fix use-after-free on object destroy").
---
v2:
- Correct the Fixes: tag to 1a1c40df2e80 ("ice: set and release switchdev environment"); the previously cited fff292b47ac1 only moved the affected code rather than introducing the unbalanced free, and the bug dates back to when switchdev support was added (Simon Horman).
- Add Simon Horman's Reviewed-by. No functional change.
drivers/net/ethernet/intel/ice/ice_eswitch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_eswitch.c +1 -1
@@ -95,7 +95,7 @@ ice_eswitch_release_repr(struct ice_pf *pf, struct ice_repr *repr)return ;ice_vsi_update_security (vsi, ice_vsi_ctx_set_antispoof); -metadata_dst_free (repr->dst); +dst_release (&repr->dst->dst); repr->dst =NULL ;ice_fltr_add_mac_and_broadcast (vsi, repr->parent_mac,ICE_FWD_TO_VSI );
--
2.43.0
Quoted 66 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Doruk Tan Ozturk
Sent: Thursday, June 18, 2026 4:50 PM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Drewek, Wojciech <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [Intel-wired-lan] [PATCH net v2] ice: eswitch: fix use-after- free ofmetadata_dstin repr release
ice_eswitch_release_repr()frees the port representormetadata_dstviametadata_dst_free(), which directly kfree()s the object and ignores thedst_entryrefcount. The eswitch slow-path TX routineice_eswitch_port_start_xmit()takes a reference on this dst withdst_hold()and attaches it to the skb viaskb_dst_set(). If such an skb is still in flight (e.g. queued in a qdisc) when the representor is torn down, themetadata_dstis freed while the skb still points at it. When the skb is later freed,dst_release()operates on already- freed memory.Replace
metadata_dst_free()withdst_release()so themetadata_dstis freed only after the last reference is dropped. The dst subsystem freesmetadata_dstobjects fromdst_destroy()once the refcount reaches zero (DST_METADATAis set bymetadata_dst_alloc()).Same class of bug and fix as commit
c32b26aaa2f9("netfilter:nft_tunnel: fix use-after-free on object destroy").Fixes 1a1c40df2e80 ("ice: set and release switchdev environment")Signed-off-by Doruk Tan Ozturk <[email protected]>Reviewed-by Simon Horman <[email protected]>---
v2:
- Correct the Fixes: tag to1a1c40df2e80("ice: set and release switchdev environment"); the previously citedfff292b47ac1only
moved
the affected code rather than introducing the unbalanced free, and
the
bug dates back to when switchdev support was added (Simon Horman).
- Add Simon Horman's Reviewed-by. No functional change.drivers/net/ethernet/intel/ice/ice_eswitch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/intel/ice/ice_eswitch.c +1
-1@@ -95,7 +95,7 @@ ice_eswitch_release_repr(struct ice_pf *pf, struct ice_repr *repr) return;ice_vsi_update_security (vsi, ice_vsi_ctx_set_antispoof); -metadata_dst_free (repr->dst); +dst_release (&repr->dst->dst); repr->dst =NULL ; ice_fltr_add_mac_and_broadcast(vsi, repr->parent_mac,
Quoted 3 lines
ICE_FWD_TO_VSI);
--
2.43.0
Quoted 14 lines · Doruk Tan Ozturk
ice_eswitch_release_repr()frees the port representormetadata_dstviametadata_dst_free(), which directly kfree()s the object and ignores thedst_entryrefcount. The eswitch slow-path TX routineice_eswitch_port_start_xmit()takes a reference on this dst withdst_hold()and attaches it to the skb viaskb_dst_set(). If such an skb is still in flight (e.g. queued in a qdisc) when the representor is torn down, themetadata_dstis freed while the skb still points at it. When the skb is later freed,dst_release()operates on already-freed memory.Replace
metadata_dst_free()withdst_release()so themetadata_dstis freed only after the last reference is dropped. The dst subsystem freesmetadata_dstobjects fromdst_destroy()once the refcount reaches zero (DST_METADATAis set bymetadata_dst_alloc()).
Quoted 7 lines
Same class of bug and fix as commit
c32b26aaa2f9("netfilter:nft_tunnel: fix use-after-free on object destroy").Fixes 1a1c40df2e80 ("ice: set and release switchdev environment")Signed-off-by Doruk Tan Ozturk <[email protected]>Reviewed-by Simon Horman <[email protected]>
Quoted 26 lines
---
v2:
- Correct the Fixes: tag to1a1c40df2e80("ice: set and release switchdev environment"); the previously citedfff292b47ac1only moved the affected code rather than introducing the unbalanced free, and the bug dates back to when switchdev support was added (Simon Horman).
- Add Simon Horman's Reviewed-by. No functional change.drivers/net/ethernet/intel/ice/ice_eswitch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/intel/ice/ice_eswitch.c +1
-2@@ -95,7 +95,7 @@ ice_eswitch_release_repr(struct ice_pf *pf, struct ice_repr *repr)return ;ice_vsi_update_security (vsi, ice_vsi_ctx_set_antispoof); -metadata_dst_free (repr->dst); +dst_release (&repr->dst->dst); repr->dst =NULL ;ice_fltr_add_mac_and_broadcast (vsi, repr->parent_mac,ICE_FWD_TO_VSI ); --2.43.0
Holda, Patryk
Tested-byQuoted 65 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Marcin Szycik
Sent: Wednesday, June 24, 2026 1:36 PM
To: Doruk Tan Ozturk <[email protected]>; Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Drewek, Wojciech <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [Intel-wired-lan] [PATCH net v2] ice: eswitch: fix use-after-free ofmetadata_dstin repr release
Importance: HighQuoted 8 lines · Doruk Tan Ozturk
ice_eswitch_release_repr()frees the port representormetadata_dstviametadata_dst_free(), which directly kfree()s the object and ignores thedst_entryrefcount. The eswitch slow-path TX routineice_eswitch_port_start_xmit()takes a reference on this dst withdst_hold()and attaches it to the skb viaskb_dst_set(). If such an skb is still in flight (e.g. queued in a qdisc) when the representor is torn down, themetadata_dstis freed while the skb still points at it. When the skb is later freed,dst_release()operates on already-freedmemory.
Quoted 6 lines
Replace
metadata_dst_free()withdst_release()so themetadata_dstis freed only after the last reference is dropped. The dst subsystem freesmetadata_dstobjects fromdst_destroy()once the refcount reaches zero (DST_METADATAis set bymetadata_dst_alloc()).Quoted 7 lines
Same class of bug and fix as commit
c32b26aaa2f9("netfilter:nft_tunnel: fix use-after-free on object destroy").Fixes 1a1c40df2e80 ("ice: set and release switchdev environment")Signed-off-by Doruk Tan Ozturk <[email protected]>Reviewed-by Simon Horman <[email protected]>Reviewed-by Marcin Szycik <[email protected]>drivers/net/ethernet/intel/ice/ice_eswitch.c ice_eswitch_release_repr(struct ice_pf *pf, struct
Quoted 17 lines
---
v2:
- Correct the Fixes: tag to1a1c40df2e80("ice: set and release switchdev environment"); the previously citedfff292b47ac1only moved the affected code rather than introducing the unbalanced free, and the bug dates back to when switchdev support was added (Simon Horman).
- Add Simon Horman's Reviewed-by. No functional change.drivers/net/ethernet/intel/ice/ice_eswitch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/intel/ice/ice_eswitch.c +0
-0@@ -95,7 +95,7 @@ ice_eswitch_release_repr(struct ice_pf *pf, struct
ice_repr*repr)Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +0
-0return ;
Quoted 8 lines
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +1
-2ice_vsi_update_security (vsi, ice_vsi_ctx_set_antispoof); -metadata_dst_free (repr->dst); +dst_release (&repr->dst->dst); repr->dst =NULL ;ice_fltr_add_mac_and_broadcast (vsi, repr->parent_mac,ICE_FWD_TO_VSI ); --2.43.0