From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C30EB4483B5 for ; Tue, 28 Jul 2026 16:10:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785255049; cv=none; b=h0z3vFTB/es80QwycZ4c98+qo+DtTsYrveAiCTUOyFNJRn9GPrDFrtzMS6YMzcDYw3pvXot3leYvKNExmcPduJivpCdENXXWCjIJ5BjZq5bmZ99tS5lgggAgtpdDX1rJZ/1PAwEq7BMmLCR49aNjd0SRJcGD8a7cn3ih6LroaaE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785255049; c=relaxed/simple; bh=dWK4fAPuB/wyxwKkiXMArMKCcHXRCkOu+aFaLVRNeiw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qH5COPdLNmV5tTZB6En5u8FloNN0jqR2QU2QwnrbF/oC2Ff4jA2V9BN01+1IKh+vEibnKSMpi6mDtVjUicUXY3p3asnVc1tL/ZFBxBHllqZNIbuD5TJXQnB6UE2aQdjV33g8ySJhnb8UxOr45anZAhrENqRxYPL2zQKpxTkJOgY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MqgQFEMf; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MqgQFEMf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C52FB1F000E9; Tue, 28 Jul 2026 16:10:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785255048; bh=wgFdDmlkqbqL4Px9j9phDVnuGtuz2h/y7ycbyGa5RxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MqgQFEMfpPcDFFOutACip6No5+6zAT/q+e8lFcXvk4ieDWny+k8lHekOm9CYpRBG1 FP5+1V3dqICgM9a6LnAzDNly6fv5vFGiwqmuDrjW1sMEyBOdHRC6sv42Q4rabkQsqs vAiUMQ38DfvsWMJ5nxhf0Wmce9/Bdp/tlGgDhzsBdV78z9wX2baxlmWFpjkYDN1o/O 8R4t5zEzj1BxfLjtRV4cpC2diN8IcOMFCpa09njq6Mfb8ebgGvageBGRwj5gJudhMU gpETQawQNft3XZKOT0uHeOcZpYWaOs0s3RPAxvD4s+izyBETXQ4JM5dXdo60JQ3dMV KgUgTlwnMdmEw== From: Sasha Levin To: stable@vger.kernel.org Cc: Junrui Luo , Yuhao Jiang , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6.y] octeontx2-af: cn10k: restrict VF LMTLINE sharing to its own PF Date: Tue, 28 Jul 2026 12:10:46 -0400 Message-ID: <20260728161046.36627-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026072018-anatomy-splicing-366a@gregkh> References: <2026072018-anatomy-splicing-366a@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Junrui Luo [ Upstream commit 8cdcf3d2caacdee7ddd363705fb4d93b0c1a0915 ] 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 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. Fixes: 893ae97214c3 ("octeontx2-af: cn10k: Support configurable LMTST regions") Reported-by: Yuhao Jiang Cc: stable@vger.kernel.org Signed-off-by: Junrui Luo Link: https://patch.msgid.link/SYBPR01MB78811656934E713B77DA6CEDAFE62@SYBPR01MB7881.ausprd01.prod.outlook.com Signed-off-by: Jakub Kicinski [ Dropped `rvu->pdev` argument from `rvu_get_pf()` calls and folded in the `is_pf_func_valid()` de-static plus its `rvu.h` declaration from commit 2156a29aecff. ] Signed-off-by: Sasha Levin --- drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 2 +- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 1 + drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c index 760dca4d5bfcb8..09352941ae61dd 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c @@ -440,7 +440,7 @@ struct rvu_pfvf *rvu_get_pfvf(struct rvu *rvu, int pcifunc) return &rvu->pf[rvu_get_pf(pcifunc)]; } -static bool is_pf_func_valid(struct rvu *rvu, u16 pcifunc) +bool is_pf_func_valid(struct rvu *rvu, u16 pcifunc) { int pf, vf, nvfs; u64 cfg; diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h index 11d25404d57166..f26814c4990286 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h @@ -751,6 +751,7 @@ int rvu_get_pf(u16 pcifunc); struct rvu_pfvf *rvu_get_pfvf(struct rvu *rvu, int pcifunc); void rvu_get_pf_numvfs(struct rvu *rvu, int pf, int *numvfs, int *hwvf); bool is_block_implemented(struct rvu_hwinfo *hw, int blkaddr); +bool is_pf_func_valid(struct rvu *rvu, u16 pcifunc); bool is_pffunc_map_valid(struct rvu *rvu, u16 pcifunc, int blktype); int rvu_get_lf(struct rvu *rvu, struct rvu_block *block, u16 pcifunc, u16 slot); int rvu_lf_reset(struct rvu *rvu, struct rvu_block *block, int lf); diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c index 1e4cd4f7d0cfd4..a76deef58af82c 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c @@ -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(req->hdr.pcifunc) != + rvu_get_pf(req->base_pcifunc))) + return -EPERM; + /* Calculating the LMT table index equivalent to primary * pcifunc. */ -- 2.53.0