patch 'common/cnxk: fix use-after-free during MACsec teardown' has been queued to stable release 24.11.9
luca.boccassi at gmail.com
luca.boccassi at gmail.com
Mon Nov 16 23:51:40 CET 2026
Hi,
FYI, your patch has been queued to stable release 24.11.9
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/18/26. So please
shout if anyone has objections.
Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.
Queued patches are on a temporary branch at:
https://github.com/bluca/dpdk-stable
This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/564e2dd4be4729dcfffc831bf1b8ec480d3933db
Thanks.
Luca Boccassi
---
>From 564e2dd4be4729dcfffc831bf1b8ec480d3933db Mon Sep 17 00:00:00 2001
From: Aarnav JP <ajp at marvell.com>
Date: Mon, 2 Nov 2026 17:51:49 +0530
Subject: [PATCH] common/cnxk: fix use-after-free during MACsec teardown
[ upstream commit 97e00631e09f46deac411676069d26bd174f5a01 ]
The idev mcs_list is walked from the mailbox interrupt thread via
roc_idev_mcs_get() and dereferenced in mcs_event_cb_process(), while
the control thread can concurrently free the mcs in roc_mcs_dev_fini().
With no lock on the list, an MCS interrupt during teardown could read
freed memory or corrupt the TAILQ mid-splice.
Add a dedicated idev mcs_lock, held across the lookup+callback in the
interrupt handler, the list insert in roc_mcs_dev_init(), and the
TAILQ_REMOVE in roc_mcs_dev_fini() (which drains any in-flight
interrupt before mcs and sa_port_map are freed). List helpers stay
lock-free to avoid recursive locking.
Fixes: f752780f30dc ("common/cnxk: add ROC MACsec initialization")
Signed-off-by: Aarnav JP <ajp at marvell.com>
---
drivers/common/cnxk/roc_dev.c | 11 +++++++++--
drivers/common/cnxk/roc_idev.c | 1 +
drivers/common/cnxk/roc_idev_priv.h | 1 +
drivers/common/cnxk/roc_mcs.c | 30 +++++++++++++++++++++--------
4 files changed, 33 insertions(+), 10 deletions(-)
diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c
index 433aca1dd3..56ffe95583 100644
--- a/drivers/common/cnxk/roc_dev.c
+++ b/drivers/common/cnxk/roc_dev.c
@@ -669,15 +669,20 @@ static int
mbox_up_handler_mcs_intr_notify(struct dev *dev, struct mcs_intr_info *info, struct msg_rsp *rsp)
{
struct roc_mcs_event_desc desc = {0};
+ struct idev_cfg *idev = idev_get_cfg();
struct roc_mcs *mcs;
plt_base_dbg("pf:%d/vf:%d msg id 0x%x (%s) from: pf:%d/vf:%d", dev_get_pf(dev->pf_func),
dev_get_vf(dev->pf_func), info->hdr.id, mbox_id2name(info->hdr.id),
dev_get_pf(info->hdr.pcifunc), dev_get_vf(info->hdr.pcifunc));
+ if (idev == NULL)
+ goto exit;
+
+ plt_spinlock_lock(&idev->mcs_lock);
mcs = roc_idev_mcs_get(info->mcs_id);
if (!mcs)
- goto exit;
+ goto unlock;
if (info->intr_mask) {
switch (info->intr_mask) {
@@ -739,12 +744,14 @@ mbox_up_handler_mcs_intr_notify(struct dev *dev, struct mcs_intr_info *info, str
desc.metadata.lmac_id = info->lmac_id;
break;
default:
- goto exit;
+ goto unlock;
}
mcs_event_cb_process(mcs, &desc);
}
+unlock:
+ plt_spinlock_unlock(&idev->mcs_lock);
exit:
rsp->hdr.rc = 0;
return 0;
diff --git a/drivers/common/cnxk/roc_idev.c b/drivers/common/cnxk/roc_idev.c
index 84812f73e0..2517a738d4 100644
--- a/drivers/common/cnxk/roc_idev.c
+++ b/drivers/common/cnxk/roc_idev.c
@@ -44,6 +44,7 @@ idev_set_defaults(struct idev_cfg *idev)
TAILQ_INIT(&idev->roc_nix_list);
plt_spinlock_init(&idev->nix_inl_dev_lock);
plt_spinlock_init(&idev->npa_dev_lock);
+ plt_spinlock_init(&idev->mcs_lock);
__atomic_store_n(&idev->npa_refcnt, 0, __ATOMIC_RELEASE);
}
diff --git a/drivers/common/cnxk/roc_idev_priv.h b/drivers/common/cnxk/roc_idev_priv.h
index 98b6286bfe..d50dee8157 100644
--- a/drivers/common/cnxk/roc_idev_priv.h
+++ b/drivers/common/cnxk/roc_idev_priv.h
@@ -44,6 +44,7 @@ struct idev_cfg {
struct idev_nix_inl_rx_inj_cfg inl_rx_inj_cfg;
plt_spinlock_t nix_inl_dev_lock;
plt_spinlock_t npa_dev_lock;
+ plt_spinlock_t mcs_lock;
uint8_t dma_cs_offset;
};
diff --git a/drivers/common/cnxk/roc_mcs.c b/drivers/common/cnxk/roc_mcs.c
index f823f7f478..1822ac30d4 100644
--- a/drivers/common/cnxk/roc_mcs.c
+++ b/drivers/common/cnxk/roc_mcs.c
@@ -818,17 +818,24 @@ struct roc_mcs *
roc_mcs_dev_init(uint8_t mcs_idx)
{
struct mcs_event_cb_list *cb_list;
+ struct idev_cfg *idev;
struct roc_mcs *mcs;
struct npa_lf *npa;
if (!(roc_feature_bphy_has_macsec() || roc_feature_nix_has_macsec()))
return NULL;
- mcs = roc_idev_mcs_get(mcs_idx);
- if (mcs) {
- plt_info("Skipping device, mcs device already probed");
- mcs->refcount++;
- return mcs;
+ idev = idev_get_cfg();
+ if (idev) {
+ plt_spinlock_lock(&idev->mcs_lock);
+ mcs = roc_idev_mcs_get(mcs_idx);
+ if (mcs) {
+ plt_info("Skipping device, mcs device already probed");
+ mcs->refcount++;
+ plt_spinlock_unlock(&idev->mcs_lock);
+ return mcs;
+ }
+ plt_spinlock_unlock(&idev->mcs_lock);
}
mcs = plt_zmalloc(sizeof(struct roc_mcs), PLT_CACHE_LINE_SIZE);
@@ -849,8 +856,11 @@ roc_mcs_dev_init(uint8_t mcs_idx)
cb_list = (struct mcs_event_cb_list *)roc_mcs_to_mcs_cb_list(mcs);
TAILQ_INIT(cb_list);
+ idev = idev_get_cfg();
+ plt_spinlock_lock(&idev->mcs_lock);
roc_idev_mcs_set(mcs);
mcs->refcount++;
+ plt_spinlock_unlock(&idev->mcs_lock);
return mcs;
exit:
@@ -861,12 +871,18 @@ exit:
void
roc_mcs_dev_fini(struct roc_mcs *mcs)
{
+ struct idev_cfg *idev = idev_get_cfg();
struct mcs_priv *priv;
int i;
+ plt_spinlock_lock(&idev->mcs_lock);
mcs->refcount--;
- if (mcs->refcount > 0)
+ if (mcs->refcount > 0) {
+ plt_spinlock_unlock(&idev->mcs_lock);
return;
+ }
+ roc_idev_mcs_free(mcs);
+ plt_spinlock_unlock(&idev->mcs_lock);
priv = roc_mcs_to_mcs_priv(mcs);
@@ -881,7 +897,5 @@ roc_mcs_dev_fini(struct roc_mcs *mcs)
plt_free(mcs->sa_port_map);
- roc_idev_mcs_free(mcs);
-
plt_free(mcs);
}
--
2.47.3
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2026-11-16 22:52:17.556804606 +0000
+++ 0026-common-cnxk-fix-use-after-free-during-MACsec-teardow.patch 2026-11-16 22:52:16.456232636 +0000
@@ -1 +1 @@
-From 97e00631e09f46deac411676069d26bd174f5a01 Mon Sep 17 00:00:00 2001
+From 564e2dd4be4729dcfffc831bf1b8ec480d3933db Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 97e00631e09f46deac411676069d26bd174f5a01 ]
+
@@ -19 +20,0 @@
-Cc: stable at dpdk.org
@@ -30 +31 @@
-index a432fb8710f..6d918bf17b3 100644
+index 433aca1dd3..56ffe95583 100644
@@ -72 +73 @@
-index 6aa5b10ee90..17b99682fdb 100644
+index 84812f73e0..2517a738d4 100644
@@ -75 +76 @@
-@@ -45,6 +45,7 @@ idev_set_defaults(struct idev_cfg *idev)
+@@ -44,6 +44,7 @@ idev_set_defaults(struct idev_cfg *idev)
@@ -84 +85 @@
-index dde555535b9..ca47f6948e0 100644
+index 98b6286bfe..d50dee8157 100644
@@ -87 +88 @@
-@@ -45,6 +45,7 @@ struct idev_cfg {
+@@ -44,6 +44,7 @@ struct idev_cfg {
@@ -96 +97 @@
-index 0ae5618c09c..1b45f5dad94 100644
+index f823f7f478..1822ac30d4 100644
@@ -99 +100 @@
-@@ -839,17 +839,24 @@ struct roc_mcs *
+@@ -818,17 +818,24 @@ struct roc_mcs *
@@ -129 +130 @@
-@@ -870,8 +877,11 @@ roc_mcs_dev_init(uint8_t mcs_idx)
+@@ -849,8 +856,11 @@ roc_mcs_dev_init(uint8_t mcs_idx)
@@ -141 +142 @@
-@@ -882,12 +892,18 @@ exit:
+@@ -861,12 +871,18 @@ exit:
@@ -161 +162 @@
-@@ -902,7 +918,5 @@ roc_mcs_dev_fini(struct roc_mcs *mcs)
+@@ -881,7 +897,5 @@ roc_mcs_dev_fini(struct roc_mcs *mcs)
More information about the stable
mailing list