mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-25 16:30:53 +07:00
f06295b44c
While discussing[1] the need for glibc to have access to random bytes during program load, it seems that an earlier attempt to implement AT_RANDOM got stalled. This implements a random 16 byte string, available to every ELF program via a new auxv AT_RANDOM vector. [1] http://sourceware.org/ml/libc-alpha/2008-10/msg00006.html Ulrich said: glibc needs right after startup a bit of random data for internal protections (stack canary etc). What is now in upstream glibc is that we always unconditionally open /dev/urandom, read some data, and use it. For every process startup. That's slow. ... The solution is to provide a limited amount of random data to the starting process in the aux vector. I suggested 16 bytes and this is what the patch implements. If we need only 16 bytes or less we use the data directly. If we need more we'll use the 16 bytes to see a PRNG. This avoids the costly /dev/urandom use and it allows the kernel to use the most adequate source of random data for this purpose. It might not be the same pool as that for /dev/urandom. Concerns were expressed about the depletion of the randomness pool. But this patch doesn't make the situation worse, it doesn't deplete entropy more than happens now. Signed-off-by: Kees Cook <kees.cook@canonical.com> Cc: Jakub Jelinek <jakub@redhat.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: Ulrich Drepper <drepper@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
40 lines
1.5 KiB
C
40 lines
1.5 KiB
C
#ifndef _LINUX_AUXVEC_H
|
|
#define _LINUX_AUXVEC_H
|
|
|
|
#include <asm/auxvec.h>
|
|
|
|
/* Symbolic values for the entries in the auxiliary table
|
|
put on the initial stack */
|
|
#define AT_NULL 0 /* end of vector */
|
|
#define AT_IGNORE 1 /* entry should be ignored */
|
|
#define AT_EXECFD 2 /* file descriptor of program */
|
|
#define AT_PHDR 3 /* program headers for program */
|
|
#define AT_PHENT 4 /* size of program header entry */
|
|
#define AT_PHNUM 5 /* number of program headers */
|
|
#define AT_PAGESZ 6 /* system page size */
|
|
#define AT_BASE 7 /* base address of interpreter */
|
|
#define AT_FLAGS 8 /* flags */
|
|
#define AT_ENTRY 9 /* entry point of program */
|
|
#define AT_NOTELF 10 /* program is not ELF */
|
|
#define AT_UID 11 /* real uid */
|
|
#define AT_EUID 12 /* effective uid */
|
|
#define AT_GID 13 /* real gid */
|
|
#define AT_EGID 14 /* effective gid */
|
|
#define AT_PLATFORM 15 /* string identifying CPU for optimizations */
|
|
#define AT_HWCAP 16 /* arch dependent hints at CPU capabilities */
|
|
#define AT_CLKTCK 17 /* frequency at which times() increments */
|
|
/* AT_* values 18 through 22 are reserved */
|
|
#define AT_SECURE 23 /* secure mode boolean */
|
|
#define AT_BASE_PLATFORM 24 /* string identifying real platform, may
|
|
* differ from AT_PLATFORM. */
|
|
#define AT_RANDOM 25 /* address of 16 random bytes */
|
|
|
|
#define AT_EXECFN 31 /* filename of program */
|
|
|
|
#ifdef __KERNEL__
|
|
#define AT_VECTOR_SIZE_BASE 19 /* NEW_AUX_ENT entries in auxiliary table */
|
|
/* number of "#define AT_.*" above, minus {AT_NULL, AT_IGNORE, AT_NOTELF} */
|
|
#endif
|
|
|
|
#endif /* _LINUX_AUXVEC_H */
|