Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Alexandre Cassen
Sun, 22 Nov 2026 21:31
[PATCH net-next v3 02/11] cxgb4: flower: refuse a tunnel key wider than the VNI
Author: Alexandre Cassen
Date: Sun, 22 Nov 2026 21:31
Date: Sun, 22 Nov 2026 21:31
47 lines
10528 bytes
10528 bytes
cxgb4 holds a 24 bit VNI and truncates the key and the mask of enc_key_id.
An exact key above bit 23 already selects the wrong VNI. Flower is about
to accept partial masks. A mask that only covers bits above 23 would then
clear the VNI mask and encap_vld. The rule would match any traffic its
other keys allow. Refuse a key that no VNI can match and a mask that
leaves no VNI bit.
Found by an AI code review agent while auditing the users of enc_key_id.
Confirmed by code inspection. The wrong match was not triggered. Build
tested only.
Fixes: 98f3697f8d41 ("cxgb4: add tc flower match support for tunnel VNI")
Reviewed-by: Potnuri Bharat Teja <bharat@chelsio.com>
Signed-off-by: Alexandre Cassen <acassen@corp.free.fr>
---
.../net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
index 3307e5042681..467f055e318c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
@@ -316,6 +316,21 @@ static int cxgb4_validate_flow_match(struct netlink_ext_ack *extack,
return -EOPNOTSUPP;
}
+ if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_KEYID)) {
+ struct flow_match_enc_keyid match;
+ u32 key, mask;
+
+ flow_rule_match_enc_keyid(rule, &match);
+ key = be32_to_cpu(match.key->keyid);
+ mask = be32_to_cpu(match.mask->keyid);
+ if (key >> ENCAP_VNI_BITWIDTH ||
+ !(mask & GENMASK(ENCAP_VNI_BITWIDTH - 1, 0))) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Tunnel key does not fit the 24 bit VNI");
+ return -EOPNOTSUPP;
+ }
+ }
+
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_BASIC)) {
struct flow_match_basic match;
--
2.43.0
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads