git: 58137266b6ea - stable/13 - rtld-elf: Check the return value of obj_enforce_relro()

Alex Richardson arichardson at FreeBSD.org
Mon Jul 5 09:47:12 UTC 2021


The branch stable/13 has been updated by arichardson:

URL: https://cgit.FreeBSD.org/src/commit/?id=58137266b6eab0a117878cb40f58bd693ea2396d

commit 58137266b6eab0a117878cb40f58bd693ea2396d
Author:     Alex Richardson <arichardson at FreeBSD.org>
AuthorDate: 2021-06-22 08:09:44 +0000
Commit:     Alex Richardson <arichardson at FreeBSD.org>
CommitDate: 2021-07-05 09:46:12 +0000

    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
    
    (cherry picked from commit e3be51b2bc7cb41eb9a238cced2ee650d9bb2d41)
---
 libexec/rtld-elf/rtld.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index 34c42969c779..42abd8391386 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -2280,7 +2280,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;


More information about the dev-commits-src-all mailing list