git: b9eaf9b7cef2 - main - libc: Reject static ELF exectables with PT_TLS segments were filesz > memsz
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 31 Jul 2026 17:57:37 UTC
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;