diff options
| author | John Baldwin <jhb@FreeBSD.org> | 2026-07-31 17:52:34 +0000 |
|---|---|---|
| committer | John Baldwin <jhb@FreeBSD.org> | 2026-07-31 17:52:34 +0000 |
| commit | b9eaf9b7cef25228e8c20e3819f1b7be94f486aa (patch) | |
| tree | d95c6c57c14f3b9beb48a60dda21fa5972faf22d | |
| parent | 535eb24d8451bad8de745937018800df1895a9aa (diff) | |
libc: Reject static ELF exectables with PT_TLS segments were filesz > memsz
Reviewed by: jrtc27
Differential Revision: https://reviews.freebsd.org/D58558
| -rw-r--r-- | lib/libc/gen/tls.c | 4 |
1 files changed, 4 insertions, 0 deletions
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; |
