From: Patrick McHardy <kaber@trash.net>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org, Andrew Morton <akpm@osdl.org>,
coreteam@netfilter.org, "David S. Miller" <davem@davemloft.net>,
Herbert Xu <herbert@gondor.apana.org.au>
Subject: Re: [netfilter-core] Re: [lockup] 2.6.17-rc3: netfilter/sctp: lockup in sctp_new(), do_basic_checks()
Date: Tue, 02 May 2006 16:29:41 +0200 [thread overview]
Message-ID: <44576CD5.60603@trash.net> (raw)
In-Reply-To: <20060502141621.GA32284@elte.hu>
[-- Attachment #1: Type: text/plain, Size: 1503 bytes --]
Ingo Molnar wrote:
> * Patrick McHardy <kaber@trash.net> wrote:
>
>
>>I did a couple of minutes ago. Here it is again in case my last mail
>>won't show up.
>
>
>>- (sch = skb_header_pointer(skb, offset, sizeof(_sch), &_sch)); \
>>- offset += (htons(sch->length) + 3) & ~3, count++)
>>+ (sch = skb_header_pointer(skb, offset, sizeof(_sch), &_sch)) && \
>>+ sch->length; offset += (htons(sch->length) + 3) & ~3, count++)
>
>
> but this makes do_basic_checks() not fail, and the clearly bogus packet
> is passed further down. The reason i have put it inside the loop is to
> be able to return 1 for the early checks. How about the fix below? It
> should be cleaner and it will also return 1 if the initial offset is
> oversized.
Right, that is better.
> Index: linux/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
> ===================================================================
> --- linux.orig/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
> +++ linux/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
> @@ -224,6 +224,13 @@ static int do_basic_checks(struct ip_con
> DEBUGP(__FUNCTION__);
> DEBUGP("\n");
>
> + /*
> + * Dont trust the initial offset:
> + */
> + offset = skb->nh.iph->ihl * 4 + sizeof(sctp_sctphdr_t);
> + if (offset >= skb->len)
> + return 1;
> +
That part is unnecessary, the presence of one sctp_sctphdr_t
has already been verified by skb_header_pointer() in sctp_new().
How about this patch (based on your patch, but typos fixed and
also covers nf_conntrack)?
[-- Attachment #2: x --]
[-- Type: text/plain, Size: 2524 bytes --]
[NETFILTER]: SCTP conntrack: fix infinite loop
fix infinite loop in the SCTP-netfilter code: check SCTP chunk size to
guarantee progress of for_each_sctp_chunk(). (all other uses of
for_each_sctp_chunk() are preceded by do_basic_checks(), so this fix
should be complete.)
Based on patch from Ingo Molnar <mingo@elte.hu>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit c14803e9e8446122312523a6b6959e7312379b2e
tree 651d4f6f1cd07703d3ec6b9367c441312e969e9e
parent 462f3ddd384045c731b3268a1b9c91c834a5a68a
author Patrick McHardy <kaber@trash.net> Tue, 02 May 2006 16:28:26 +0200
committer Patrick McHardy <kaber@trash.net> Tue, 02 May 2006 16:28:26 +0200
net/ipv4/netfilter/ip_conntrack_proto_sctp.c | 11 +++++++----
net/netfilter/nf_conntrack_proto_sctp.c | 11 +++++++----
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_sctp.c b/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
index 5259abd..a563534 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
@@ -235,12 +235,15 @@ static int do_basic_checks(struct ip_con
flag = 1;
}
- /* Cookie Ack/Echo chunks not the first OR
- Init / Init Ack / Shutdown compl chunks not the only chunks */
- if ((sch->type == SCTP_CID_COOKIE_ACK
+ /*
+ * Cookie Ack/Echo chunks not the first OR
+ * Init / Init Ack / Shutdown compl chunks not the only chunks
+ * OR zero-length.
+ */
+ if (((sch->type == SCTP_CID_COOKIE_ACK
|| sch->type == SCTP_CID_COOKIE_ECHO
|| flag)
- && count !=0 ) {
+ && count !=0) || !sch->length) {
DEBUGP("Basic checks failed\n");
return 1;
}
diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c
index 9cccc32..730f5d6 100644
--- a/net/netfilter/nf_conntrack_proto_sctp.c
+++ b/net/netfilter/nf_conntrack_proto_sctp.c
@@ -240,12 +240,15 @@ static int do_basic_checks(struct nf_con
flag = 1;
}
- /* Cookie Ack/Echo chunks not the first OR
- Init / Init Ack / Shutdown compl chunks not the only chunks */
- if ((sch->type == SCTP_CID_COOKIE_ACK
+ /*
+ * Cookie Ack/Echo chunks not the first OR
+ * Init / Init Ack / Shutdown compl chunks not the only chunks
+ * OR zero-length.
+ */
+ if (((sch->type == SCTP_CID_COOKIE_ACK
|| sch->type == SCTP_CID_COOKIE_ECHO
|| flag)
- && count !=0 ) {
+ && count !=0) || !sch->length) {
DEBUGP("Basic checks failed\n");
return 1;
}
next prev parent reply other threads:[~2006-05-02 14:29 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-02 11:34 [lockup] 2.6.17-rc3: netfilter/sctp: lockup in sctp_new(), do_basic_checks() Ingo Molnar
2006-05-02 13:40 ` Ingo Molnar
2006-05-02 13:45 ` Ingo Molnar
2006-05-02 13:54 ` [netfilter-core] " Patrick McHardy
2006-05-02 14:01 ` Ingo Molnar
2006-05-02 13:57 ` Patrick McHardy
2006-05-02 14:16 ` Ingo Molnar
2006-05-02 14:24 ` Ingo Molnar
2006-05-02 14:29 ` Patrick McHardy [this message]
2006-05-02 14:38 ` Ingo Molnar
2006-05-02 14:35 ` Patrick McHardy
2006-05-02 14:42 ` Ingo Molnar
2006-05-02 14:40 ` Patrick McHardy
2006-05-02 13:45 ` [netfilter-core] " Patrick McHardy
2006-05-02 15:34 ` Marcel Holtmann
2006-05-02 15:55 ` [netfilter-core] " Patrick McHardy
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=44576CD5.60603@trash.net \
--to=kaber@trash.net \
--cc=akpm@osdl.org \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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