Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 Jul 2026 17:57:37 +0000
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: b9eaf9b7cef2 - main - libc: Reject static ELF exectables with PT_TLS segments were filesz > memsz
Message-ID:  <6a6ce211.3f35c.64cfbffb@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by jhb:

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

commit b9eaf9b7cef25228e8c20e3819f1b7be94f486aa
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2026-07-31 17:52:34 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2026-07-31 17:52:34 +0000

    libc: Reject static ELF exectables with PT_TLS segments were filesz > memsz
    
    Reviewed by:    jrtc27
    Differential Revision:  https://reviews.freebsd.org/D58558
---
 lib/libc/gen/tls.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/libc/gen/tls.c b/lib/libc/gen/tls.c
index b26b13d45589..e9f256d5e369 100644
--- a/lib/libc/gen/tls.c
+++ b/lib/libc/gen/tls.c
@@ -435,6 +435,10 @@ _init_tls(void)
 
 	for (i = 0; (unsigned) i < phnum; i++) {
 		if (phdr[i].p_type == PT_TLS) {
+			if (phdr[i].p_memsz < phdr[i].p_filesz) {
+				tls_msg("_init_tls: invalid PT_TLS segment.\n");
+				abort();
+			}
 			libc_tls_static_space = roundup2(phdr[i].p_memsz,
 			    phdr[i].p_align);
 			libc_tls_init_size = phdr[i].p_filesz;


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a6ce211.3f35c.64cfbffb>