]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
idpf: fix double free and use-after-free in aux device error paths
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 May 2026 21:48:13 +0000 (14:48 -0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 8 May 2026 23:01:09 +0000 (16:01 -0700)
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 ("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 <anthony.l.nguyen@intel.com>
Cc: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>
Cc: stable@kernel.org
Fixes: be91128c579c ("idpf: implement RDMA vport auxiliary dev create, init, and destroy")
Fixes: f4312e6bfa2a ("idpf: implement core RDMA auxiliary dev create, init, and destroy")
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://patch.msgid.link/20260506-jk-iwl-net-2026-05-04-v2-4-a5ea4dc837a9@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/intel/idpf/idpf_idc.c

index 7e4f4ac9265377ed3440d6c4ca1dadf911172f09..b7d6b08fc89e89debe8c0e82399d8e62fa2d6ea2 100644 (file)
@@ -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: