All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sriram Yagnaraman <sriram.yagnaraman@est.tech>
To: netfilter-devel@vger.kernel.org
Cc: Florian Westphal <fw@strlen.de>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	Marcelo Ricardo Leitner <mleitner@redhat.com>,
	Long Xin <lxin@redhat.com>,
	Claudio Porfiri <claudio.porfiri@ericsson.com>,
	Sriram Yagnaraman <sriram.yagnaraman@est.tech>
Subject: [PATCH v3 2/4] netfilter: conntrack: fix bug in for_each_sctp_chunk
Date: Wed, 18 Jan 2023 12:38:51 +0100	[thread overview]
Message-ID: <20230118113853.8067-3-sriram.yagnaraman@est.tech> (raw)
In-Reply-To: <20230118113853.8067-1-sriram.yagnaraman@est.tech>

skb_header_pointer() will return NULL if offset + sizeof(_sch) exceeds
skb->len, so this offset < skb->len test is redundant.

if sch->length == 0, this will end up in an infinite loop, add a check
for sch->length > 0

Fixes: 9fb9cbb1082d ("[NETFILTER]: Add nf_conntrack subsystem.")
Suggested-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Sriram Yagnaraman <sriram.yagnaraman@est.tech>
---
 net/netfilter/nf_conntrack_proto_sctp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c
index 2b2c549ba678..c561c1213704 100644
--- a/net/netfilter/nf_conntrack_proto_sctp.c
+++ b/net/netfilter/nf_conntrack_proto_sctp.c
@@ -160,8 +160,8 @@ static void sctp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
 
 #define for_each_sctp_chunk(skb, sch, _sch, offset, dataoff, count)	\
 for ((offset) = (dataoff) + sizeof(struct sctphdr), (count) = 0;	\
-	(offset) < (skb)->len &&					\
-	((sch) = skb_header_pointer((skb), (offset), sizeof(_sch), &(_sch)));	\
+	((sch) = skb_header_pointer((skb), (offset), sizeof(_sch), &(_sch))) &&	\
+	(sch)->length;	\
 	(offset) += (ntohs((sch)->length) + 3) & ~3, (count)++)
 
 /* Some validity checks to make sure the chunks are fine */
-- 
2.34.1


  parent reply	other threads:[~2023-01-18 12:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-18 11:38 [PATCH v3 0/4] sctp conntrack fixes Sriram Yagnaraman
2023-01-18 11:38 ` [PATCH v3 1/4] netfilter: conntrack: fix vtag checks for ABORT/SHUTDOWN_COMPLETE Sriram Yagnaraman
2023-01-18 11:38 ` Sriram Yagnaraman [this message]
2023-01-18 11:38 ` [PATCH v3 3/4] Revert "netfilter: conntrack: add sctp DATA_SENT state" Sriram Yagnaraman
2023-01-18 11:38 ` [PATCH v3 4/4] netfilter: conntrack: unify established states for SCTP paths Sriram Yagnaraman
2023-01-18 15:28   ` Pablo Neira Ayuso
2023-01-19  8:27     ` Sriram Yagnaraman
2023-01-19 10:48       ` 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=20230118113853.8067-3-sriram.yagnaraman@est.tech \
    --to=sriram.yagnaraman@est.tech \
    --cc=claudio.porfiri@ericsson.com \
    --cc=fw@strlen.de \
    --cc=lxin@redhat.com \
    --cc=mleitner@redhat.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.