Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102929888
D28075.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
988 B
Referenced Files
None
Subscribers
None
D28075.diff
View Options
diff --git a/lib/libc/gen/dlfcn.c b/lib/libc/gen/dlfcn.c
--- a/lib/libc/gen/dlfcn.c
+++ b/lib/libc/gen/dlfcn.c
@@ -34,7 +34,9 @@
/*
* Linkage to services provided by the dynamic linker.
*/
+#include <sys/types.h>
#include <sys/mman.h>
+#include <machine/atomic.h>
#include <dlfcn.h>
#include <link.h>
#include <stddef.h>
@@ -256,8 +258,30 @@
int
_rtld_get_stack_prot(void)
{
+#ifndef IN_LIBDL
+ unsigned i;
+ int r;
+ static int ret;
+
+ r = atomic_load_int(&ret);
+ if (r != 0)
+ return (r);
- return (PROT_EXEC | PROT_READ | PROT_WRITE);
+ _once(&dl_phdr_info_once, dl_init_phdr_info);
+ r = PROT_EXEC | PROT_READ | PROT_WRITE;
+ for (i = 0; i < phdr_info.dlpi_phnum; i++) {
+ if (phdr_info.dlpi_phdr[i].p_type != PT_GNU_STACK)
+ continue;
+ r = PROT_READ | PROT_WRITE;
+ if ((phdr_info.dlpi_phdr[i].p_flags & PF_X) != 0)
+ r |= PROT_EXEC;
+ break;
+ }
+ atomic_store_int(&ret, r);
+ return (r);
+#else
+ return (0);
+#endif
}
#pragma weak _rtld_is_dlopened
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 19, 9:25 PM (21 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14723748
Default Alt Text
D28075.diff (988 B)
Attached To
Mode
D28075: libc: implement rtld_get_stack_prot() for real
Attached
Detach File
Event Timeline
Log In to Comment