[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <61606335e85ae_1bf1208bb@john-XPS-13-9370.notmuch>
Date: Fri, 08 Oct 2021 08:26:45 -0700
From: John Fastabend <john.fastabend@...il.com>
To: Cong Wang <xiyou.wangcong@...il.com>,
Daniel Borkmann <daniel@...earbox.net>
Cc: Linux Kernel Network Developers <netdev@...r.kernel.org>,
bpf <bpf@...r.kernel.org>, Cong Wang <cong.wang@...edance.com>,
Yucong Sun <sunyucong@...il.com>,
John Fastabend <john.fastabend@...il.com>,
Jakub Sitnicki <jakub@...udflare.com>,
Lorenz Bauer <lmb@...udflare.com>
Subject: Re: [Patch bpf v3 3/4] net: implement ->sock_is_readable() for UDP
and AF_UNIX
Cong Wang wrote:
> On Thu, Oct 7, 2021 at 1:00 PM Daniel Borkmann <daniel@...earbox.net> wrote:
> >
> > On 10/2/21 2:37 AM, Cong Wang wrote:
> > > From: Cong Wang <cong.wang@...edance.com>
> > >
> > > Yucong noticed we can't poll() sockets in sockmap even
> > > when they are the destination sockets of redirections.
> > > This is because we never poll any psock queues in ->poll(),
> > > except for TCP. With ->sock_is_readable() now we can
> > > overwrite >sock_is_readable(), invoke and implement it for
> > > both UDP and AF_UNIX sockets.
> > >
> > > Reported-by: Yucong Sun <sunyucong@...il.com>
> > > Cc: John Fastabend <john.fastabend@...il.com>
> > > Cc: Daniel Borkmann <daniel@...earbox.net>
> > > Cc: Jakub Sitnicki <jakub@...udflare.com>
> > > Cc: Lorenz Bauer <lmb@...udflare.com>
> > > Signed-off-by: Cong Wang <cong.wang@...edance.com>
> > > ---
> > > net/ipv4/udp.c | 2 ++
> > > net/ipv4/udp_bpf.c | 1 +
> > > net/unix/af_unix.c | 4 ++++
> > > net/unix/unix_bpf.c | 2 ++
> > > 4 files changed, 9 insertions(+)
> > >
> > > diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
> > > index 2a7825a5b842..4a7e15a43a68 100644
> > > --- a/net/ipv4/udp.c
> > > +++ b/net/ipv4/udp.c
> > > @@ -2866,6 +2866,8 @@ __poll_t udp_poll(struct file *file, struct socket *sock, poll_table *wait)
> > > !(sk->sk_shutdown & RCV_SHUTDOWN) && first_packet_length(sk) == -1)
> > > mask &= ~(EPOLLIN | EPOLLRDNORM);
> > >
> > > + if (sk_is_readable(sk))
> > > + mask |= EPOLLIN | EPOLLRDNORM;
> >
> > udp_poll() has this extra logic around first_packet_length() which drops all bad csum'ed
> > skbs. How does this stand in relation to sk_msg_is_readable()? Is this a concern as well
> > there? Maybe makes sense to elaborate a bit more in the commit message for context / future
> > reference.
>
> We don't validate UDP checksums on sockmap RX path, so
> it is okay to leave it as it is, but it is worth a comment like
> you suggest. I will add a comment in this code.
>
> If we really need to validate the checksum, it should be addressed
> in a separate patch(set), not in this one.
>
> Thanks.
We should validate the checksum before creating the sk_msg so that any parsers running
on top of UDP don't parse a bad checksum payload or pass a bad checksum up to user
space. I thought there would be a check in the read_sock side, but I didn't see it.
Powered by blists - more mailing lists