aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Richardson <arichardson@FreeBSD.org>2021-06-22 08:09:44 +0000
committerAlex Richardson <arichardson@FreeBSD.org>2021-06-22 08:10:48 +0000
commite3be51b2bc7cb41eb9a238cced2ee650d9bb2d41 (patch)
treeda3a176f0a6218cf521b71f02a96c421b3939819
parentd98a4eb807e972ac207264043ba3c50ba94f5df5 (diff)
downloadsrc-e3be51b2bc7cb41eb9a238cced2ee650d9bb2d41.tar.gz
src-e3be51b2bc7cb41eb9a238cced2ee650d9bb2d41.zip
rtld-elf: Check the return value of obj_enforce_relro()
The mprotect() call was failing on CheriBSD when changing rtld's relro page permissions due to missing CHERI capability permissions on the mprotect() argument but did not report an error since the return value was being ignored. It should never fail on any supported FreeBSD architecture, but checking the return value seems like a good sanity check to me. Reviewed By: kib, imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30820
-rw-r--r--libexec/rtld-elf/rtld.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index 9897248bffbb..f60872f12c52 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -2288,7 +2288,8 @@ init_rtld(caddr_t mapbase, Elf_Auxinfo **aux_info)
obj_rtld.path = xstrdup(ld_path_rtld);
parse_rtld_phdr(&obj_rtld);
- obj_enforce_relro(&obj_rtld);
+ if (obj_enforce_relro(&obj_rtld) == -1)
+ rtld_die();
r_debug.r_version = R_DEBUG_VERSION;
r_debug.r_brk = r_debug_state;