lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAM_iQpXqCQ1BPwqokr6djGmGEHF5BXQDQEPygq16FHDJwxk=uA@mail.gmail.com>
Date:   Wed, 13 Oct 2021 09:38:20 -0700
From:   Cong Wang <xiyou.wangcong@...il.com>
To:     John Fastabend <john.fastabend@...il.com>
Cc:     Linux Kernel Network Developers <netdev@...r.kernel.org>,
        bpf <bpf@...r.kernel.org>, Cong Wang <cong.wang@...edance.com>,
        Daniel Borkmann <daniel@...earbox.net>,
        Lorenz Bauer <lmb@...udflare.com>,
        Jakub Sitnicki <jakub@...udflare.com>
Subject: Re: [Patch bpf] udp: validate checksum in udp_read_sock()

On Mon, Oct 11, 2021 at 10:06 PM John Fastabend
<john.fastabend@...il.com> wrote:
>
> Cong Wang wrote:
> > From: Cong Wang <cong.wang@...edance.com>
> >
> > It turns out the skb's in sock receive queue could have
> > bad checksums, as both ->poll() and ->recvmsg() validate
> > checksums. We have to do the same for ->read_sock() path
> > too before they are redirected in sockmap.
> >
> > Fixes: d7f571188ecf ("udp: Implement ->read_sock() for sockmap")
> > Reported-by: Daniel Borkmann <daniel@...earbox.net>
> > Reported-by: John Fastabend <john.fastabend@...il.com>
> > Cc: Lorenz Bauer <lmb@...udflare.com>
> > Cc: Jakub Sitnicki <jakub@...udflare.com>
> > Signed-off-by: Cong Wang <cong.wang@...edance.com>
> > ---
> >  net/ipv4/udp.c | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
> > index 8536b2a7210b..0ae8ab5e05b4 100644
> > --- a/net/ipv4/udp.c
> > +++ b/net/ipv4/udp.c
> > @@ -1808,6 +1808,17 @@ int udp_read_sock(struct sock *sk, read_descriptor_t *desc,
> >               skb = skb_recv_udp(sk, 0, 1, &err);
> >               if (!skb)
> >                       return err;
> > +
> > +             if (udp_lib_checksum_complete(skb)) {
> > +                     __UDP_INC_STATS(sock_net(sk), UDP_MIB_CSUMERRORS,
> > +                                     IS_UDPLITE(sk));
> > +                     __UDP_INC_STATS(sock_net(sk), UDP_MIB_INERRORS,
> > +                                     IS_UDPLITE(sk));
> > +                     atomic_inc(&sk->sk_drops);
> > +                     kfree_skb(skb);
>
> We could use sock_drop() here? Otherwise looks good thanks.

sock_drop() is in include/linux/skmsg.h, I think we need to move it
to sock.h before using it here in net/ipv4/udp.c, right?

And there are other similar patterns which can be replaced with
sock_drop(), so we can do the replacement for all in a separate
patch.

Thanks.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ