Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arc4random #1

Open
upsala opened this issue Feb 11, 2017 · 2 comments
Open

arc4random #1

upsala opened this issue Feb 11, 2017 · 2 comments
Assignees

Comments

@upsala
Copy link

upsala commented Feb 11, 2017

Wouldn't it be better, to replace arc4random() with random() ? This seems to be the only dependency to libbsd.

@tcort
Copy link
Member

tcort commented Feb 14, 2017

I'm primarily using this on FreeBSD. According to the FreeBSD manpage for random(3):

The functions described in this manual page are not secure. Applications which require unpredictable random numbers should use arc4random(3) instead.

I'll look at using getrandom(2) where available (i.e. on Linux) and then fall back to arc4random() everywhere else (FreeBSD, Mac OS X, older Linux without getrandom(2)).

@tcort tcort mentioned this issue Feb 14, 2017
@tcort
Copy link
Member

tcort commented Feb 15, 2017

It looks like getrandom(2) is a good choice for the following reasons:

  • it doesn't need to open any files (e.g. /dev/random nor /dev/urandom).
  • it doesn't need to be seeded by us.
  • it removes the libbsd dependency on Linux (when getrandom(2) is available).
  • it is cryptographically secure.
  • it doesn't block once the pool is ready -- I would assume it would be ready by the time MySQL is started.
  • etc.

However, even though the getrandom(2) syscall has been present in the kernel since 3.17, which was released over 2 years ago, it was only introduced into glibc 10 days ago (see The long road to getrandom() in glibc).

I'm going to hold off on implementing this change until I can get my hands on a Linux distribution with the new glibc. In the meantime, I'll make a release with the changes from the other issues.

@tcort tcort self-assigned this Feb 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants