From: Jukka Rissanen <jukka.rissanen@linux.intel.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
Alexander Aring <alex.aring@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
linux-bluetooth@vger.kernel.org, linux-wpan@vger.kernel.org,
netdev@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH net] 6lowpan: Off by one handling ->nexthdr
Date: Wed, 03 Apr 2019 09:23:52 +0300 [thread overview]
Message-ID: <50a114ab56ec46ab88f7721081e1d1489fe0f369.camel@linux.intel.com> (raw)
In-Reply-To: <20190403053416.GA21913@kadam>
Hi Dan,
On Wed, 2019-04-03 at 08:34 +0300, Dan Carpenter wrote:
> NEXTHDR_MAX is 255. What happens here is that we take a u8 value
> "hdr->nexthdr" from the network and then look it up in
> lowpan_nexthdr_nhcs[]. The problem is that if hdr->nexthdr is 0xff
> then
> we read one element beyond the end of the array so the array needs to
> be one element larger.
>
> Fixes: 92aa7c65d295 ("6lowpan: add generic nhc layer interface")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> This is the only place which uses the NEXTHDR_MAX define, so I
> considered
> changing that to 256 instead. Either fix would work.
>
> net/6lowpan/nhc.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/net/6lowpan/nhc.c b/net/6lowpan/nhc.c
> index 4fa2fdda174d..9e56fb98f33c 100644
> --- a/net/6lowpan/nhc.c
> +++ b/net/6lowpan/nhc.c
> @@ -18,7 +18,7 @@
> #include "nhc.h"
>
> static struct rb_root rb_root = RB_ROOT;
> -static struct lowpan_nhc *lowpan_nexthdr_nhcs[NEXTHDR_MAX];
> +static struct lowpan_nhc *lowpan_nexthdr_nhcs[NEXTHDR_MAX + 1];
> static DEFINE_SPINLOCK(lowpan_nhc_lock);
>
> static int lowpan_nhc_insert(struct lowpan_nhc *nhc)
Nice catch!
Acked-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Cheers,
Jukka
next prev parent reply other threads:[~2019-04-03 6:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-03 5:34 [PATCH net] 6lowpan: Off by one handling ->nexthdr Dan Carpenter
2019-04-03 6:23 ` Jukka Rissanen [this message]
2019-04-08 18:16 ` Alexander Aring
2019-04-23 17:10 ` Marcel Holtmann
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=50a114ab56ec46ab88f7721081e1d1489fe0f369.camel@linux.intel.com \
--to=jukka.rissanen@linux.intel.com \
--cc=alex.aring@gmail.com \
--cc=dan.carpenter@oracle.com \
--cc=davem@davemloft.net \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=netdev@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).