Re: [PATCH] seedrng: fix getrandom() detection for non-glibc libc

2023-04-20 Thread Steffen Nurpmeso
Thomas Devoogdt wrote in
 :
 |I can't follow everything in your mail,
 |but about:
 |
 |>> Having said that, the current implementation as it is here is
 |>> surely wrong, since the fallback getrandom returns ENOSYS, instead
 |>> of setting errno to ENOSYS?
 |>> 200a9669fbf6f06894e42439fc11a1a6073a as of -04-10.
 |
 |Already fixed here:
 |https://git.busybox.net/busybox/commit/?id=cb57abb46f06f4ede8d9ccbdaac67\
 |377fdf416cf

Ok.  I am out of bandwidth and did not update, yes.

--steffen
|
|Der Kragenbaer,The moon bear,
|der holt sich munter   he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] seedrng: fix getrandom() detection for non-glibc libc

2023-04-19 Thread Thomas Devoogdt
Hi,

I can't follow everything in your mail,
but about:

>> Having said that, the current implementation as it is here is
>> surely wrong, since the fallback getrandom returns ENOSYS, instead
>> of setting errno to ENOSYS?
>> 200a9669fbf6f06894e42439fc11a1a6073a as of -04-10.

Already fixed here:
https://git.busybox.net/busybox/commit/?id=cb57abb46f06f4ede8d9ccbdaac67377fdf416cf

Kind regards,

Thomas
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] seedrng: fix getrandom() detection for non-glibc libc

2023-04-19 Thread Steffen Nurpmeso
Thomas Devoogdt wrote in
 :
 |About:
 |>> HAVE_GETRANDOM := $(shell printf '#include \n#include \
 |>> \nint main(void){char buf[256];\ngetrandom(buf,sizeof(buf)\
 |>> ,GRND_NONBLOCK);}' >bb_libtest.c; $(CC) $(CFLAGS) $(CFLAGS_busybox) \
 |>> -D_GNU_SOURCE -o /dev/null
 |
 |Is it a good idea to have GRND_NONBLOCK in that check? What if it's
 |not defined, but getrandom() is, then HAVE_GETRANDOM might incorrectly
 |be false?
 |We do anyway define it in seedrng.c if needed.

Heck, this entire thing is grazy from the start.
The kernel random code mutilates input coming via the /dev/*random
devices, instead of treating that as just the same regular input
as through ioctl or whatever (i am too lazy to look again).
They should all simply reject going that route along the random
maintainer, and insist on using

  # Load random seed
  /bin/cat /var/lib/urandom/seed > /dev/urandom

like my Linux distribution does (even though *i* repeatedly
prodded using my entropy thing, then that Friday the 13th thing
for years, before i had to go, mind you).
Moreover, even GLibC 2.36 / current manual pages still does not
document the other flag that the busybox applet uses.
Even on super-async modern boot, some things have to be
synchronized, why not random.  (If i recall correctly, people
knowing about systemd even said that is done, last time i said
that, hm.)

Just my off-topic one cent.  seedrng.c is an intellectually
penetrated piece of software.

Having said that, the current implementation as it is here is
surely wrong, since the fallback getrandom returns ENOSYS, instead
of setting errno to ENOSYS?
200a9669fbf6f06894e42439fc11a1a6073a as of -04-10.

--steffen
|
|Der Kragenbaer,The moon bear,
|der holt sich munter   he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] seedrng: fix getrandom() detection for non-glibc libc

2023-04-19 Thread Raphaël Mélotte
Hello,

On 19 April 2023 22:24:13 CEST, Thomas Devoogdt  wrote:
>Is it a good idea to have GRND_NONBLOCK in that check? What if it's
>not defined, but getrandom() is, then HAVE_GETRANDOM might incorrectly
>be false?
>We do anyway define it in seedrng.c if needed.

Indeed, maybe it should be removed.

Kind regards,

Raphaël
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] seedrng: fix getrandom() detection for non-glibc libc

2023-04-19 Thread Thomas Devoogdt
Hi,

About:
>> HAVE_GETRANDOM := $(shell printf '#include \n#include 
>> \nint main(void){char 
>> buf[256];\ngetrandom(buf,sizeof(buf),GRND_NONBLOCK);}' >bb_libtest.c; $(CC) 
>> $(CFLAGS) $(CFLAGS_busybox) -D_GNU_SOURCE -o /dev/null

Is it a good idea to have GRND_NONBLOCK in that check? What if it's
not defined, but getrandom() is, then HAVE_GETRANDOM might incorrectly
be false?
We do anyway define it in seedrng.c if needed.

Kind regards,

Thomas
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] seedrng: fix getrandom() detection for non-glibc libc

2023-04-19 Thread Raphaël Mélotte

On 4/19/23 14:52, Kang-Che Sung wrote:

Just my two cents...

On Wednesday, April 19, 2023, Raphaël Mélotte mailto:raphael.melo...@mind.be>> wrote:
 > +# Not all libc versions have getrandom, so check for it.
 > +HAVE_GETRANDOM := $(shell printf '#include \n#include \nint main(void){char 
buf[256];\ngetrandom(buf,sizeof(buf),GRND_NONBLOCK);}' >bb_libtest.c; $(CC) $(CFLAGS) $(CFLAGS_busybox) -D_GNU_SOURCE -o 
/dev/null bb_libtest.c >/dev/null 2>&1 && echo "y"; rm bb_libtest.c)

How about putting the define line '#define _GNU_SOURCE' into bb_libtest.c ? I 
don't like defining the feature test macros externally in '-D' options.


Sure, it's only added here for the test, either should work.
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] seedrng: fix getrandom() detection for non-glibc libc

2023-04-19 Thread Kang-Che Sung
Just my two cents...

On Wednesday, April 19, 2023, Raphaël Mélotte 
wrote:
> +# Not all libc versions have getrandom, so check for it.
> +HAVE_GETRANDOM := $(shell printf '#include \n#include
\nint main(void){char
buf[256];\ngetrandom(buf,sizeof(buf),GRND_NONBLOCK);}' >bb_libtest.c; $(CC)
$(CFLAGS) $(CFLAGS_busybox) -D_GNU_SOURCE -o /dev/null bb_libtest.c
>/dev/null 2>&1 && echo "y"; rm bb_libtest.c)

How about putting the define line '#define _GNU_SOURCE' into bb_libtest.c ?
I don't like defining the feature test macros externally in '-D' options.
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox