All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: syzbot <syzbot+a2c4601efc75848ba321@syzkaller.appspotmail.com>,
	davem@davemloft.net, edumazet@google.com, jiri@resnulli.us,
	kuba@kernel.org, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, pabeni@redhat.com,
	syzkaller-bugs@googlegroups.com, xiyou.wangcong@gmail.com
Subject: Re: [syzbot] WARNING in u32_change
Date: Mon, 26 Sep 2022 13:18:25 +0300	[thread overview]
Message-ID: <YzF8cdiKQKG9l73k@kadam> (raw)
In-Reply-To: <CAM0EoMm9uBQQepMb5bda1vR-Okw-tPp2nnf6TvfA0FzPu_D_2A@mail.gmail.com>

On Sun, Sep 25, 2022 at 12:14:44PM -0400, Jamal Hadi Salim wrote:
> On Sun, Sep 25, 2022 at 11:38 AM Jamal Hadi Salim <jhs@mojatatu.com> wrote:
> >
> > Is there a way to tell the boat "looking into it?"
> 
> 
> I guess I have to swim across to it to get the message;->
> 
> I couldnt see the warning message  but it is obvious by inspection that
> the memcpy is broken. We should add more test coverage.
> This should fix it. Will send a formal patch later:
> 
> diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
> index 4d27300c2..591cbbf27 100644
> --- a/net/sched/cls_u32.c
> +++ b/net/sched/cls_u32.c
> @@ -1019,7 +1019,7 @@ static int u32_change(struct net *net, struct
> sk_buff *in_skb,
>         }
> 
>         s = nla_data(tb[TCA_U32_SEL]);
> -       sel_size = struct_size(s, keys, s->nkeys);
> +       sel_size = struct_size(s, keys, s->nkeys) + sizeof(n->sel);

Smatch will soon start complaining about these.  Can we instead do:

	sel_size = size_add(struct_size(s, keys, s->nkeys), sizeof(n->sel));

Probably eventually Smatch will be able to detect some times when
struct_size() is used for readability and not for safety so maybe it
won't warn...

regards,
dan carpenter

  parent reply	other threads:[~2022-09-26 10:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-25 11:50 [syzbot] WARNING in u32_change syzbot
2022-09-25 15:38 ` Jamal Hadi Salim
2022-09-25 16:14   ` Jamal Hadi Salim
2022-09-25 16:28     ` Eric Dumazet
2022-09-25 17:08       ` Jamal Hadi Salim
2022-09-25 17:13         ` Jamal Hadi Salim
2022-09-25 17:34           ` Eric Dumazet
2022-09-26  2:39             ` Kees Cook
2022-09-26  2:52               ` Kees Cook
2022-09-27 11:23               ` Jamal Hadi Salim
2022-09-26 10:18     ` Dan Carpenter [this message]
2022-10-06  7:55   ` Dmitry Vyukov

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=YzF8cdiKQKG9l73k@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=syzbot+a2c4601efc75848ba321@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=xiyou.wangcong@gmail.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 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.