* FAILED: patch "[PATCH] RDMA/irdma: avoid use-after-free in icrdma_remove" failed to apply to 6.12-stable tree
@ 2026-11-04 13:36 gregkh
2026-12-05 20:05 ` Dickson Wu
0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2026-11-04 13:36 UTC (permalink / raw)
To: lgs201920130244, leon; +Cc: stable
The patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x 8a8088b899e4cdfe558428cd6113d45df81625be
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026110441-support-onboard-d0bb@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 8a8088b899e4cdfe558428cd6113d45df81625be Mon Sep 17 00:00:00 2001
From: Guangshuo Li <lgs201920130244@gmail.com>
Date: Mon, 14 Sep 2026 20:28:40 +0800
Subject: [PATCH] RDMA/irdma: avoid use-after-free in icrdma_remove
icrdma_remove() dereferences iwdev after calling
irdma_ib_unregister_device():
irdma_ib_unregister_device(iwdev)
-> ib_unregister_device(&iwdev->ibdev)
-> __ib_unregister_device()
-> ib_dealloc_device()
irdma registers irdma_ib_dealloc_device() as the dealloc_driver
callback in its ib_device_ops. The RDMA core explicitly documents
ib_unregister_device() that when ops.dealloc_driver is used, ib_dev
will be freed upon return from the function.
The ib_device is embedded in struct irdma_device and iwdev itself was
allocated by ib_alloc_device(irdma_device, ibdev). Consequently, once
irdma_ib_unregister_device() returns, iwdev must no longer be
dereferenced.
However, icrdma_remove() currently accesses iwdev->rf afterwards when
deinitializing interrupts, destroying ah_tbl_lock, and freeing rf.
Although the final ib_device storage is released with kfree_rcu(), the
object lifetime has already ended and callers must not rely on the RCU
grace period to continue dereferencing iwdev.
Save iwdev->rf before unregistering the RDMA device and use the saved
pointer for the remaining cleanup.
This issue was found by manual code inspection.
Fixes: 8498a30e1b94 ("RDMA/irdma: Register auxiliary driver and implement private channel OPs")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
Link: https://patch.msgid.link/20260914122840.1709743-1-lgs201920130244@gmail.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
diff --git a/drivers/infiniband/hw/irdma/icrdma_if.c b/drivers/infiniband/hw/irdma/icrdma_if.c
index 4b451d8482a4..f405ef761f84 100644
--- a/drivers/infiniband/hw/irdma/icrdma_if.c
+++ b/drivers/infiniband/hw/irdma/icrdma_if.c
@@ -318,14 +318,15 @@ static void icrdma_remove(struct auxiliary_device *aux_dev)
container_of(aux_dev, struct iidc_rdma_core_auxiliary_dev, adev);
struct iidc_rdma_core_dev_info *cdev_info = idc_adev->cdev_info;
struct irdma_device *iwdev = auxiliary_get_drvdata(aux_dev);
- u8 rdma_ver = iwdev->rf->rdma_ver;
+ struct irdma_pci_f *rf = iwdev->rf;
+ u8 rdma_ver = rf->rdma_ver;
ice_rdma_update_vsi_filter(cdev_info, iwdev->vsi_num, false);
irdma_ib_unregister_device(iwdev);
- icrdma_deinit_interrupts(iwdev->rf, cdev_info);
- mutex_destroy(&iwdev->rf->ah_tbl_lock);
+ icrdma_deinit_interrupts(rf, cdev_info);
+ mutex_destroy(&rf->ah_tbl_lock);
- kfree(iwdev->rf);
+ kfree(rf);
pr_debug("INIT: Gen[%d] func[%d] device remove success\n",
rdma_ver, PCI_FUNC(cdev_info->pdev->devfn));
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 6.12.y] RDMA/irdma: avoid use-after-free in icrdma_remove
2026-11-04 13:36 FAILED: patch "[PATCH] RDMA/irdma: avoid use-after-free in icrdma_remove" failed to apply to 6.12-stable tree gregkh
@ 2026-12-05 20:05 ` Dickson Wu
0 siblings, 0 replies; 4+ messages in thread
From: Dickson Wu via B4 Relay @ 2026-12-05 20:05 UTC (permalink / raw)
To: stable
Cc: Tatyana Nikolova, Jason Gunthorpe, Leon Romanovsky, Shiraz Saleem,
Mustafa Ismail, gustavoars, linux-rdma, linux-kernel,
Guangshuo Li
From: Guangshuo Li <lgs201920130244@gmail.com>
commit 8a8088b899e4cdfe558428cd6113d45df81625be upstream.
icrdma_remove() dereferences iwdev after calling
irdma_ib_unregister_device():
irdma_ib_unregister_device(iwdev)
-> ib_unregister_device(&iwdev->ibdev)
-> __ib_unregister_device()
-> ib_dealloc_device()
irdma registers irdma_ib_dealloc_device() as the dealloc_driver
callback in its ib_device_ops. The RDMA core explicitly documents
ib_unregister_device() that when ops.dealloc_driver is used, ib_dev
will be freed upon return from the function.
The ib_device is embedded in struct irdma_device and iwdev itself was
allocated by ib_alloc_device(irdma_device, ibdev). Consequently, once
irdma_ib_unregister_device() returns, iwdev must no longer be
dereferenced.
However, icrdma_remove() currently accesses iwdev->rf afterwards when
deinitializing interrupts, destroying ah_tbl_lock, and freeing rf.
Although the final ib_device storage is released with kfree_rcu(), the
object lifetime has already ended and callers must not rely on the RCU
grace period to continue dereferencing iwdev.
Save iwdev->rf before unregistering the RDMA device and use the saved
pointer for the remaining cleanup.
This issue was found by manual code inspection.
Fixes: 8498a30e1b94 ("RDMA/irdma: Register auxiliary driver and implement private channel OPs")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
Link: https://patch.msgid.link/20260914122840.1709743-1-lgs201920130244@gmail.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
[ adapted to 6.12.y: save the VSI number and keep filter removal order ]
Signed-off-by: Dickson Wu <dickson.wu@certik.com>
---
In 6.12.y the Gen2 remove path is irdma_remove() in main.c, and
irdma_ib_dealloc_device() already tears down interrupts and frees rf
inside the unregister, so the only use of iwdev after
irdma_ib_unregister_device() is the VSI number passed to
ice_rdma_update_vsi_filter(). Save it first. Mainline moved the filter
update before the unregister in a separate IDC refactor (c24a65b6a27c);
this keeps the 6.12.y order.
Tested on v6.12.120:
- x86_64 allmodconfig W=1 build of drivers/infiniband/hw/irdma/main.o,
base vs patched, no new warnings
- booted base and patched kernels under QEMU/KVM with ICE and irdma
built in; both registered the InfiniBand class and the auxiliary
driver. There is no ICE RDMA device in the guest, so the remove path
itself was not exercised at runtime.
The backport and the test runs were prepared with AI coding tools
(OpenAI Codex agents, with review by Claude). I went over the result
before signing off.
---
drivers/infiniband/hw/irdma/main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/irdma/main.c b/drivers/infiniband/hw/irdma/main.c
index 3f13200ff71b..7ec58c467e42 100644
--- a/drivers/infiniband/hw/irdma/main.c
+++ b/drivers/infiniband/hw/irdma/main.c
@@ -213,9 +213,10 @@ static void irdma_remove(struct auxiliary_device *aux_dev)
adev);
struct ice_pf *pf = iidc_adev->pf;
struct irdma_device *iwdev = auxiliary_get_drvdata(aux_dev);
+ u16 vsi_num = iwdev->vsi_num;
irdma_ib_unregister_device(iwdev);
- ice_rdma_update_vsi_filter(pf, iwdev->vsi_num, false);
+ ice_rdma_update_vsi_filter(pf, vsi_num, false);
pr_debug("INIT: Gen2 PF[%d] device remove success\n", PCI_FUNC(pf->pdev->devfn));
}
---
base-commit: fa3ff5a9ce6f5ada4510bda0d8b891018a0be4b7
change-id: 20261205-irdma-612-b9477db5f92f
Best regards,
--
Dickson Wu <dickson.wu@certik.com>
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 6.12.y] RDMA/irdma: avoid use-after-free in icrdma_remove
@ 2026-12-05 20:05 ` Dickson Wu
0 siblings, 0 replies; 4+ messages in thread
From: Dickson Wu @ 2026-12-05 20:05 UTC (permalink / raw)
To: stable
Cc: Tatyana Nikolova, Jason Gunthorpe, Leon Romanovsky, Shiraz Saleem,
Mustafa Ismail, gustavoars, linux-rdma, linux-kernel,
Guangshuo Li
From: Guangshuo Li <lgs201920130244@gmail.com>
commit 8a8088b899e4cdfe558428cd6113d45df81625be upstream.
icrdma_remove() dereferences iwdev after calling
irdma_ib_unregister_device():
irdma_ib_unregister_device(iwdev)
-> ib_unregister_device(&iwdev->ibdev)
-> __ib_unregister_device()
-> ib_dealloc_device()
irdma registers irdma_ib_dealloc_device() as the dealloc_driver
callback in its ib_device_ops. The RDMA core explicitly documents
ib_unregister_device() that when ops.dealloc_driver is used, ib_dev
will be freed upon return from the function.
The ib_device is embedded in struct irdma_device and iwdev itself was
allocated by ib_alloc_device(irdma_device, ibdev). Consequently, once
irdma_ib_unregister_device() returns, iwdev must no longer be
dereferenced.
However, icrdma_remove() currently accesses iwdev->rf afterwards when
deinitializing interrupts, destroying ah_tbl_lock, and freeing rf.
Although the final ib_device storage is released with kfree_rcu(), the
object lifetime has already ended and callers must not rely on the RCU
grace period to continue dereferencing iwdev.
Save iwdev->rf before unregistering the RDMA device and use the saved
pointer for the remaining cleanup.
This issue was found by manual code inspection.
Fixes: 8498a30e1b94 ("RDMA/irdma: Register auxiliary driver and implement private channel OPs")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
Link: https://patch.msgid.link/20260914122840.1709743-1-lgs201920130244@gmail.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
[ adapted to 6.12.y: save the VSI number and keep filter removal order ]
Signed-off-by: Dickson Wu <dickson.wu@certik.com>
---
In 6.12.y the Gen2 remove path is irdma_remove() in main.c, and
irdma_ib_dealloc_device() already tears down interrupts and frees rf
inside the unregister, so the only use of iwdev after
irdma_ib_unregister_device() is the VSI number passed to
ice_rdma_update_vsi_filter(). Save it first. Mainline moved the filter
update before the unregister in a separate IDC refactor (c24a65b6a27c);
this keeps the 6.12.y order.
Tested on v6.12.120:
- x86_64 allmodconfig W=1 build of drivers/infiniband/hw/irdma/main.o,
base vs patched, no new warnings
- booted base and patched kernels under QEMU/KVM with ICE and irdma
built in; both registered the InfiniBand class and the auxiliary
driver. There is no ICE RDMA device in the guest, so the remove path
itself was not exercised at runtime.
The backport and the test runs were prepared with AI coding tools
(OpenAI Codex agents, with review by Claude). I went over the result
before signing off.
---
drivers/infiniband/hw/irdma/main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/irdma/main.c b/drivers/infiniband/hw/irdma/main.c
index 3f13200ff71b..7ec58c467e42 100644
--- a/drivers/infiniband/hw/irdma/main.c
+++ b/drivers/infiniband/hw/irdma/main.c
@@ -213,9 +213,10 @@ static void irdma_remove(struct auxiliary_device *aux_dev)
adev);
struct ice_pf *pf = iidc_adev->pf;
struct irdma_device *iwdev = auxiliary_get_drvdata(aux_dev);
+ u16 vsi_num = iwdev->vsi_num;
irdma_ib_unregister_device(iwdev);
- ice_rdma_update_vsi_filter(pf, iwdev->vsi_num, false);
+ ice_rdma_update_vsi_filter(pf, vsi_num, false);
pr_debug("INIT: Gen2 PF[%d] device remove success\n", PCI_FUNC(pf->pdev->devfn));
}
---
base-commit: fa3ff5a9ce6f5ada4510bda0d8b891018a0be4b7
change-id: 20261205-irdma-612-b9477db5f92f
Best regards,
--
Dickson Wu <dickson.wu@certik.com>
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 6.12.y] RDMA/irdma: avoid use-after-free in icrdma_remove
2026-12-05 20:05 ` Dickson Wu
(?)
@ 2026-12-05 20:17 ` sashiko-bot
-1 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-12-05 20:17 UTC (permalink / raw)
To: Dickson Wu; +Cc: linux-rdma
> From: Guangshuo Li <lgs201920130244@gmail.com>
>
> commit 8a8088b899e4cdfe558428cd6113d45df81625be upstream.
>
> icrdma_remove() dereferences iwdev after calling
> irdma_ib_unregister_device():
>
> irdma_ib_unregister_device(iwdev)
> -> ib_unregister_device(&iwdev->ibdev)
> -> __ib_unregister_device()
> -> ib_dealloc_device()
>
> irdma registers irdma_ib_dealloc_device() as the dealloc_driver
> callback in its ib_device_ops. The RDMA core explicitly documents
> ib_unregister_device() that when ops.dealloc_driver is used, ib_dev
> [ ... ]
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> Link: https://patch.msgid.link/20260914122840.1709743-1-lgs201920130244@gmail.com
> Signed-off-by: Leon Romanovsky <leon@kernel.org>
> [ adapted to 6.12.y: save the VSI number and keep filter removal order ]
> Signed-off-by: Dickson Wu <dickson.wu@certik.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205-irdma-612-v1-1-1be6ab2e9d8c@certik.com?part=1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-05 20:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04 13:36 FAILED: patch "[PATCH] RDMA/irdma: avoid use-after-free in icrdma_remove" failed to apply to 6.12-stable tree gregkh
2026-12-05 20:05 ` [PATCH 6.12.y] RDMA/irdma: avoid use-after-free in icrdma_remove Dickson Wu via B4 Relay
2026-12-05 20:05 ` Dickson Wu
2026-12-05 20:17 ` sashiko-bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.