Skip to contentSkip to conversation

netfilter: nft_exthdr: Search chunks in SCTP packets only

PATCH Applied Phil Sutter 2 participants 2 messages Jun 11, 2021 – Jun 18, 2021

Subsystems (2)
lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH v2 1/1 netfilter: nft_exthdr: Search chunks in SCTP packets only

Since user space does not generate a payload dependency, plain sctp chunk matches cause searching in non-SCTP packets, too. Avoid this potential mis-interpretation of packet data by checking pkt->tprot.

Fixes 133dc203d77df ("netfilter: nft_exthdr: Support SCTP chunks")

---
Changes since v1:
- Drop pointless check of tprot_set value.

---
 net/netfilter/nft_exthdr.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/netfilter/nft_exthdr.c +4 -1
index 7f705b5c09de8..9cf86be2cff4b 100644
@@ -312,6 +312,9 @@ static void nft_exthdr_sctp_eval(const struct nft_expr *expr,
 	const struct sctp_chunkhdr *sch;
 	struct sctp_chunkhdr _sch;
 
+	if (pkt->tprot != IPPROTO_SCTP)
+		goto err;
+
 	do {
 		sch = skb_header_pointer(pkt->skb, offset, sizeof(_sch), &_sch);
 		if (!sch || !sch->length)
@@ -334,7 +337,7 @@ static void nft_exthdr_sctp_eval(const struct nft_expr *expr,
 		}
 		offset += SCTP_PAD4(ntohs(sch->length));
 	} while (offset < pkt->skb->len);
-
+err:
 	if (priv->flags & NFT_EXTHDR_F_PRESENT)
 		nft_reg_store8(dest, false);
 	else
Signature · 1 line
2.31.1
maintainer Applied
#1 lore raw
Quoted 3 lines · Phil Sutter

Since user space does not generate a payload dependency, plain sctp chunk matches cause searching in non-SCTP packets, too. Avoid this potential mis-interpretation of packet data by checking pkt->tprot.

Applied, thanks.