Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Aug 2021 09:32:36 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 02e46073bd8a - stable/13 - rtld: Round down relro_size
Message-ID:  <202108200932.17K9WarF010363@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=02e46073bd8a98a8c3adc96b1885b5e47ebb3d4f

commit 02e46073bd8a98a8c3adc96b1885b5e47ebb3d4f
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-08-12 02:45:15 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2021-08-20 09:31:46 +0000

    rtld: Round down relro_size
    
    (cherry picked from commit c9f833abf1d76ea194b82caafa06a0627790ad97)
---
 libexec/rtld-elf/map_object.c | 3 ++-
 libexec/rtld-elf/rtld.c       | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libexec/rtld-elf/map_object.c b/libexec/rtld-elf/map_object.c
index 273e477fbda5..b725fe93b8f6 100644
--- a/libexec/rtld-elf/map_object.c
+++ b/libexec/rtld-elf/map_object.c
@@ -325,7 +325,8 @@ map_object(int fd, const char *path, const struct stat *sb)
     }
     obj->stack_flags = stack_flags;
     obj->relro_page = obj->relocbase + trunc_page(relro_page);
-    obj->relro_size = round_page(relro_size);
+    obj->relro_size = trunc_page(relro_page + relro_size) -
+      trunc_page(relro_page);
     if (note_start < note_end)
 	digest_notes(obj, note_start, note_end);
     if (note_map != NULL)
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index f60872f12c52..eaad89339d07 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -1557,7 +1557,8 @@ digest_phdr(const Elf_Phdr *phdr, int phnum, caddr_t entry, const char *path)
 
 	case PT_GNU_RELRO:
 	    obj->relro_page = obj->relocbase + trunc_page(ph->p_vaddr);
-	    obj->relro_size = round_page(ph->p_memsz);
+	    obj->relro_size = trunc_page(ph->p_vaddr + ph->p_memsz) -
+	      trunc_page(ph->p_vaddr);
 	    break;
 
 	case PT_NOTE:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108200932.17K9WarF010363>