All of lore.kernel.org
 help / color / mirror / Atom feed
From: "David S. Miller" <davem@davemloft.net>
To: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Cc: netfilter-devel@lists.netfilter.org, usagi-core@linux-ipv6.org
Subject: Re: [PATCH]: fixed kernel panic when trying to find tcp option
Date: Wed, 15 Sep 2004 08:43:35 -0700	[thread overview]
Message-ID: <20040915084335.6944eebe.davem@davemloft.net> (raw)
In-Reply-To: <200409151136.i8FBajor029883@toshiba.co.jp>

On Wed, 15 Sep 2004 20:36:44 +0900 (JST)
Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> wrote:

> This patch fixed panic on 2.6.9-rc2 when trying to find tcp option
> in the packet which has no option.
> 
> If not fixed yet, please apply this patch.

This patch is unnecessary, you might want to explain how
this condition can possibly occur.

All callers, well there is only one, make sure optlen is
non-zero.

Here is the call site in tcp_match():

	if (tcpinfo->option) {
		if (th->doff * 4 < sizeof(_tcph)) {
			*hotdrop = 1;
			return 0;
		}
		if (!tcp_find_option(tcpinfo->option, skb,
				     th->doff*4 - sizeof(_tcph),
				     tcpinfo->invflags & IPT_TCP_INV_OPTION,
				     hotdrop))
			return 0;
	}

If the optlen would be zero, second if() passes and we
set *hotdrop to 1 and return.

This is why tcp_find_option() uses BUG_ON(!optlen), it means
that callers must check this.

You must be changing this code or using it is some other way,
if so you must make sure you check for non-zero optlen before
invoking tcp_find_option().

  reply	other threads:[~2004-09-15 15:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-15 11:36 [PATCH]: fixed kernel panic when trying to find tcp option Yasuyuki Kozakai
2004-09-15 15:43 ` David S. Miller [this message]
2004-09-15 15:50   ` David S. Miller
2004-09-15 17:20     ` Yasuyuki Kozakai
2004-09-15 17:22       ` David S. Miller
2004-09-15 17:31       ` Yasuyuki Kozakai

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=20040915084335.6944eebe.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=netfilter-devel@lists.netfilter.org \
    --cc=usagi-core@linux-ipv6.org \
    --cc=yasuyuki.kozakai@toshiba.co.jp \
    /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.