From: Andrey Ignatov <rdna@fb.com>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
"David S. Miller" <davem@davemloft.net>,
"Network Development" <netdev@vger.kernel.org>
Subject: Re: [PATCH 8/9] bpf: Check address length before reading address family
Date: Fri, 12 Apr 2019 16:51:14 +0000 [thread overview]
Message-ID: <20190412165112.GB28199@rdna-mbp> (raw)
In-Reply-To: <CAADnVQLh+fJciux3bMSure6fmw_krQ6OVeJzwhf3JEeOb4kYFQ@mail.gmail.com>
Alexei Starovoitov <alexei.starovoitov@gmail.com> [Fri, 2019-04-12 09:20 -0700]:
> On Fri, Apr 12, 2019 at 3:56 AM Tetsuo Handa
> <penguin-kernel@i-love.sakura.ne.jp> wrote:
> >
> > KMSAN will complain if valid address length passed to bpf_bind() is
> > shorter than sizeof("struct sockaddr"->sa_family) bytes.
> >
> > Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> > ---
> > net/core/filter.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/net/core/filter.c b/net/core/filter.c
> > index 41f633cf4fc1..b9089fda4367 100644
> > --- a/net/core/filter.c
> > +++ b/net/core/filter.c
> > @@ -4458,6 +4458,8 @@ BPF_CALL_3(bpf_bind, struct bpf_sock_addr_kern *, ctx, struct sockaddr *, addr,
> > * Only binding to IP is supported.
> > */
> > err = -EINVAL;
> > + if (addr_len < offsetofend(struct sockaddr, sa_family))
> > + return err;
>
> the verifier will check that addr_len is not zero,
> but it can be one byte, so it's a good check.
> Thanks!
True, I missed this corner-case. Thanks for fixing.
Acked-by: Andrey Ignatov <rdna@fb.com>
> > if (addr->sa_family == AF_INET) {
> > if (addr_len < sizeof(struct sockaddr_in))
> > return err;
> > --
> > 2.16.5
> >
--
Andrey Ignatov
next prev parent reply other threads:[~2019-04-12 16:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-12 10:55 [PATCH 8/9] bpf: Check address length before reading address family Tetsuo Handa
2019-04-12 16:19 ` Alexei Starovoitov
2019-04-12 16:51 ` Andrey Ignatov [this message]
2019-04-12 17:26 ` David Miller
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=20190412165112.GB28199@rdna-mbp \
--to=rdna@fb.com \
--cc=alexei.starovoitov@gmail.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=penguin-kernel@i-love.sakura.ne.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox