[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240219225611.38239-1-kuniyu@amazon.com>
Date: Mon, 19 Feb 2024 14:56:11 -0800
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <willemdebruijn.kernel@...il.com>
CC: <daan.j.demeyer@...il.com>, <davem@...emloft.net>, <dsahern@...nel.org>,
<edumazet@...gle.com>, <eric.dumazet@...il.com>, <kuba@...nel.org>,
<kuniyu@...zon.com>, <martin.lau@...nel.org>, <netdev@...r.kernel.org>,
<pabeni@...hat.com>
Subject: Re: [PATCH net] net: implement lockless setsockopt(SO_PEEK_OFF)
From: Willem de Bruijn <willemdebruijn.kernel@...il.com>
Date: Mon, 19 Feb 2024 12:20:39 -0500
> Eric Dumazet wrote:
> > On Mon, Feb 19, 2024 at 5:07 PM Willem de Bruijn
> > <willemdebruijn.kernel@...il.com> wrote:
> > >
> > > Eric Dumazet wrote:
> > > > syzbot reported a lockdep violation [1] involving af_unix
> > > > support of SO_PEEK_OFF.
> > > >
> > > > Since SO_PEEK_OFF is inherently not thread safe (it uses a per-socket
> > > > sk_peek_off field), there is really no point to enforce a pointless
> > > > thread safety in the kernel.
> > >
> > > Would it be sufficient to just move the setsockopt, so that the
> > > socket lock is not taken, but iolock still is?
> >
> > Probably, if we focus on the lockdep issue rather than the general
> > SO_PEEK_OFF mechanism.
> >
> > We could remove unix_set_peek_off() in net-next,
> > unless someone explains why keeping a locking on iolock is needed.
Probably to avoid a small race where setsockopt() does not take effect.
sk_peek_offset_bwd
setsockopt |- off = READ_ONCE(sk_peek_off)
`- WRITE_ONCE(sk_peek_off, val) |
`- WRITE_ONCE(sk_peek_off, off - val)
>
> Since calling SO_PEEK_OFF and recvmsg concurrently is inherently not
> thread-safe, fine to remove it all.
Agreed, we can do that locklessly.
Reviewed-by: Kuniyuki Iwashima <kuniyu@...zon.com>
Powered by blists - more mailing lists