Skip to contentSkip to conversation

idpf: fix double free and use-after-free in aux device error paths

PATCH In review Greg Kroah-Hartman 4 participants 5 messages Apr 11 – Apr 14

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

PATCH 1/1 idpf: fix double free and use-after-free in aux device error paths

When auxiliary_device_add() fails in idpf_plug_vport_aux_dev() or idpf_plug_core_aux_dev(), the err_aux_dev_add label calls auxiliary_device_uninit() and falls through to err_aux_dev_init. The uninit call will trigger put_device(), which invokes the release callback (idpf_vport_adev_release / idpf_core_adev_release) that frees iadev. The fall-through then reads adev->id from the freed iadev for ida_free() and double-frees iadev with kfree().

Free the IDA slot and clear the back-pointer before uninit, while adev is still valid, then return immediately.

Commit 65637c3a1811 65637c3a1811 ("idpf: fix UAF in RDMA core aux dev deinitialization") fixed the same use-after-free in the matching unplug path in this file but missed both probe error paths.

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 stable <[email protected]>
Fixes be91128c579c ("idpf: implement RDMA vport auxiliary dev create, init, and destroy")
Fixes f4312e6bfa2a ("idpf: implement core RDMA auxiliary dev create, init, and destroy")
Assisted-by gregkh_clanker_t1000

---
Note, these cleanup paths are messy, but I couldn't see a simpler way without a lot more rework, so I choose the simple way :)

 drivers/net/ethernet/intel/idpf/idpf_idc.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/ethernet/intel/idpf/idpf_idc.c +6 -0
index 7e4f4ac92653..b7d6b08fc89e 100644
@@ -90,7 +90,10 @@ static int idpf_plug_vport_aux_dev(struct iidc_rdma_core_dev_info *cdev_info,
 	return 0;
 
 err_aux_dev_add:
+	ida_free(&idpf_idc_ida, adev->id);
+	vdev_info->adev = NULL;
 	auxiliary_device_uninit(adev);
+	return ret;
 err_aux_dev_init:
 	ida_free(&idpf_idc_ida, adev->id);
 err_ida_alloc:
@@ -228,7 +231,10 @@ static int idpf_plug_core_aux_dev(struct iidc_rdma_core_dev_info *cdev_info)
 	return 0;
 
 err_aux_dev_add:
+	ida_free(&idpf_idc_ida, adev->id);
+	cdev_info->adev = NULL;
 	auxiliary_device_uninit(adev);
+	return ret;
 err_aux_dev_init:
 	ida_free(&idpf_idc_ida, adev->id);
 err_ida_alloc:
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 81 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Greg Kroah-Hartman
Sent: Saturday, April 11, 2026 12:12 PM
To: [email protected]
Cc: [email protected]; [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]>; stable <[email protected]>
Subject: [Intel-wired-lan] [PATCH net] idpf: fix double free and use- after-free in aux device error paths

When auxiliary_device_add() fails in idpf_plug_vport_aux_dev() or idpf_plug_core_aux_dev(), the err_aux_dev_add label calls auxiliary_device_uninit() and falls through to err_aux_dev_init. The uninit call will trigger put_device(), which invokes the release callback (idpf_vport_adev_release / idpf_core_adev_release) that frees iadev. The fall-through then reads adev->id from the freed iadev for ida_free() and double-frees iadev with kfree().

Free the IDA slot and clear the back-pointer before uninit, while adev is still valid, then return immediately.

Commit 65637c3a1811 65637c3a1811 ("idpf: fix UAF in RDMA core aux dev deinitialization") fixed the same use-after-free in the matching unplug path in this file but missed both probe error paths.

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 stable <[email protected]>
Fixes be91128c579c ("idpf: implement RDMA vport auxiliary dev create,

init, and destroy")

Fixes f4312e6bfa2a ("idpf: implement core RDMA auxiliary dev create,

init, and destroy")

Assisted-by gregkh_clanker_t1000

---
Note, these cleanup paths are messy, but I couldn't see a simpler way without a lot more rework, so I choose the simple way :)

 drivers/net/ethernet/intel/idpf/idpf_idc.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/ethernet/intel/idpf/idpf_idc.c +3 -0
index 7e4f4ac92653..b7d6b08fc89e 100644
@@ -90,7 +90,10 @@ static int idpf_plug_vport_aux_dev(struct
 iidc_rdma_core_dev_info *cdev_info,
 	return 0;
 
 err_aux_dev_add:
+	ida_free(&idpf_idc_ida, adev->id);
+	vdev_info->adev = NULL;
 	auxiliary_device_uninit(adev);
+	return ret;
 err_aux_dev_init:
 	ida_free(&idpf_idc_ida, adev->id);

err_ida_alloc:

drivers/net/ethernet/intel/idpf/idpf_idc.c +3 -0
@@ -228,7 +231,10 @@ static int idpf_plug_core_aux_dev(struct
 iidc_rdma_core_dev_info *cdev_info)
 	return 0;
 
 err_aux_dev_add:
+	ida_free(&idpf_idc_ida, adev->id);
+	cdev_info->adev = NULL;
 	auxiliary_device_uninit(adev);
+	return ret;
 err_aux_dev_init:
 	ida_free(&idpf_idc_ida, adev->id);
Quoted 3 lines

err_ida_alloc:
--
2.53.0

#2 lore raw
In reply to Greg Kroah-Hartman
Quoted 27 lines · Greg Kroah-Hartman

When auxiliary_device_add() fails in idpf_plug_vport_aux_dev() or idpf_plug_core_aux_dev(), the err_aux_dev_add label calls auxiliary_device_uninit() and falls through to err_aux_dev_init. The uninit call will trigger put_device(), which invokes the release callback (idpf_vport_adev_release / idpf_core_adev_release) that frees iadev. The fall-through then reads adev->id from the freed iadev for ida_free() and double-frees iadev with kfree().

Free the IDA slot and clear the back-pointer before uninit, while adev is still valid, then return immediately.

Commit 65637c3a1811 65637c3a1811 ("idpf: fix UAF in RDMA core aux dev deinitialization") fixed the same use-after-free in the matching unplug path in this file but missed both probe error paths.

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 stable <[email protected]>
Fixes be91128c579c ("idpf: implement RDMA vport auxiliary dev create, init, and destroy")
Fixes f4312e6bfa2a ("idpf: implement core RDMA auxiliary dev create, init, and destroy")
Assisted-by gregkh_clanker_t1000
Quoted 1 line

---

This is targeted at [net]. The fix seems straight forward enough. @Jakub, I have no objections if you want to pull this directly. I am not sure our validation team will find anything when testing since this is an error path that is historically been difficult for us to test.

I'm also fine with taking it through iwl-net if you prefer, but just want to avoid duplicate work if you're already considering it.

Quoted 3 lines

Note, these cleanup paths are messy, but I couldn't see a simpler way without a lot more rework, so I choose the simple way :)

Yea, I didn't see a better way either.

Thanks,
Jake

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

Dear Greg,

Thank you for the patch.

Am 11.04.26 um 12:12 schrieb Greg Kroah-Hartman:

Quoted 8 lines

When auxiliary_device_add() fails in idpf_plug_vport_aux_dev() or idpf_plug_core_aux_dev(), the err_aux_dev_add label calls auxiliary_device_uninit() and falls through to err_aux_dev_init. The uninit call will trigger put_device(), which invokes the release callback (idpf_vport_adev_release / idpf_core_adev_release) that frees iadev. The fall-through then reads adev->id from the freed iadev for ida_free() and double-frees iadev with kfree().

Quoted 4 lines

Free the IDA slot and clear the back-pointer before uninit, while adev is still valid, then return immediately.

Commit 65637c3a1811 65637c3a1811 ("idpf: fix UAF in RDMA core aux dev

The commit hash is pasted twice.

Quoted 38 lines

deinitialization") fixed the same use-after-free in the matching unplug path in this file but missed both probe error paths.

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 stable <[email protected]>
Fixes be91128c579c ("idpf: implement RDMA vport auxiliary dev create, init, and destroy")
Fixes f4312e6bfa2a ("idpf: implement core RDMA auxiliary dev create, init, and destroy")
Assisted-by gregkh_clanker_t1000

---
Note, these cleanup paths are messy, but I couldn't see a simpler way without a lot more rework, so I choose the simple way :)

  drivers/net/ethernet/intel/idpf/idpf_idc.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/net/ethernet/intel/idpf/idpf_idc.c +3 -0
index 7e4f4ac92653..b7d6b08fc89e 100644
@@ -90,7 +90,10 @@ static int idpf_plug_vport_aux_dev(struct iidc_rdma_core_dev_info *cdev_info,
  	return 0;
 
  err_aux_dev_add:
+	ida_free(&idpf_idc_ida, adev->id);
+	vdev_info->adev = NULL;
  	auxiliary_device_uninit(adev);
+	return ret;
  err_aux_dev_init:
  	ida_free(&idpf_idc_ida, adev->id);
  err_ida_alloc:

drivers/net/ethernet/intel/idpf/idpf_idc.c static int idpf_plug_core_aux_dev(struct iidc_rdma_core_dev_info *cdev_info) · line 240

Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_idc.c +3 -0
@@ -228,7 +231,10 @@ static int idpf_plug_core_aux_dev(struct iidc_rdma_core_dev_info *cdev_info)
  	return 0;
 
  err_aux_dev_add:
+	ida_free(&idpf_idc_ida, adev->id);
+	cdev_info->adev = NULL;
  	auxiliary_device_uninit(adev);
+	return ret;
  err_aux_dev_init:
  	ida_free(&idpf_idc_ida, adev->id);
  err_ida_alloc:

gemini/gemini-3.1-pro-preview has two comments [1]. Maybe the driver developers could judge their relevance.

Kind regards,

Paul

[1]: https://sashiko.dev/#/patchset/2026041116-retail-bagginess-250f%40gregkh

#4 lore raw
Quoted 14 lines · Paul Menzel

Dear Greg,

Thank you for the patch.

Am 11.04.26 um 12:12 schrieb Greg Kroah-Hartman:

Quoted 8 lines

When auxiliary_device_add() fails in idpf_plug_vport_aux_dev() or idpf_plug_core_aux_dev(), the err_aux_dev_add label calls auxiliary_device_uninit() and falls through to err_aux_dev_init. The uninit call will trigger put_device(), which invokes the release callback (idpf_vport_adev_release / idpf_core_adev_release) that frees iadev. The fall-through then reads adev->id from the freed iadev for ida_free() and double-frees iadev with kfree().

Quoted 6 lines
Quoted 4 lines

Free the IDA slot and clear the back-pointer before uninit, while adev is still valid, then return immediately.

Commit 65637c3a1811 65637c3a1811 ("idpf: fix UAF in RDMA core aux dev

The commit hash is pasted twice.

Argh, when I cut/paste from my terminal that happened, my fault.

Quoted 49 lines
Quoted 37 lines

deinitialization") fixed the same use-after-free in the matching unplug path in this file but missed both probe error paths.

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 stable <[email protected]>
Fixes be91128c579c ("idpf: implement RDMA vport auxiliary dev create, init, and destroy")
Fixes f4312e6bfa2a ("idpf: implement core RDMA auxiliary dev create, init, and destroy")
Assisted-by gregkh_clanker_t1000

---
Note, these cleanup paths are messy, but I couldn't see a simpler way without a lot more rework, so I choose the simple way :)

  drivers/net/ethernet/intel/idpf/idpf_idc.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/net/ethernet/intel/idpf/idpf_idc.c +3 -0
index 7e4f4ac92653..b7d6b08fc89e 100644
@@ -90,7 +90,10 @@ static int idpf_plug_vport_aux_dev(struct iidc_rdma_core_dev_info *cdev_info,
  	return 0;
  err_aux_dev_add:
+	ida_free(&idpf_idc_ida, adev->id);
+	vdev_info->adev = NULL;
  	auxiliary_device_uninit(adev);
+	return ret;
  err_aux_dev_init:
  	ida_free(&idpf_idc_ida, adev->id);
  err_ida_alloc:

drivers/net/ethernet/intel/idpf/idpf_idc.c static int idpf_plug_core_aux_dev(struct iidc_rdma_core_dev_info *cdev_info) · line 239

Quoted 9 lines
drivers/net/ethernet/intel/idpf/idpf_idc.c +3 -0
@@ -228,7 +231,10 @@ static int idpf_plug_core_aux_dev(struct iidc_rdma_core_dev_info *cdev_info)
  	return 0;
  err_aux_dev_add:
+	ida_free(&idpf_idc_ida, adev->id);
+	cdev_info->adev = NULL;
  	auxiliary_device_uninit(adev);
+	return ret;
  err_aux_dev_init:
  	ida_free(&idpf_idc_ida, adev->id);
  err_ida_alloc:
Quoted 2 lines

gemini/gemini-3.1-pro-preview has two comments [1]. Maybe the driver developers could judge their relevance.

These "pre-existing" reports are getting annoying. While they are nice to see for driver authors, it makes developers sending bug fixes in feel like they are forced to do "more". I think they are trying to tune this to be a bit more sane...

thanks,

greg k-h