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: <20190917071222.6nfzmcxt4kxzgpki@gallifrey>
Date:   Tue, 17 Sep 2019 04:12:22 -0300
From:   Marcelo Henrique Cerri <marcelo.cerri@...onical.com>
To:     shuah <shuah@...nel.org>
Cc:     "David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org,
        linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] selftests/net: replace AF_MAX with INT_MAX in socket.c

So the problem arises because the headers we have in userspace might
be older and not match what we have in the kernel. In that case, the
actual value of AF_MAX in the userspace headers might be a valid
protocol family in the new kernel.

That happens relatively often for us because we support different
kernel versions at the same time in a given Ubuntu series.

An alternative is to use the headers we have in the kernel tree, but I
believe that might cause other issues.

On Mon, Sep 16, 2019 at 10:09:13AM -0600, shuah wrote:
> On 9/16/19 9:03 AM, Marcelo Henrique Cerri wrote:
> > Use INT_MAX instead of AF_MAX, since libc might have a smaller value
> > of AF_MAX than the kernel, what causes the test to fail.
> > 
> > Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@...onical.com>
> > ---
> >   tools/testing/selftests/net/socket.c | 6 +++++-
> >   1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/testing/selftests/net/socket.c b/tools/testing/selftests/net/socket.c
> > index afca1ead677f..10e75ba90124 100644
> > --- a/tools/testing/selftests/net/socket.c
> > +++ b/tools/testing/selftests/net/socket.c
> > @@ -6,6 +6,7 @@
> >   #include <sys/types.h>
> >   #include <sys/socket.h>
> >   #include <netinet/in.h>
> > +#include <limits.h>
> >   struct socket_testcase {
> >   	int	domain;
> > @@ -24,7 +25,10 @@ struct socket_testcase {
> >   };
> >   static struct socket_testcase tests[] = {
> > -	{ AF_MAX,  0,           0,           -EAFNOSUPPORT,    0 },
> > +	/* libc might have a smaller value of AF_MAX than the kernel
> > +	 * actually supports, so use INT_MAX instead.
> > +	 */
> > +	{ INT_MAX, 0,           0,           -EAFNOSUPPORT,    0  },
> >   	{ AF_INET, SOCK_STREAM, IPPROTO_TCP, 0,                1  },
> >   	{ AF_INET, SOCK_DGRAM,  IPPROTO_TCP, -EPROTONOSUPPORT, 1  },
> >   	{ AF_INET, SOCK_DGRAM,  IPPROTO_UDP, 0,                1  },
> > 
> 
> What failure are you seeing? It sounds arbitrary to use INT_MAX
> instead of AF_MAX. I think it is important to understand the
> failure first.
> 
> Please note that AF_MAX is widely used in the kernel.
> 
> thanks,
> -- Shuah

-- 
Regards,
Marcelo


Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ