Skip to content

Commit cd52c59

Browse files
committed
Allow MAP_POPULATE under pledge()
1 parent 53357aa commit cd52c59

File tree

6 files changed

+3
-305
lines changed

6 files changed

+3
-305
lines changed

libc/calls/pledge-linux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1644,7 +1644,7 @@ static privileged void AllowMmapNoexec(struct Filter *f) {
16441644
/*L2*/ BPF_STMT(BPF_ALU | BPF_AND | BPF_K, ~(PROT_READ | PROT_WRITE)),
16451645
/*L3*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 0, 8 - 4),
16461646
/*L4*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[3])), // flags
1647-
/*L5*/ BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0x5a000),
1647+
/*L5*/ BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0x52000),
16481648
/*L6*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 0, 1),
16491649
/*L7*/ BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW),
16501650
/*L8*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(nr)),

libc/dlopen/BUILD.mk

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,8 @@ LIBC_DLOPEN = $(LIBC_DLOPEN_A_DEPS) $(LIBC_DLOPEN_A)
88
LIBC_DLOPEN_A = o/$(MODE)/libc/dlopen/dlopen.a
99
LIBC_DLOPEN_A_FILES := $(wildcard libc/dlopen/*)
1010
LIBC_DLOPEN_A_HDRS = $(filter %.h,$(LIBC_DLOPEN_A_FILES))
11-
LIBC_DLOPEN_A_SRCS_S = $(filter %.S,$(LIBC_DLOPEN_A_FILES))
12-
LIBC_DLOPEN_A_SRCS_C = $(filter %.c,$(LIBC_DLOPEN_A_FILES))
13-
14-
LIBC_DLOPEN_A_SRCS = \
15-
$(LIBC_DLOPEN_A_SRCS_S) \
16-
$(LIBC_DLOPEN_A_SRCS_C)
17-
18-
LIBC_DLOPEN_A_OBJS = \
19-
$(LIBC_DLOPEN_A_SRCS_S:%.S=o/$(MODE)/%.o) \
20-
$(LIBC_DLOPEN_A_SRCS_C:%.c=o/$(MODE)/%.o)
11+
LIBC_DLOPEN_A_SRCS = $(filter %.c,$(LIBC_DLOPEN_A_FILES))
12+
LIBC_DLOPEN_A_OBJS = $(LIBC_DLOPEN_A_SRCS:%.c=o/$(MODE)/%.o)
2113

2214
LIBC_DLOPEN_A_CHECKS = \
2315
$(LIBC_DLOPEN_A).pkg \

libc/nexgen32e/nt2sysv.S

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
__nt2sysv:
3333
push %rbp
3434
mov %rsp,%rbp
35-
// TODO(jart): We should probably find some way to use our own
36-
// stack when Windows delivers signals ;_;
3735
sub $256,%rsp
3836
push %rbx
3937
push %rdi

libc/nexgen32e/yield.h

Whitespace-only changes.

third_party/make/job.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3792,24 +3792,5 @@ construct_command_argv (char *line, char **restp, struct file *file,
37923792

37933793
return argv;
37943794
}
3795-
3796-
#if !defined(HAVE_DUP2) && !defined(_AMIGA)
3797-
int
3798-
dup2 (int old, int new)
3799-
{
3800-
int fd;
3801-
3802-
(void) close (new);
3803-
EINTRLOOP (fd, dup (old));
3804-
if (fd != new)
3805-
{
3806-
(void) close (fd);
3807-
errno = EMFILE;
3808-
return -1;
3809-
}
3810-
3811-
return fd;
3812-
}
3813-
#endif /* !HAVE_DUP2 && !_AMIGA */
38143795

38153796
/* On VMS systems, include special VMS functions. */

third_party/make/misc.c

Lines changed: 0 additions & 273 deletions
Original file line numberDiff line numberDiff line change
@@ -556,22 +556,6 @@ dbg (const char *fmt, ...)
556556

557557
/* Provide support for temporary files. */
558558

559-
#ifndef HAVE_STDLIB_H
560-
# ifdef HAVE_MKSTEMP
561-
int mkstemp (char *template);
562-
# else
563-
char *mktemp (char *template);
564-
# endif
565-
#endif
566-
567-
#ifndef HAVE_UMASK
568-
mode_t
569-
umask (mode_t mask)
570-
{
571-
return 0;
572-
}
573-
#endif
574-
575559
#ifdef VMS
576560
# define DEFAULT_TMPFILE "sys$scratch:gnv$make_cmdXXXXXX.com"
577561
#else
@@ -784,260 +768,3 @@ get_tmpfile (char **name)
784768

785769
return file;
786770
}
787-
788-
789-
#if HAVE_TTYNAME && defined(__EMX__)
790-
/* OS/2 kLIBC has a declaration for ttyname(), so configure finds it.
791-
But, it is not implemented! Roll our own. */
792-
char *ttyname (int fd)
793-
{
794-
ULONG type;
795-
ULONG attr;
796-
ULONG rc;
797-
798-
rc = DosQueryHType (fd, &type, &attr);
799-
if (rc)
800-
{
801-
errno = EBADF;
802-
return NULL;
803-
}
804-
805-
if (type == HANDTYPE_DEVICE)
806-
{
807-
if (attr & 3) /* 1 = KBD$, 2 = SCREEN$ */
808-
return (char *) "/dev/con";
809-
810-
if (attr & 4) /* 4 = NUL */
811-
return (char *) "/dev/nul";
812-
813-
if (attr & 8) /* 8 = CLOCK$ */
814-
return (char *) "/dev/clock$";
815-
}
816-
817-
errno = ENOTTY;
818-
return NULL;
819-
}
820-
#endif
821-
822-
823-
#if !HAVE_STRCASECMP && !HAVE_STRICMP && !HAVE_STRCMPI
824-
/* If we don't have strcasecmp() (from POSIX), or anything that can substitute
825-
for it, define our own version. */
826-
827-
int
828-
strcasecmp (const char *s1, const char *s2)
829-
{
830-
while (1)
831-
{
832-
int c1 = (unsigned char) *(s1++);
833-
int c2 = (unsigned char) *(s2++);
834-
835-
if (isalpha (c1))
836-
c1 = tolower (c1);
837-
if (isalpha (c2))
838-
c2 = tolower (c2);
839-
840-
if (c1 != '\0' && c1 == c2)
841-
continue;
842-
843-
return (c1 - c2);
844-
}
845-
}
846-
#endif
847-
848-
#if !HAVE_STRNCASECMP && !HAVE_STRNICMP && !HAVE_STRNCMPI
849-
/* If we don't have strncasecmp() (from POSIX), or anything that can
850-
substitute for it, define our own version. */
851-
852-
int
853-
strncasecmp (const char *s1, const char *s2, size_t n)
854-
{
855-
while (n-- > 0)
856-
{
857-
int c1 = (unsigned char) *(s1++);
858-
int c2 = (unsigned char) *(s2++);
859-
860-
if (isalpha (c1))
861-
c1 = tolower (c1);
862-
if (isalpha (c2))
863-
c2 = tolower (c2);
864-
865-
if (c1 != '\0' && c1 == c2)
866-
continue;
867-
868-
return (c1 - c2);
869-
}
870-
871-
return 0;
872-
}
873-
#endif
874-
875-
876-
#ifdef NEED_GET_PATH_MAX
877-
unsigned int
878-
get_path_max (void)
879-
{
880-
static unsigned int value;
881-
882-
if (value == 0)
883-
{
884-
long x = pathconf ("/", _PC_PATH_MAX);
885-
if (x > 0)
886-
value = (unsigned int) x;
887-
else
888-
value = PATH_MAX;
889-
}
890-
891-
return value;
892-
}
893-
#endif
894-
895-
#if !HAVE_MEMPCPY
896-
void *
897-
mempcpy (void *dest, const void *src, size_t n)
898-
{
899-
return (char *) memcpy (dest, src, n) + n;
900-
}
901-
#endif
902-
903-
#if !HAVE_STPCPY
904-
char *
905-
stpcpy (char *dest, const char *src)
906-
{
907-
char *d = dest;
908-
const char *s = src;
909-
910-
do
911-
*d++ = *s;
912-
while (*s++ != '\0');
913-
914-
return d - 1;
915-
}
916-
#endif
917-
918-
#if !HAVE_STRTOLL
919-
# undef UNSIGNED
920-
# undef USE_NUMBER_GROUPING
921-
# undef USE_WIDE_CHAR
922-
# define QUAD 1
923-
# include <strtol.c>
924-
#endif
925-
926-
#if !HAVE_STRERROR
927-
char *
928-
strerror (int errnum)
929-
{
930-
static char msg[256];
931-
932-
#define SETMSG(_e, _m) case _e: strcpy(msg, _m); break
933-
934-
switch (errnum)
935-
{
936-
#ifdef EPERM
937-
SETMSG (EPERM , "Operation not permitted");
938-
#endif
939-
#ifdef ENOENT
940-
SETMSG (ENOENT , "No such file or directory");
941-
#endif
942-
#ifdef ESRCH
943-
SETMSG (ESRCH , "No such process");
944-
#endif
945-
#ifdef EINTR
946-
SETMSG (EINTR , "Interrupted system call");
947-
#endif
948-
#ifdef EIO
949-
SETMSG (EIO , "I/O error");
950-
#endif
951-
#ifdef ENXIO
952-
SETMSG (ENXIO , "No such device or address");
953-
#endif
954-
#ifdef E2BIG
955-
SETMSG (E2BIG , "Argument list too long");
956-
#endif
957-
#ifdef ENOEXEC
958-
SETMSG (ENOEXEC, "Exec format error");
959-
#endif
960-
#ifdef EBADF
961-
SETMSG (EBADF , "Bad file number");
962-
#endif
963-
#ifdef ECHILD
964-
SETMSG (ECHILD , "No child processes");
965-
#endif
966-
#ifdef EAGAIN
967-
SETMSG (EAGAIN , "Try again");
968-
#endif
969-
#ifdef ENOMEM
970-
SETMSG (ENOMEM , "Out of memory");
971-
#endif
972-
#ifdef EACCES
973-
SETMSG (EACCES , "Permission denied");
974-
#endif
975-
#ifdef EFAULT
976-
SETMSG (EFAULT , "Bad address");
977-
#endif
978-
#ifdef ENOTBLK
979-
SETMSG (ENOTBLK, "Block device required");
980-
#endif
981-
#ifdef EBUSY
982-
SETMSG (EBUSY , "Device or resource busy");
983-
#endif
984-
#ifdef EEXIST
985-
SETMSG (EEXIST , "File exists");
986-
#endif
987-
#ifdef EXDEV
988-
SETMSG (EXDEV , "Cross-device link");
989-
#endif
990-
#ifdef ENODEV
991-
SETMSG (ENODEV , "No such device");
992-
#endif
993-
#ifdef ENOTDIR
994-
SETMSG (ENOTDIR, "Not a directory");
995-
#endif
996-
#ifdef EISDIR
997-
SETMSG (EISDIR , "Is a directory");
998-
#endif
999-
#ifdef EINVAL
1000-
SETMSG (EINVAL , "Invalid argument");
1001-
#endif
1002-
#ifdef ENFILE
1003-
SETMSG (ENFILE , "File table overflow");
1004-
#endif
1005-
#ifdef EMFILE
1006-
SETMSG (EMFILE , "Too many open files");
1007-
#endif
1008-
#ifdef ENOTTY
1009-
SETMSG (ENOTTY , "Not a typewriter");
1010-
#endif
1011-
#ifdef ETXTBSY
1012-
SETMSG (ETXTBSY, "Text file busy");
1013-
#endif
1014-
#ifdef EFBIG
1015-
SETMSG (EFBIG , "File too large");
1016-
#endif
1017-
#ifdef ENOSPC
1018-
SETMSG (ENOSPC , "No space left on device");
1019-
#endif
1020-
#ifdef ESPIPE
1021-
SETMSG (ESPIPE , "Illegal seek");
1022-
#endif
1023-
#ifdef EROFS
1024-
SETMSG (EROFS , "Read-only file system");
1025-
#endif
1026-
#ifdef EMLINK
1027-
SETMSG (EMLINK , "Too many links");
1028-
#endif
1029-
#ifdef EPIPE
1030-
SETMSG (EPIPE , "Broken pipe");
1031-
#endif
1032-
#ifdef EDOM
1033-
SETMSG (EDOM , "Math argument out of domain of func");
1034-
#endif
1035-
#ifdef ERANGE
1036-
SETMSG (ERANGE , "Math result not representable");
1037-
#endif
1038-
default: sprintf (msg, "Unknown error %d", errnum); break;
1039-
}
1040-
1041-
return msg;
1042-
}
1043-
#endif

0 commit comments

Comments
 (0)