Remove malloc() dependency on pledge() / unveil()

This change also fixes a bug with gettid() being incorrect after fork().
We now implement the ENOENT behavior for getauxval(). The getuid() etc.
system calls are now faster too. Plus issetugid() will work on BSDs.
This commit is contained in:
Justine Tunney 2022-07-24 19:40:32 -07:00
parent c921dc78f0
commit 3d2cf95af1
33 changed files with 270 additions and 100 deletions

View file

@ -16,6 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/calls/_getauxval.internal.h"
#include "libc/intrin/pthread.h"
#include "libc/intrin/spinlock.h"
#include "libc/nexgen32e/rdtsc.h"
@ -54,7 +55,7 @@ uint64_t rand64(void) {
s = g_rand64.thepool; // normal path
} else {
if (!g_rand64.thepid) {
if (AT_RANDOM && (p = (void *)getauxval(AT_RANDOM))) {
if (AT_RANDOM && (p = (void *)_getauxval(AT_RANDOM).value)) {
// linux / freebsd kernel supplied entropy
memcpy(&s, p, 16);
} else {