From: Florian Westphal <fw@strlen.de>
To: Toby DiPasquale <toby@cbcg.net>
Cc: pablo@netfilter.org, Patrick McHardy <kaber@trash.net>,
kadlec@blackhole.kfki.hu, davem@davemloft.net,
netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
netdev@vger.kernel.org
Subject: Re: off-by-one in DecodeQ931
Date: Mon, 25 Apr 2016 17:29:05 +0200 [thread overview]
Message-ID: <20160425152905.GA8621@strlen.de> (raw)
In-Reply-To: <CAML0wpEBwXdzWX7g3LDJRDOVM0J7dkuhH8b+96ZhRf54+qUgwQ@mail.gmail.com>
Toby DiPasquale <toby@cbcg.net> wrote:
> I was reviewing the H.323 conntrack helper in the kernel when I came
> across what appears to be an off-by-one error in the DecodeQ931
> function. The MessageType field of the Q931 record is assigned and p
> is incremented, but the corresponding decrement to sz is missing,
> leading the sz variable to be one more than it should be. This patch
> decrements sz so it is the proper value going into the parsing of the
> information elements.
>
> Signed-off-by: Toby DiPasquale <toby@cbcg.net>
Looks correct, BUT
> diff --git a/net/netfilter/nf_conntrack_h323_asn1.c
> b/net/netfilter/nf_conntrack_h323_asn1.c
> index bcd5ed6..68b1557 100644
> --- a/net/netfilter/nf_conntrack_h323_asn1.c
> +++ b/net/netfilter/nf_conntrack_h323_asn1.c
> @@ -849,6 +849,7 @@ int DecodeQ931(unsigned char *buf, size_t sz, Q931 *q931)
> if (sz < 1)
> return H323_ERROR_BOUND;
sz can be 1
> q931->MessageType = *p++;
> + sz--;
sz is now 0
> PRINT("MessageType = %02X\n", q931->MessageType);
> if (*p & 0x80) {
> p++;
> sz--;
-> sz (size_t) will underflow here
I'd suggest to change the if (sz < 1) to if (sz < 2) to
resolve this, the while loop below has to be taken anyway.
next prev parent reply other threads:[~2016-04-25 15:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-23 17:08 [PATCH] off-by-one in DecodeQ931 Toby DiPasquale
2016-04-25 15:29 ` Florian Westphal [this message]
2016-05-03 5:12 ` Toby DiPasquale
2016-05-21 0:20 ` Toby DiPasquale
2016-06-06 13:50 ` Toby DiPasquale
2016-06-06 14:35 ` Florian Westphal
2016-06-06 14:55 ` Pablo Neira Ayuso
2016-06-12 23:29 ` Toby DiPasquale
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=20160425152905.GA8621@strlen.de \
--to=fw@strlen.de \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=kaber@trash.net \
--cc=kadlec@blackhole.kfki.hu \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=toby@cbcg.net \
/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).