Re: Picky, but much more efficient arc4random_uniform!

2022-05-14 Thread Luke Small
This is version 1, which I was pretty sure was secure. I revamped it with a few features and implanted the binary search for 'bit' in most cases, which aren't intentionally worst-case, it's pretty darned fast! This is a sample run of my program with your piece of code included: 1 99319 10023

Re: Picky, but much more efficient arc4random_uniform!

2022-05-14 Thread Otto Moerbeek
On Sat, May 14, 2022 at 05:03:17PM -0700, Philip Guenther wrote: > On Sun, 15 May 2022, Steffen Nurpmeso wrote: > > Stuart Henderson wrote in > ... > > |what's the perceived problem you're wanting to solve? and does that > > |problem actually exist in the first place? > > > > The problem is tha

use cpu sensor for cpuspeed

2022-05-14 Thread Ted Unangst
The cpu hz sensor is more accurate and updates faster than than the value currently used for hw.cpuspeed. So return that value (scaled). This doesn't set cpuspeed directly because the acpi does that and it's hard to create a whole system of priority overrides. I think it's simpler and maybe even b

Re: Picky, but much more efficient arc4random_uniform!

2022-05-14 Thread Philip Guenther
On Sun, 15 May 2022, Steffen Nurpmeso wrote: > Stuart Henderson wrote in ... > |what's the perceived problem you're wanting to solve? and does that > |problem actually exist in the first place? > > The problem is that if have a low upper bound then modulo will "remove a > lot of randomization".

Re: Picky, but much more efficient arc4random_uniform!

2022-05-14 Thread Steffen Nurpmeso
Stuart Henderson wrote in : |On 2022/05/14 06:56, Luke Small wrote: |> If I use arc4random_uniform() repeatedly to create a random distribution \ |> of |> say numbers less than 0x1000 or even something weird like 0x1300 will the |> random distribution be better with arc4random_uniform() or wi

Re: Picky, but much more efficient arc4random_uniform!

2022-05-14 Thread Matthew Martin
int main() { int results[3] = { 0, 0, 0 }; for (int i = 0; i < 10; i++) { results[arc4random_uniform_fast_simple(3)]++; } for (int i = 0; i < 3; i++) printf("%d: %d\n", i, results[i]); return 0; } % ./a.out 0: 24809 1: 50

Re: Picky, but much more efficient arc4random_uniform!

2022-05-14 Thread Stuart Henderson
On 2022/05/14 06:56, Luke Small wrote: > If I use arc4random_uniform() repeatedly to create a random distribution of > say numbers less than 0x1000 or even something weird like 0x1300 will the > random distribution be better with arc4random_uniform() or with mine? there's no point to have a choice

Re: stop using mquery(2) inside realloc(3)

2022-05-14 Thread Philip Guenther
On Sat, 14 May 2022, Philip Guenther wrote: > On Sat, 14 May 2022, Theo de Raadt wrote: > > I worry a little about having libc use an undocumented mmap(2) flag. > > About as much as using mquery, which is non-standard. > > > > Maybe __MAP_NOREPLACE should get documentation? __MAP_NOFAULT is in th

Re: stop using mquery(2) inside realloc(3)

2022-05-14 Thread Philip Guenther
On Sat, 14 May 2022, Theo de Raadt wrote: > I worry a little about having libc use an undocumented mmap(2) flag. > About as much as using mquery, which is non-standard. > > Maybe __MAP_NOREPLACE should get documentation? __MAP_NOFAULT is in the > same situation. The behaviour of these flags shou

Re: Picky, but much more efficient arc4random_uniform!

2022-05-14 Thread Luke Small
Look at my code. I don’t even use a modulus operator. I perform hit and miss with a random bitstream. How can I have a bias of something I don’t do? I return a bitstream which meets the parameters of being a value less than the upper bound. Much like arc4random_buf(). If I use arc4random_uniform(

Re: stop using mquery(2) inside realloc(3)

2022-05-14 Thread Theo de Raadt
I worry a little about having libc use an undocumented mmap(2) flag. About as much as using mquery, which is non-standard. Maybe __MAP_NOREPLACE should get documentation? __MAP_NOFAULT is in the same situation. The behaviour of these flags should be documented (set in stone), which may also disc

Re: librthread: validate timespec inputs with timespecisvalid(3)

2022-05-14 Thread Todd C . Miller
On Sat, 14 May 2022 09:31:26 -0500, Scott Cheloha wrote: > ok? OK millert@ - todd

librthread: validate timespec inputs with timespecisvalid(3)

2022-05-14 Thread Scott Cheloha
ok? Index: rthread_rwlock_compat.c === RCS file: /cvs/src/lib/librthread/rthread_rwlock_compat.c,v retrieving revision 1.1 diff -u -p -r1.1 rthread_rwlock_compat.c --- rthread_rwlock_compat.c 13 Feb 2019 13:15:39 - 1.1 ++

Re: Picky, but much more efficient arc4random_uniform!

2022-05-14 Thread Otto Moerbeek
On Sat, May 14, 2022 at 05:48:10AM -0500, Luke Small wrote: > arc4random_uniform_fast2 that I made, streams in data from arc4random() and > uses the datastream directly and uses it as a bit by bit right "sliding > window" in the last loop. arc4random_uniform() uses a modulus which I is > simple to

Re: Picky, but much more efficient arc4random_uniform!

2022-05-14 Thread Luke Small
arc4random_uniform_fast2 that I made, streams in data from arc4random() and uses the datastream directly and uses it as a bit by bit right "sliding window" in the last loop. arc4random_uniform() uses a modulus which I is simple to implement, but I wonder how cryptographically sound or even how even