From: Eric Dumazet <eric.dumazet@gmail.com>
To: Alexander Aring <aring@mojatatu.com>, stefan@osg.samsung.com
Cc: linux-wpan@vger.kernel.org, kernel@mojatatu.com
Subject: Re: [PATCH wpan] net: ieee802154: 6lowpan: fix frag reassembly
Date: Mon, 23 Apr 2018 17:11:39 -0700 [thread overview]
Message-ID: <da1db914-bf92-ac44-9f60-5e5dfbc59b94@gmail.com> (raw)
In-Reply-To: <20180420185413.8818-1-aring@mojatatu.com>
On 04/20/2018 11:54 AM, Alexander Aring wrote:
> This patch initialize stack variables which are used in
> frag_lowpan_compare_key to zero. In my case there are padding bytes in the
> structures ieee802154_addr as well in frag_lowpan_compare_key. Otherwise
> the key variable contains random bytes. The result is that a compare of
> two keys by memcmp works incorrect.
>
> Fixes: 648700f76b03 ("inet: frags: use rhashtables for reassembly units")
> Signed-off-by: Alexander Aring <aring@mojatatu.com>
> Reported-by: Stefan Schmidt <stefan@osg.samsung.com>
> ---
> So far I see it's a case of 32 alignment in frag_v4_compare_key and
> frag_v6_compare_key and I am not sure about if this works on all arch
> correctly.
>
> net/ieee802154/6lowpan/6lowpan_i.h | 4 ++--
> net/ieee802154/6lowpan/reassembly.c | 14 +++++++-------
> 2 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/net/ieee802154/6lowpan/6lowpan_i.h b/net/ieee802154/6lowpan/6lowpan_i.h
> index b8d95cb71c25..44a7e16bf3b5 100644
> --- a/net/ieee802154/6lowpan/6lowpan_i.h
> +++ b/net/ieee802154/6lowpan/6lowpan_i.h
> @@ -20,8 +20,8 @@ typedef unsigned __bitwise lowpan_rx_result;
> struct frag_lowpan_compare_key {
> u16 tag;
> u16 d_size;
> - const struct ieee802154_addr src;
> - const struct ieee802154_addr dst;
> + struct ieee802154_addr src;
> + struct ieee802154_addr dst;
> };
>
> /* Equivalent of ipv4 struct ipq
> diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c
> index 1790b65944b3..2cc224106b69 100644
> --- a/net/ieee802154/6lowpan/reassembly.c
> +++ b/net/ieee802154/6lowpan/reassembly.c
> @@ -75,14 +75,14 @@ fq_find(struct net *net, const struct lowpan_802154_cb *cb,
> {
> struct netns_ieee802154_lowpan *ieee802154_lowpan =
> net_ieee802154_lowpan(net);
> - struct frag_lowpan_compare_key key = {
> - .tag = cb->d_tag,
> - .d_size = cb->d_size,
> - .src = *src,
> - .dst = *dst,
> - };
> + struct frag_lowpan_compare_key key = {};
> struct inet_frag_queue *q;
>
> + key.tag = cb->d_tag;
> + key.d_size = cb->d_size;
> + key.src = *src;
> + key.dst = *dst;
> +
> q = inet_frag_find(&ieee802154_lowpan->frags, &key);
> if (!q)
> return NULL;
> @@ -372,7 +372,7 @@ int lowpan_frag_rcv(struct sk_buff *skb, u8 frag_type)
> struct lowpan_frag_queue *fq;
> struct net *net = dev_net(skb->dev);
> struct lowpan_802154_cb *cb = lowpan_802154_cb(skb);
> - struct ieee802154_hdr hdr;
> + struct ieee802154_hdr hdr = {};
> int err;
>
> if (ieee802154_hdr_peek_addrs(skb, &hdr) < 0)
>
Hi Alexander.
Thanks for working on this !
It looks like only the last chunk was really needed to fix this bug, right ?
Compiler should really init everything, and not leave garbage bytes in :
struct frag_lowpan_compare_key key = {
.tag = cb->d_tag,
.d_size = cb->d_size,
.src = *src,
.dst = *dst,
};
next prev parent reply other threads:[~2018-04-24 0:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-20 18:54 [PATCH wpan] net: ieee802154: 6lowpan: fix frag reassembly Alexander Aring
2018-04-20 21:07 ` Stefan Schmidt
2018-04-23 19:07 ` Stefan Schmidt
2018-04-24 0:11 ` Eric Dumazet [this message]
2018-04-25 21:19 ` Alexander Aring
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=da1db914-bf92-ac44-9f60-5e5dfbc59b94@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=aring@mojatatu.com \
--cc=kernel@mojatatu.com \
--cc=linux-wpan@vger.kernel.org \
--cc=stefan@osg.samsung.com \
/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