From: Kees Cook <keescook@chromium.org>
To: Eric Dumazet <edumazet@google.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>,
syzbot <syzbot+a2c4601efc75848ba321@syzkaller.appspotmail.com>,
David Miller <davem@davemloft.net>, Jiri Pirko <jiri@resnulli.us>,
Jakub Kicinski <kuba@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
netdev <netdev@vger.kernel.org>, Paolo Abeni <pabeni@redhat.com>,
syzkaller-bugs <syzkaller-bugs@googlegroups.com>,
Cong Wang <xiyou.wangcong@gmail.com>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>
Subject: Re: [syzbot] WARNING in u32_change
Date: Sun, 25 Sep 2022 19:52:22 -0700 [thread overview]
Message-ID: <202209251949.D718072@keescook> (raw)
In-Reply-To: <202209251935.0469930C@keescook>
On Sun, Sep 25, 2022 at 07:39:23PM -0700, Kees Cook wrote:
> On Sun, Sep 25, 2022 at 10:34:37AM -0700, Eric Dumazet wrote:
> > Sure, please look at:
> >
> > commit 54d9469bc515dc5fcbc20eecbe19cea868b70d68
> > Author: Kees Cook <keescook@chromium.org>
> > Date: Thu Jun 24 15:39:26 2021 -0700
> >
> > fortify: Add run-time WARN for cross-field memcpy()
> > [...]
> > Here, we might switch to unsafe_memcpy() instead of memcpy()
>
> I would tend to agree. Something like:
>
> diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
> index 4d27300c287c..21e0e6206ecc 100644
> --- a/net/sched/cls_u32.c
> +++ b/net/sched/cls_u32.c
> @@ -1040,7 +1040,9 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
> }
> #endif
>
> - memcpy(&n->sel, s, sel_size);
> + unsafe_memcpy(&n->sel, s, sel_size,
> + /* A composite flex-array structure destination,
> + * which was correctly sized and allocated above. */);
> RCU_INIT_POINTER(n->ht_up, ht);
> n->handle = handle;
> n->fshift = s->hmask ? ffs(ntohl(s->hmask)) - 1 : 0;
Ah, there is another in the same source file, in u32_init_knode():
memcpy(&new->sel, s, struct_size(s, keys, s->nkeys));
(I've been trying to convince Coccinelle to produce a list of all the
composite structure targets, but I keep running into weird glitches.
That it hadn't found this one let me track down the latest issue, so now
I should be able to find more! Whew.)
--
Kees Cook
next prev parent reply other threads:[~2022-09-26 2:52 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 [this message]
2022-09-27 11:23 ` Jamal Hadi Salim
2022-09-26 10:18 ` Dan Carpenter
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=202209251949.D718072@keescook \
--to=keescook@chromium.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gustavoars@kernel.org \
--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 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).