From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Julian Anastasov <ja@ssi.bg>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH 1/2] netfilter: xt_TCPMSS: fix handling of malformed TCP header
Date: Thu, 1 Aug 2013 02:39:19 +0200 [thread overview]
Message-ID: <20130801003919.GB19777@localhost> (raw)
In-Reply-To: <alpine.LFD.2.00.1307312236050.1863@ja.ssi.bg>
Hi Julian,
On Wed, Jul 31, 2013 at 10:54:16PM +0300, Julian Anastasov wrote:
>
> Hello,
>
> On Wed, 31 Jul 2013, Pablo Neira Ayuso wrote:
>
> > Make sure the packet has enough room for the TCP header and
> > that it is not malformed.
> >
> > While at it, store tcph->doff*4 in a variable, as it is used
> > several times.
> >
> > Reported-by: Julian Anastasov <ja@ssi.bg>
> > Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> > ---
> > net/netfilter/xt_TCPMSS.c | 27 ++++++++++++++++-----------
> > 1 file changed, 16 insertions(+), 11 deletions(-)
> >
> > diff --git a/net/netfilter/xt_TCPMSS.c b/net/netfilter/xt_TCPMSS.c
> > index 7011c71..2883c1c 100644
> > --- a/net/netfilter/xt_TCPMSS.c
> > +++ b/net/netfilter/xt_TCPMSS.c
>
> > @@ -87,8 +91,8 @@ tcpmss_mangle_packet(struct sk_buff *skb,
> > newmss = info->mss;
> >
> > opt = (u_int8_t *)tcph;
> > - for (i = sizeof(struct tcphdr); i < tcph->doff*4; i += optlen(opt, i)) {
> > - if (opt[i] == TCPOPT_MSS && tcph->doff*4 - i >= TCPOLEN_MSS &&
> > + for (i = sizeof(struct tcphdr); i < tcp_hdrlen; i += optlen(opt, i)) {
>
> If we also want to avoid the wrong access in optlen()
> we have 2 options for the above line:
>
> 1. Use 'i < tcp_hdrlen - 1' or 'i <= tcp_hdrlen - 2'
>
> 2. Use 'i <= tcp_hdrlen - TCPOLEN_MSS' and remove the
> below 'tcp_hdrlen - i >= TCPOLEN_MSS' check
Indeed. I fixed the optlen issue in xt_TCPOPTSTRIP but forgot to make
it here.
Will send a new version, thanks for reviewing.
prev parent reply other threads:[~2013-08-01 0:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-31 14:10 [PATCH 1/2] netfilter: xt_TCPMSS: fix handling of malformed TCP header Pablo Neira Ayuso
2013-07-31 14:10 ` [PATCH 2/2] netfilter: xt_TCPOPTSTRIP: fix off by one access Pablo Neira Ayuso
2013-07-31 19:54 ` [PATCH 1/2] netfilter: xt_TCPMSS: fix handling of malformed TCP header Julian Anastasov
2013-08-01 0:39 ` Pablo Neira Ayuso [this message]
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=20130801003919.GB19777@localhost \
--to=pablo@netfilter.org \
--cc=ja@ssi.bg \
--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).