mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-24 17:44:17 +01:00
openssl: use getrandom(2) instead of probing for getentropy(2)
The probing for getentropy(2) relies on re-declaring getentropy(2) as weak and checking the address, but this is incompatible with the _FORTIFY_SOURCE symbol renaming scheme. It's always present on all supported FreeBSD versions now so we could cut it down to unconditional use, but there's another segment for getrandom(2) already that's cleaner to just add us to. We should upstream this. Reviewed by: kib (earlier version), markj Sponsored by: Klara, Inc. Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D45976
This commit is contained in:
parent
9c73f38cd3
commit
838b6caaba
@ -356,7 +356,7 @@ static ssize_t syscall_random(void *buf, size_t buflen)
|
||||
* Note: Sometimes getentropy() can be provided but not implemented
|
||||
* internally. So we need to check errno for ENOSYS
|
||||
*/
|
||||
# if !defined(__DragonFly__) && !defined(__NetBSD__)
|
||||
# if !defined(__DragonFly__) && !defined(__NetBSD__) && !defined(__FreeBSD__)
|
||||
# if defined(__GNUC__) && __GNUC__>=2 && defined(__ELF__) && !defined(__hpux)
|
||||
extern int getentropy(void *buffer, size_t length) __attribute__((weak));
|
||||
|
||||
@ -393,11 +393,12 @@ static ssize_t syscall_random(void *buf, size_t buflen)
|
||||
/* Linux supports this since version 3.17 */
|
||||
# if defined(__linux) && defined(__NR_getrandom)
|
||||
return syscall(__NR_getrandom, buf, buflen, 0);
|
||||
# elif (defined(__FreeBSD__) || defined(__NetBSD__)) && defined(KERN_ARND)
|
||||
return sysctl_random(buf, buflen);
|
||||
# elif (defined(__DragonFly__) && __DragonFly_version >= 500700) \
|
||||
|| (defined(__NetBSD__) && __NetBSD_Version >= 1000000000)
|
||||
|| (defined(__NetBSD__) && __NetBSD_Version >= 1000000000) \
|
||||
|| defined(__FreeBSD__)
|
||||
return getrandom(buf, buflen, 0);
|
||||
# elif defined(__NetBSD__) && defined(KERN_ARND)
|
||||
return sysctl_random(buf, buflen);
|
||||
# else
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user