octeontx2-af: cn10k: restrict LMTLINE sharing to same PF
PATCH 1/1 octeontx2-af: cn10k: restrict LMTLINE sharing to same PF
rvu_mbox_handler_lmtst_tbl_setup() uses req->base_pcifunc as a direct index into the LMT map table to read another function's LMTLINE physical base address and copy it into the caller's own LMT map table entry. The mailbox dispatcher authenticates req->hdr.pcifunc from the IRQ source, but req->base_pcifunc is a separate payload field and is not sanitized.
Reject the request with -EPERM when the caller and base function do not share a parent PF.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c +7 -0
@@ -178,6 +178,13 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu,* pcifunc (will be the one who is calling this mailbox). */ if (req->base_pcifunc) { +/* Only allow LMTLINE sharing within the same PF, so that a +* PCI function cannot hijack another PF's LMTLINE region. +*/ +if (rvu_get_pf (rvu->pdev, req->hdr.pcifunc) != +rvu_get_pf (rvu->pdev, req->base_pcifunc)) +return -EPERM ; +/* Calculating the LMT table index equivalent to primary * pcifunc. */
---
base-commit: c369299895a591d96745d6492d4888259b004a9e
change-id: 20260524-fixes-33bb6d8cccf8
Best regards,
Signature · 1 line
Junrui Luo <[email protected]>
Jakub Kicinski
maintainerQuoted 1 line · On Sun, 24 May 2026 15:29:29 +0800 Junrui Luo wrote:
Reported-by Yuhao Jiang <[email protected]>
Really? I thought I saw this reported in Sashiko..
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/[email protected]
Either way, Marvell folks - please review.
Hi Jakub,
I worked with Junrui on discovering this bug and preparing the patch. I found the bug and reported it to Junrui, and he helped write the patch. There may be some overlap with other work.
Thanks.
Quoted 9 lines · Jakub Kicinski
Quoted 1 line · On Sun, 24 May 2026 15:29:29 +0800 Junrui Luo wrote:
Reported-by Yuhao Jiang <[email protected]>Really? I thought I saw this reported in Sashiko..
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/[email protected]
Either way, Marvell folks - please review.
Signature · 1 line
Yuhao Jiang
Jakub Kicinski
maintainerQuoted 5 lines · On Tue, 26 May 2026 20:46:46 -0500 Yuhao Jiang wrote:
Hi Jakub,
I worked with Junrui on discovering this bug and preparing the patch. I found the bug and reported it to Junrui, and he helped write the patch. There may be some overlap with other work.
Please don't top post on the list.
Junrui, please describe your discovery process.
Quoted 10 lines · Jakub Kicinski
Quoted 9 lines · On Sun, 24 May 2026 15:29:29 +0800 Junrui Luo wrote:
Quoted 1 line
Reported-by Yuhao Jiang <[email protected]>Really? I thought I saw this reported in Sashiko..
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/[email protected]
Either way, Marvell folks - please review.
Quoted 1 line · Jakub Kicinski
Junrui, please describe your discovery process.
Hi Jakub,
Yuhao forwarded the report to me, and I investigated the issue and wrote the patch. Sorry for missing the earlier report on Sashiko, and thanks for the link.
Thanks,
Junrui Luo
Geethasowjanya Akula
maintainerQuoted 36 lines
-----Original Message-----
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, May 27, 2026 7:22 AM
To: Yuhao Jiang <[email protected]>
Cc: Junrui Luo <[email protected]>; Sunil Kovvuri Goutham <[email protected]>; Linu Cherian <[email protected]>; Geethasowjanya Akula <[email protected]>; Hariprasad Kelam <[email protected]>; Subbaraya Sundeep Bhatta <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Paolo Abeni <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Subject: [EXTERNAL] Re: [PATCH net] octeontx2-af: cn10k: restrict LMTLINE sharing to same PFQuoted 5 lines · On Tue, 26 May 2026 20:46:46 -0500 Yuhao Jiang wrote:
Hi Jakub,
I worked with Junrui on discovering this bug and preparing the patch. I found the bug and reported it to Junrui, and he helped write the patch. There may be some overlap with other work.
Please don't top post on the list.
Junrui, please describe your discovery process.
Quoted 9 lines · Jakub Kicinski
Quoted 8 lines · On Sun, 24 May 2026 15:29:29 +0800 Junrui Luo wrote:
Quoted 1 line
Reported-by Yuhao Jiang <[email protected]>Really? I thought I saw this reported in Sashiko..
https://urldefense.proofpoint.com/v2/url?u=https-3A__netdev-2Dai.bot
s.linux.dev_sashiko_-23_patchset_20260520154157.1439319-2D1-
Quoted 11 lines
2Dmichae
Quoted 1 line
Quoted 1 line
l.bommarito-
40gmail.com&d=DwIFaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=UiEt_nUe
Quoted 1 line
Quoted 1 line
YFctu7JVLXVlXDhTmq_EAfooaZEYInfGuEQ&m=ESyWUuC7cOhVRmobPkCa2wZp UJil1G
Quoted 1 line
Quoted 1 line
km_eJqp-iBzx2soczScJlUupDstoIztUIo&s=J8p73boIdnnkY-
tzhEXMXXE6W0qp5sC
Quoted 3 lines
Quoted 3 lines
HAZFQ0FjEugE&e=
Either way, Marvell folks - please review.
Hi Junrui and Jakub,
This patch enforces that the requester’s pcifunc and req->base_pcifunc belong to the same PF. However, this assumption is not always valid.
We have valid use cases where LMTST lines are intentionally shared across multiple PFs. In such scenarios, the base_pcifunc may legitimately belong to a different PF, and restricting access to the same PF would break these existing use cases.
Quoted 7 lines · Geethasowjanya Akula
Hi Junrui and Jakub,
This patch enforces that the requester’s pcifunc and
req->base_pcifuncbelong to the same PF. However, this assumption is not always valid.
We have valid use cases where LMTST lines are intentionally shared across multiple PFs. In such scenarios, thebase_pcifuncmay legitimately belong to a different PF, and restricting access to the same PF would break these existing use cases.
Thanks for the review. To preserve cross-PF sharing while still restricting VF callers, would the check below match your expectation?
if (is_vf(req->hdr.pcifunc) && rvu_get_pf(rvu->pdev, req->hdr.pcifunc) != rvu_get_pf(rvu->pdev, req->base_pcifunc)) return -EPERM;
Thanks,
Junrui Luo
Geethasowjanya Akula
maintainerQuoted 26 lines
-----Original Message-----
From: Junrui Luo <[email protected]>
Sent: Thursday, May 28, 2026 9:58 PM
To: Geethasowjanya Akula <[email protected]>
Cc: Jakub Kicinski <[email protected]>; Yuhao Jiang <[email protected]>; Sunil Kovvuri Goutham <[email protected]>; Linu Cherian <[email protected]>; Hariprasad Kelam <[email protected]>; Subbaraya Sundeep Bhatta <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Paolo Abeni <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [EXTERNAL] [PATCH net] octeontx2-af: cn10k: restrict LMTLINE sharing to same PFQuoted 3 lines · Geethasowjanya Akula
Hi Junrui and Jakub,
This patch enforces that the requester’s pcifunc and
req->base_pcifuncbelong to the same PF.
Quoted 4 lines
However, this assumption is not always valid.
We have valid use cases where LMTST lines are intentionally shared across multiple PFs. In such scenarios, thebase_pcifuncmay legitimately belong to a different PF, and restricting access to the same PFwould break these existing use cases.
Quoted 7 lines
Thanks for the review. To preserve cross-PF sharing while still restricting VF callers, would the check below match your expectation?
if (is_vf(req->hdr.pcifunc) && rvu_get_pf(rvu->pdev, req->hdr.pcifunc) != rvu_get_pf(rvu->pdev, req->base_pcifunc)) return -EPERM;
Hi Junrui,
Thanks for the update,
Restricting only VF callers from accessing LMTLINEs across PF boundaries makes sense from a security standpoint. The changes aligns with our expectations.
LGTM.
Geetha.
Quoted 3 lines
Thanks,
Junrui Luo
PATCH v2 1/1 octeontx2-af: cn10k: restrict VF LMTLINE sharing to its own PF
In reply to Junrui Luorvu_mbox_handler_lmtst_tbl_setup() uses req->base_pcifunc as a direct index into the LMT map table to read another function's LMTLINE physical base address and copy it into the caller's own LMT map table entry. The mailbox dispatcher authenticates req->hdr.pcifunc from the IRQ source, but req->base_pcifunc is a separate payload field and is not sanitized.
Reject with -EPERM when a VF caller and the base function do not share a parent PF. PF callers are trusted and may still share LMTLINEs across PFs.
---
Changes in v2:
- Restrict the check to VF callers only. PF callers are trusted and may
still share LMTLINEs across PFs.
- Link to v1: https://lore.kernel.org/r/SYBPR01MB7881F8D11D2930BB84215253AF0D2@SYBPR01MB7881.ausprd01.prod.outlook.com
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c +8 -0
@@ -178,6 +178,14 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu,* pcifunc (will be the one who is calling this mailbox). */ if (req->base_pcifunc) { +/* A VF is untrusted and must not redirect its LMTLINE to +* another PF's region, so confine VF callers to their own PF. +*/ +if (is_vf (req->hdr.pcifunc) && +rvu_get_pf (rvu->pdev, req->hdr.pcifunc) != +rvu_get_pf (rvu->pdev, req->base_pcifunc)) +return -EPERM ; +/* Calculating the LMT table index equivalent to primary * pcifunc. */
---
base-commit: c369299895a591d96745d6492d4888259b004a9e
change-id: 20260601-fixes-a06620632bac
Best regards,
Signature · 1 line
Junrui Luo <[email protected]>
RE: [EXTERNAL] [PATCH net v2] octeontx2-af: cn10k: restrict VF LMTLINE sharing to its own PF
Quoted 67 lines
-----Original Message-----
From: Junrui Luo <[email protected]>
Sent: Monday, June 1, 2026 11:25 AM
To: Sunil Kovvuri Goutham <[email protected]>; Linu Cherian <[email protected]>; Geethasowjanya Akula <[email protected]>; Hariprasad Kelam <[email protected]>; Subbaraya Sundeep Bhatta <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>
Cc: [email protected]; [email protected]; Yuhao Jiang <[email protected]>; [email protected]; Junrui Luo <[email protected]>
Subject: [EXTERNAL] [PATCH net v2] octeontx2-af: cn10k: restrict VF LMTLINE sharing to its own PFrvu_mbox_handler_lmtst_tbl_setup()usesreq->base_pcifuncas a direct index into the LMT map table to read another function's LMTLINE physical base address and copy it into the caller's own LMT map table entry. The mailbox dispatcher authenticatesreq->hdr.pcifuncfrom the IRQ source, butreq->base_pcifuncis a separate payload field and is not sanitized.Reject with
-EPERMwhen a VF caller and the base function do not share a parent PF. PF callers are trusted and may still share LMTLINEs across PFs.Fixes 893ae97214c3 ("octeontx2-af: cn10k: Support configurable LMTSTregions")
Reported-by Yuhao Jiang <[email protected]>Signed-off-by Junrui Luo <[email protected]>---
Changes in v2:
- Restrict the check to VF callers only. PF callers are trusted and may still share LMTLINEs across PFs.
- Link to v1: https://urldefense.proofpoint.com/v2/url?u=https-
3A__lore.kernel.org_r_SYBPR01MB7881F8D11D2930BB84215253AF0D2- 40SYBPR01MB7881.ausprd01.prod.outlook.com&d=DwICaQ&c=nKjWec2b6R0m OyPaz7xtfQ&r=UiEt_nUeYFctu7JVLXVlXDhTmq_EAfooaZEYInfGuEQ&m=xuYymVG Ze1qq-oeBKE-_xOE_HuutAdE4D- lF9ezsL5AvB8RYG06YF9gySBv8fXhy&s=DKDPlH9M4tsGPjYPWOjPXQTKFR_spOogL CfJW1rIagI&e=
---drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c| 8 ++++++++1 file changed, 8 insertions(+)drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c +8
-0@@ -178,6 +178,14 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu*rvu, * pcifunc (will be the one who is calling this mailbox). */ if (req->base_pcifunc) { +/* A VF is untrusted and must not redirect its LMTLINE to +* another PF's region, so confine VF callers to their own PF. +*/ +if (is_vf (req->hdr.pcifunc) && +rvu_get_pf (rvu->pdev, req->hdr.pcifunc) != +rvu_get_pf (rvu->pdev, req->base_pcifunc)) +return -EPERM ; +/* Calculating the LMT table index equivalent to primary * pcifunc. */
Quoted 7 lines
---
base-commit:c369299895a591d96745d6492d4888259b004a9e
change-id: 20260601-fixes-a06620632bacBest regards,
--
Junrui Luo <[email protected]>
Paolo Abeni
maintainerRe: [PATCH net v2] octeontx2-af: cn10k: restrict VF LMTLINE sharing to its own PF
In reply to Junrui LuoThis is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
---
octeontx2-af: cn10k: restrict VF LMTLINE sharing to its own PF
This patch tries to plug a privilege boundary in the LMTLINE setup mailbox by rejecting -EPERM when a VF caller's parent PF differs from the parent PF of req->base_pcifunc. It carries Fixes: 893ae97214c3 and Cc: [email protected].
Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c +0
-0@@ -178,6 +178,14 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu,* pcifunc (will be the one who is calling this mailbox).
drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu, · line 188
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c +8
-0*/ if (req->base_pcifunc) { +/* A VF is untrusted and must not redirect its LMTLINE to +* another PF's region, so confine VF callers to their own PF. +*/ +if (is_vf (req->hdr.pcifunc) && +rvu_get_pf (rvu->pdev, req->hdr.pcifunc) != +rvu_get_pf (rvu->pdev, req->base_pcifunc)) +return -EPERM ; +
[Critical]
Can this check still be bypassed via the FUNC bits of base_pcifunc?
rvu_get_pf() only inspects the upper PF bits of the pcifunc (shift 10 on OTX2, shift 9 on CN20K), but RVU_PFVF_FUNC_MASK is 0x3FF, so the FUNC field a VF can set in req->base_pcifunc spans 0..1023:
static inline int rvu_get_pf(struct pci_dev *pdev, u16 pcifunc)
{
if (is_cn20k(pdev))
return (pcifunc >> RVU_CN20K_PFVF_PF_SHIFT) &
RVU_CN20K_PFVF_PF_MASK;
else
return (pcifunc >> RVU_OTX2_PFVF_PF_SHIFT) &
RVU_OTX2_PFVF_PF_MASK;
}After the new check passes, base_pcifunc is fed straight into rvu_get_lmtst_tbl_index(), where the index is computed from the full FUNC field and LMT_MAX_VFS = 256:
#define LMT_MAX_VFS 256
static u32 rvu_get_lmtst_tbl_index(struct rvu *rvu, u16 pcifunc)
{
return ((rvu_get_pf(rvu->pdev, pcifunc) * LMT_MAX_VFS) +
(pcifunc & RVU_PFVF_FUNC_MASK)) * LMT_MAPTBL_ENTRY_SIZE;
}So a FUNC value >= 256 wraps into the next PF's slot range. Worked example on OTX2: a VF on PF=0 (req->hdr.pcifunc = 0x0001) sets req->base_pcifunc = 0x012C (300). is_vf() is true, and rvu_get_pf(0x012C) = (300 >> 10) & PF_MASK = 0, equal to the caller's PF, so the new -EPERM path is not taken.
rvu_get_lmtst_tbl_index() then yields (0 * 256 + 300) * 16 = 4800, which is the slot for PF=1 FUNC=44 (1 * 256 + 44 = 300).
pri_tbl_idx = rvu_get_lmtst_tbl_index(rvu, req->base_pcifunc); err = lmtst_map_table_ops(rvu, pri_tbl_idx, &val, LMT_TBL_OP_READ); ... err = rvu_update_lmtaddr(rvu, req->hdr.pcifunc, val);
That reads PF=1's physical LMT base address and copies it into the attacker VF's own LMT map entry, which is the cross-PF redirection the patch is intended to prevent.
The same wrap is reachable on CN20K, e.g. base_pcifunc = 511 lands in PF=1 FUNC=255's slot since PF_SHIFT is 9 there.
Would it make sense to also reject base_pcifunc whose FUNC field is out of range, for example by additionally requiring (req->base_pcifunc & RVU_PFVF_FUNC_MASK) < LMT_MAX_VFS, or by looking base_pcifunc up via rvu_get_pfvf() / is_pffunc_map_valid() and confirming it is a real attached function under the same parent PF?
PATCH v3 1/1 octeontx2-af: cn10k: restrict VF LMTLINE sharing to its own PF
In reply to Junrui Luorvu_mbox_handler_lmtst_tbl_setup() uses req->base_pcifunc as a direct index into the LMT map table to read another function's LMTLINE physical base address and copy it into the caller's own LMT map table entry. The mailbox dispatcher authenticates req->hdr.pcifunc from the IRQ source, but req->base_pcifunc is a separate payload field and is not sanitized.
Reject the request with -EPERM when a VF caller's base_pcifunc is not a valid function under its own PF. is_pf_func_valid() bounds the FUNC field to the PF's configured VF count, keeping the computed index inside the caller's own slot block.
---
Changes in v3:
- Validate base_pcifunc with is_pf_func_valid() in addition to the same-PF
check: it bounds the FUNC field to the PF's configured VF count and
rejects non-existent functions, closing the wrap. Thanks to the AI
review forwarded by Paolo Abeni for spotting this.
- Link to v2: https://lore.kernel.org/all/SYBPR01MB788101745A9E36F6FD81CD7AAF152@SYBPR01MB7881.ausprd01.prod.outlook.com
Changes in v2:
- Restrict the check to VF callers only. PF callers are trusted and may
still share LMTLINEs across PFs.
- Link to v1: https://lore.kernel.org/r/SYBPR01MB7881F8D11D2930BB84215253AF0D2@SYBPR01MB7881.ausprd01.prod.outlook.com
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c +9 -0
@@ -178,6 +178,15 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu,* pcifunc (will be the one who is calling this mailbox). */ if (req->base_pcifunc) { +/* A VF is untrusted and must not redirect its LMTLINE to +* another PF's region, so confine VF callers to their own PF. +*/ +if (is_vf (req->hdr.pcifunc) && + (!is_pf_func_valid (rvu, req->base_pcifunc) || +rvu_get_pf (rvu->pdev, req->hdr.pcifunc) != +rvu_get_pf (rvu->pdev, req->base_pcifunc))) +return -EPERM ; +/* Calculating the LMT table index equivalent to primary * pcifunc. */
---
base-commit: 9716c086c8e8b141d35aa61f2e96a2e83de212a7
change-id: 20260615-fixes-239a59dc6012
Best regards,
Signature · 1 line
Junrui Luo <[email protected]>
Re: [PATCH net v3] octeontx2-af: cn10k: restrict VF LMTLINE sharing to its own PF
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Mon, 15 Jun 2026 23:04:27 +0800 you wrote:
rvu_mbox_handler_lmtst_tbl_setup()usesreq->base_pcifuncas a direct index into the LMT map table to read another function's LMTLINE physical base address and copy it into the caller's own LMT map table entry. The mailbox dispatcher authenticatesreq->hdr.pcifuncfrom the IRQ source, butreq->base_pcifuncis a separate payload field and is not sanitized.[...]
Here is the summary with links:
- [net,v3] octeontx2-af: cn10k: restrict VF LMTLINE sharing to its own PF
https://git.kernel.org/netdev/net/c/8cdcf3d2caac
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html