netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org
Subject: [PATCH net-next 1/6] netfilter: nft_exthdr: Search chunks in SCTP packets only
Date: Wed, 23 Jun 2021 19:02:56 +0200	[thread overview]
Message-ID: <20210623170301.59973-2-pablo@netfilter.org> (raw)
In-Reply-To: <20210623170301.59973-1-pablo@netfilter.org>

From: Phil Sutter <phil@nwl.cc>

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")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nft_exthdr.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/nft_exthdr.c b/net/netfilter/nft_exthdr.c
index 7f705b5c09de..9cf86be2cff4 100644
--- a/net/netfilter/nft_exthdr.c
+++ b/net/netfilter/nft_exthdr.c
@@ -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
-- 
2.30.2


  reply	other threads:[~2021-06-23 17:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-23 17:02 [PATCH net-next 0/6] Netfilter updates for net-next Pablo Neira Ayuso
2021-06-23 17:02 ` Pablo Neira Ayuso [this message]
2021-06-23 19:40   ` [PATCH net-next 1/6] netfilter: nft_exthdr: Search chunks in SCTP packets only patchwork-bot+netdevbpf
2021-06-23 17:02 ` [PATCH net-next 2/6] netfilter: nft_extdhr: Drop pointless check of tprot_set Pablo Neira Ayuso
2021-06-23 17:02 ` [PATCH net-next 3/6] netfilter: nf_tables: add last expression Pablo Neira Ayuso
2021-06-23 17:02 ` [PATCH net-next 4/6] netfilter: conntrack: pass hook state to log functions Pablo Neira Ayuso
2021-06-23 17:03 ` [PATCH net-next 5/6] docs: networking: Update connection tracking offload sysctl parameters Pablo Neira Ayuso
2021-06-23 17:03 ` [PATCH net-next 6/6] netfilter: nfnetlink_hook: fix check for snprintf() overflow Pablo Neira Ayuso
  -- strict thread matches above, loose matches on Subject: below --
2021-06-23 17:02 [PATCH net-next 0/6] Netfilter updates for net-next Pablo Neira Ayuso
2021-06-23 17:02 ` [PATCH net-next 1/6] netfilter: nft_exthdr: Search chunks in SCTP packets only Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210623170301.59973-2-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).