idpf: free the RDMA auxiliary device ID after deleting the device
Subsystems (3)
PATCH 1/1 idpf: free the RDMA auxiliary device ID after deleting the device
idpf_unplug_aux_dev() returns the ID to idpf_idc_ida before auxiliary_device_delete() removes the device. If another idpf device plugs an RDMA auxiliary device in between, it can get the same ID, and its auxiliary_device_add() fails with -EEXIST because the old "idpf.<vendor>.rdma.core.<id>" or "idpf.<vendor>.rdma.vdev.<id>" device is still registered. RDMA is then not set up on that device.
Free the ID after auxiliary_device_delete(). It still has to be freed before auxiliary_device_uninit(), whose release callback frees adev.
---
Found with a static analysis tool we are developing.
Compile-tested only, with x86_64_defconfig plus IDPF and W=1.
drivers/net/ethernet/intel/idpf/idpf_idc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_idc.c +1 -2
@@ -253,9 +253,8 @@ static void idpf_unplug_aux_dev(struct auxiliary_device *adev)if (!adev)return ; -ida_free (&idpf_idc_ida, adev->id); -auxiliary_device_delete (adev); +ida_free (&idpf_idc_ida, adev->id);auxiliary_device_uninit (adev); }
base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
Signature · 1 line
2.43.0
Quoted 10 lines · Changyul Lee
idpf_unplug_aux_dev()returns the ID toidpf_idc_idabeforeauxiliary_device_delete()removes the device. If another idpf device plugs an RDMA auxiliary device in between, it can get the same ID, and itsauxiliary_device_add()fails with-EEXISTbecause the old "idpf.<vendor>.rdma.core.<id>" or "idpf.<vendor>.rdma.vdev.<id>" device is still registered. RDMA is then not set up on that device.Free the ID after
auxiliary_device_delete(). It still has to be freed beforeauxiliary_device_uninit(), whose release callback frees adev.
Quoted 6 lines
Fixes 65637c3a1811 ("idpf: fix UAF in RDMA core aux dev deinitialization")Signed-off-by Changyul Lee <[email protected]>---
Found with a static analysis tool we are developing.Compile-tested only, with
x86_64_defconfigplus IDPF and W=1.