Skip to contentSkip to conversation

octeontx2-af: npc: Warn on NPC_IPSEC_SPI key overlap

PATCH Superseded Ratheesh Kannoth 2 participants 3 messages Jul 13 – Jul 21

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ratheesh Kannoth

author maintainer
#0 lore raw

PATCH 1/1 octeontx2-af: npc: Warn on NPC_IPSEC_SPI key overlap

From: Hariprasad Kelam <[email protected]>

When scanning the MKEX profile to determine supported NPC features, warn if the SPI extraction field overlaps with other key fields. AH and ESP may legitimately use the same key offset for SPI, so continue to advertise NPC_IPSEC_SPI via npc_is_field_present() instead of treating the overlap as a hard failure.

---
 drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +3 -0
index 91b5947dae06..b217c1c19810 100644
@@ -730,6 +730,9 @@ static void npc_set_features(struct rvu *rvu, int blkaddr, u8 intf)
 			*features &= ~BIT_ULL(NPC_OUTER_VID);
 
 	/* Allow extracting SPI field from AH and ESP headers at same offset */
+	if (npc_check_overlap(rvu, blkaddr, NPC_IPSEC_SPI, 0, intf))
+		dev_warn(rvu->dev, "Overlap detected the field NPC_IPSEC_SPI\n");
+	/* Set SPI flag only if AH/ESP and IPSEC_SPI are in the key */
 	if (npc_is_field_present(rvu, NPC_IPSEC_SPI, intf) &&
 	    (*features & (BIT_ULL(NPC_IPPROTO_ESP) | BIT_ULL(NPC_IPPROTO_AH))))
 		*features |= BIT_ULL(NPC_IPSEC_SPI);
Signature · 1 line
2.43.0
reviewer
#1 lore raw

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
https://sashiko.dev/#/patchset/[email protected]?part=1
---
--- Patch [1]: [PATCH net-next] octeontx2-af: npc: Warn on NPC_IPSEC_SPI key overlap --- commit f018da26dc974202fbe56b064f0bc0375c74613a
Author: Hariprasad Kelam <[email protected]>

octeontx2-af: npc: Warn on NPC_IPSEC_SPI key overlap

When scanning the MKEX profile to determine supported NPC features, warn if the SPI extraction field overlaps with other key fields. AH and ESP may legitimately use the same key offset for SPI, so continue to advertise NPC_IPSEC_SPI via npc_is_field_present() instead of treating the overlap as a hard failure.

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c static void npc_set_features(struct rvu *rvu, int blkaddr, u8 intf) · line 734

Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +2 -0
index 91b5947dae060..b217c1c19810a 100644
@@ -730,6 +730,9 @@ static void npc_set_features(struct rvu *rvu, int blkaddr, u8 intf)
 			*features &= ~BIT_ULL(NPC_OUTER_VID);
 
 	/* Allow extracting SPI field from AH and ESP headers at same offset */
+	if (npc_check_overlap(rvu, blkaddr, NPC_IPSEC_SPI, 0, intf))
+		dev_warn(rvu->dev, "Overlap detected the field NPC_IPSEC_SPI\n");

[Severity: Medium]
The commit message notes that AH and ESP may legitimately use the same key offset for SPI. However, will this new dev_warn() trigger anyway for those valid configurations?

If an MKEX profile configures AH and ESP SPI extraction at the same offset, npc_check_overlap() will still see them as mutually exclusive fields with different lids (LID_LD and LID_LE). Does this result in spurious warnings polluting the kernel log on valid hardware configurations?

[Severity: High]
This is a pre-existing issue, but does npc_check_overlap() have a data race when called concurrently?

Looking at npc_check_overlap(), it assigns a local pointer to the shared scratchpad array and then mutates it:

rvu_npc_fs.c:npc_check_overlap() {
	...
	dummy = &mcam->rx_key_fields[NPC_UNKNOWN];
	...
	memset(dummy, 0, sizeof(struct npc_key_field));
	npc_set_layer_mdata(rvu, mcam, NPC_UNKNOWN, cfg, lid, lt, intf);
	...
}

If multiple VFs simultaneously send mailbox commands that trigger overlap checks across different CPUs, won't they overwrite this global dummy struct and corrupt each other's flow validation?

Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +1 -0
+	/* Set SPI flag only if AH/ESP and IPSEC_SPI are in the key */
 	if (npc_is_field_present(rvu, NPC_IPSEC_SPI, intf) &&
 	    (*features & (BIT_ULL(NPC_IPPROTO_ESP) | BIT_ULL(NPC_IPPROTO_AH))))
 		*features |= BIT_ULL(NPC_IPSEC_SPI);
author maintainer
#2 lore raw
Quoted 53 lines · Simon Horman

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
https://sashiko.dev/#/patchset/[email protected]?part=1
---
--- Patch [1]: [PATCH net-next] octeontx2-af: npc: Warn on NPC_IPSEC_SPI key overlap --- commit f018da26dc974202fbe56b064f0bc0375c74613a
Author: Hariprasad Kelam <[email protected]>

octeontx2-af: npc: Warn on NPC_IPSEC_SPI key overlap

When scanning the MKEX profile to determine supported NPC features, warn if the SPI extraction field overlaps with other key fields. AH and ESP may legitimately use the same key offset for SPI, so continue to advertise NPC_IPSEC_SPI via npc_is_field_present() instead of treating the overlap as a hard failure.

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c static void npc_set_features(struct rvu *rvu, int blkaddr, u8 intf) · line 734

Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +2 -0
index 91b5947dae060..b217c1c19810a 100644
@@ -730,6 +730,9 @@ static void npc_set_features(struct rvu *rvu, int blkaddr, u8 intf)
 			*features &= ~BIT_ULL(NPC_OUTER_VID);
 
 	/* Allow extracting SPI field from AH and ESP headers at same offset */
+	if (npc_check_overlap(rvu, blkaddr, NPC_IPSEC_SPI, 0, intf))
+		dev_warn(rvu->dev, "Overlap detected the field NPC_IPSEC_SPI\n");

[Severity: Medium]
The commit message notes that AH and ESP may legitimately use the same key offset for SPI. However, will this new dev_warn() trigger anyway for those valid configurations?

If an MKEX profile configures AH and ESP SPI extraction at the same offset, npc_check_overlap() will still see them as mutually exclusive fields with different lids (LID_LD and LID_LE). Does this result in spurious warnings polluting the kernel log on valid hardware configurations?

[Severity: High]
This is a pre-existing issue, but does npc_check_overlap() have a data race when called concurrently?

Looking at npc_check_overlap(), it assigns a local pointer to the shared scratchpad array and then mutates it:

rvu_npc_fs.c:npc_check_overlap() {
	...
	dummy = &mcam->rx_key_fields[NPC_UNKNOWN];
	...
	memset(dummy, 0, sizeof(struct npc_key_field));
	npc_set_layer_mdata(rvu, mcam, NPC_UNKNOWN, cfg, lid, lt, intf);
	...
}
Quoted 8 lines

If multiple VFs simultaneously send mailbox commands that trigger overlap checks across different CPUs, won't they overwrite this global dummy struct and corrupt each other's flow validation?

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c static void npc_set_features(struct rvu *rvu, int blkaddr, u8 intf) · line 738

Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +1 -0
+	/* Set SPI flag only if AH/ESP and IPSEC_SPI are in the key */
 	if (npc_is_field_present(rvu, NPC_IPSEC_SPI, intf) &&
 	    (*features & (BIT_ULL(NPC_IPPROTO_ESP) | BIT_ULL(NPC_IPPROTO_AH))))
 		*features |= BIT_ULL(NPC_IPSEC_SPI);

These comments are not valid. Let me modify the code omment so that AI reviewer wont raise this again.

pw-bot: changes-requested