I've now committed most of your diff, thanks once again.

    o I asked for further review on the kernel parts
    o I'm going to skip hack for now

Here's a patch for libc, based on the previous discussion.
I think this is easier to read and understand.  No binary change on
amd64.

ok?

Index: lib/libc/stdlib/rand.c
===================================================================
RCS file: /var/cvs/src/lib/libc/stdlib/rand.c,v
retrieving revision 1.15
diff -u -p -r1.15 rand.c
--- lib/libc/stdlib/rand.c      13 Sep 2015 08:31:47 -0000      1.15
+++ lib/libc/stdlib/rand.c      16 Dec 2015 08:02:41 -0000
@@ -37,7 +37,7 @@ int
 rand_r(u_int *seed)
 {
        *seed = *seed * 1103515245 + 12345;
-       return (*seed % ((u_int)RAND_MAX + 1));
+       return (*seed & RAND_MAX);
 }
 DEF_WEAK(rand_r);
 
@@ -50,7 +50,7 @@ int
 rand(void)
 {
        if (rand_deterministic == 0)
-               return (arc4random() % ((u_int)RAND_MAX + 1));
+               return (arc4random() & RAND_MAX);
        return (rand_r(&next));
 }
 

Reply via email to