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:   Mon, 7 Feb 2022 17:05:21 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Willy Tarreau' <w@....eu>,
        "Paul E . McKenney" <paulmck@...nel.org>
CC:     Mark Brown <broonie@...nel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH 11/42] tools/nolibc/types: move the FD_* functions to
 macros in types.h

From: Willy Tarreau
> Sent: 07 February 2022 16:23
> 
> FD_SET, FD_CLR, FD_ISSET, FD_ZERO are supposed to be macros and not
> functions.

Are you sure?
I'd have thought they could be either.
There are certainly systems where they are functions.
They can be implemented as an array of fd numbers rather than a bitmap.

> In addition we already have a file dedicated to such macros
> and types used by syscalls, it's types.h, so let's move them
> there and turn them to macros. FD_CLR() and FD_ISSET() were missing,
> so they were added. FD_ZERO() now deals with its own loop so that it
> doesn't rely on memset() that sets one byte at a time.
> 
....
> +#define FD_CLR(fd, set) do {                                            \
> +		int __fd = (int)(fd);                                   \
> +		fd_set *__set = (fd_set *)(set);                        \

I'm not sure you really want either cast.
They are just likely to hide some horrid bugs.

+		if (__fd >= 0 && __fd < FD_SETSIZE)                     \
+			__set->fd32[__fd / 32] &= ~(1U << (__fd & 31)); \
+	} while (0)
+

Do you need the range check?
I don't think glibc has one.
Things just break in obscure ways when you use select on big fd.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ