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]
Date:   Tue, 1 Mar 2022 16:25:21 +0100
From:   Samuel Thibault <samuel.thibault@...ri.fr>
To:     Willem de Bruijn <willemdebruijn.kernel@...il.com>
Cc:     willemb@...gle.com, davem@...emloft.net, kuba@...nel.org,
        linux-kernel@...r.kernel.org,
        Network Development <netdev@...r.kernel.org>
Subject: Re: [PATCH] SO_ZEROCOPY should rather return -ENOPROTOOPT

Willem de Bruijn, le mar. 01 mars 2022 10:21:41 -0500, a ecrit:
> On Tue, Mar 1, 2022 at 10:20 AM Samuel Thibault
> <samuel.thibault@...ri.fr> wrote:
> >
> > Willem de Bruijn, le mar. 01 mars 2022 10:14:18 -0500, a ecrit:
> > > On Tue, Mar 1, 2022 at 10:00 AM Samuel Thibault
> > > <samuel.thibault@...ri.fr> wrote:
> > > >
> > > > Willem de Bruijn, le mar. 01 mars 2022 09:51:45 -0500, a ecrit:
> > > > > On Tue, Mar 1, 2022 at 9:44 AM Samuel Thibault <samuel.thibault@...ri.fr> wrote:
> > > > > >
> > > > > > ENOTSUPP is documented as "should never be seen by user programs", and
> > > > > > is not exposed in <errno.h>, so applications cannot safely check against
> > > > > > it. We should rather return the well-known -ENOPROTOOPT.
> > > > > >
> > > > > > Signed-off-by: Samuel Thibault <samuel.thibault@...ri.fr>
> > > > > >
> > > > > > diff --git a/net/core/sock.c b/net/core/sock.c
> > > > > > index 4ff806d71921..6e5b84194d56 100644
> > > > > > --- a/net/core/sock.c
> > > > > > +++ b/net/core/sock.c
> > > > > > @@ -1377,9 +1377,9 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
> > > > > >                         if (!(sk_is_tcp(sk) ||
> > > > > >                               (sk->sk_type == SOCK_DGRAM &&
> > > > > >                                sk->sk_protocol == IPPROTO_UDP)))
> > > > > > -                               ret = -ENOTSUPP;
> > > > > > +                               ret = -ENOPROTOOPT;
> > > > > >                 } else if (sk->sk_family != PF_RDS) {
> > > > > > -                       ret = -ENOTSUPP;
> > > > > > +                       ret = -ENOPROTOOPT;
> > > > > >                 }
> > > > > >                 if (!ret) {
> > > > > >                         if (val < 0 || val > 1)
> > > > >
> > > > > That should have been a public error code. Perhaps rather EOPNOTSUPP.
> > > > >
> > > > > The problem with a change now is that it will confuse existing
> > > > > applications that check for -524 (ENOTSUPP).
> > > >
> > > > They were not supposed to hardcord -524...
> > > >
> > > > Actually, they already had to check against EOPNOTSUPP to support older
> > > > kernels, so EOPNOTSUPP is not supposed to pose a problem.
> > >
> > > Which older kernels returned EOPNOTSUPP on SO_ZEROCOPY?
> >
> > Sorry, bad copy/paste, I meant ENOPROTOOPT.
> 
> Same point though, right? These are not legacy concerns, but specific
> to applications written to SO_ZEROCOPY.
> 
> I expect that most will just ignore the exact error code and will work
> with either.

Well, in the code I just wrote, I ignored ENOPROTOOPT due to older
kernels, and it's only when the code happened to be run against PF_LOCAL
sockets that the ENOTSUPP question raised. My code has never been
exposed to a EOPNOTSUPP error, so I would have never written a check
against EOPNOTSUPP if you didn't mention it as a possibility.

Samuel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ