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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89iL=npDL0S+w-F-iE2kmQ2rnNSA7K9ic9s-4ByLkvHPHYg@mail.gmail.com>
Date: Tue, 13 Feb 2024 14:34:48 +0100
From: Eric Dumazet <edumazet@...gle.com>
To: Paolo Abeni <pabeni@...hat.com>
Cc: kuba@...nel.org, passt-dev@...st.top, sbrivio@...hat.com, 
	lvivier@...hat.com, dgibson@...hat.com, jmaloy@...hat.com, 
	netdev@...r.kernel.org, davem@...emloft.net
Subject: Re: [PATCH v3] tcp: add support for SO_PEEK_OFF

On Tue, Feb 13, 2024 at 2:02 PM Paolo Abeni <pabeni@...hat.com> wrote:
>
> On Tue, 2024-02-13 at 13:24 +0100, Eric Dumazet wrote:
> > On Tue, Feb 13, 2024 at 11:49 AM Paolo Abeni <pabeni@...hat.com> wrote:
> >
> > > > @@ -2508,7 +2508,10 @@ static int tcp_recvmsg_locked(struct sock *sk, struct msghdr *msg, size_t len,
> > > >               WRITE_ONCE(*seq, *seq + used);
> > > >               copied += used;
> > > >               len -= used;
> > > > -
> > > > +             if (flags & MSG_PEEK)
> > > > +                     sk_peek_offset_fwd(sk, used);
> > > > +             else
> > > > +                     sk_peek_offset_bwd(sk, used);
> >
> > Yet another cache miss in TCP fast path...
> >
> > We need to move sk_peek_off in a better location before we accept this patch.
> >
> > I always thought MSK_PEEK was very inefficient, I am surprised we
> > allow arbitrary loops in recvmsg().
>
> Let me double check I read the above correctly: are you concerned by
> the 'skb_queue_walk(&sk->sk_receive_queue, skb) {' loop that could
> touch a lot of skbs/cachelines before reaching the relevant skb?
>
> The end goal here is allowing an user-space application to read
> incrementally/sequentially the received data while leaving them in
> receive buffer.
>
> I don't see a better option than MSG_PEEK, am I missing something?


This sk_peek_offset protocol, needing  sk_peek_offset_bwd() in the non
MSG_PEEK case is very strange IMO.

Ideally, we should read/write over sk_peek_offset only when MSG_PEEK
is used by the caller.

That would only touch non fast paths.

Since the API is mono-threaded anyway, the caller should not rely on
the fact that normal recvmsg() call
would 'consume' sk_peek_offset.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ