Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F158857047
D44195.id135332.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D44195.id135332.diff
View Options
diff --git a/include/spawn.h b/include/spawn.h
--- a/include/spawn.h
+++ b/include/spawn.h
@@ -59,6 +59,7 @@
#define POSIX_SPAWN_SETSCHEDULER 0x08
#define POSIX_SPAWN_SETSIGDEF 0x10
#define POSIX_SPAWN_SETSIGMASK 0x20
+#define POSIX_SPAWN_DISABLE_ASLR_NP 0x40
__BEGIN_DECLS
/*
diff --git a/lib/libc/gen/posix_spawn.c b/lib/libc/gen/posix_spawn.c
--- a/lib/libc/gen/posix_spawn.c
+++ b/lib/libc/gen/posix_spawn.c
@@ -28,6 +28,7 @@
#include "namespace.h"
#include <sys/param.h>
+#include <sys/procctl.h>
#include <sys/queue.h>
#include <sys/wait.h>
@@ -91,7 +92,7 @@
process_spawnattr(const posix_spawnattr_t sa)
{
struct sigaction sigact = { .sa_flags = 0, .sa_handler = SIG_DFL };
- int i;
+ int aslr, i;
/*
* POSIX doesn't really describe in which order everything
@@ -139,6 +140,13 @@
}
}
+ /* Disable ASLR. */
+ if ((sa->sa_flags & POSIX_SPAWN_DISABLE_ASLR_NP) != 0) {
+ aslr = PROC_ASLR_FORCE_DISABLE;
+ if (procctl(P_PID, 0, PROC_ASLR_CTL, &aslr) != 0)
+ return (errno);
+ }
+
return (0);
}
@@ -629,6 +637,11 @@
int
posix_spawnattr_setflags(posix_spawnattr_t *sa, short flags)
{
+ if ((flags & ~(POSIX_SPAWN_RESETIDS | POSIX_SPAWN_SETPGROUP |
+ POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER |
+ POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK |
+ POSIX_SPAWN_DISABLE_ASLR_NP)) != 0)
+ return (EINVAL);
(*sa)->sa_flags = flags;
return (0);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jun 7, 10:38 PM (2 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33803135
Default Alt Text
D44195.id135332.diff (1 KB)
Attached To
Mode
D44195: Add POSIX_SPAWN_DISABLE_ASLR_NP
Attached
Detach File
Event Timeline
Log In to Comment