]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/glibc-2.38/0036-x86-64-Fix-the-dtv-field-load-for-x32-BZ-31184.patch
glibc: Import latest patches from upstream
[ipfire-2.x.git] / src / patches / glibc-2.38 / 0036-x86-64-Fix-the-dtv-field-load-for-x32-BZ-31184.patch
CommitLineData
a61a21ef
MT
1From 35ea7549751d4f13a28c732e6ad68204f5e60a06 Mon Sep 17 00:00:00 2001
2From: "H.J. Lu" <hjl.tools@gmail.com>
3Date: Wed, 20 Dec 2023 16:31:43 -0800
4Subject: [PATCH 36/44] x86-64: Fix the dtv field load for x32 [BZ #31184]
5
6On x32, I got
7
8FAIL: elf/tst-tlsgap
9
10$ gdb elf/tst-tlsgap
11...
12open tst-tlsgap-mod1.so
13
14Thread 2 "tst-tlsgap" received signal SIGSEGV, Segmentation fault.
15[Switching to LWP 2268754]
16_dl_tlsdesc_dynamic () at ../sysdeps/x86_64/dl-tlsdesc.S:108
17108 movq (%rsi), %rax
18(gdb) p/x $rsi
19$4 = 0xf7dbf9005655fb18
20(gdb)
21
22This is caused by
23
24_dl_tlsdesc_dynamic:
25 _CET_ENDBR
26 /* Preserve call-clobbered registers that we modify.
27 We need two scratch regs anyway. */
28 movq %rsi, -16(%rsp)
29 movq %fs:DTV_OFFSET, %rsi
30
31Since the dtv field in TCB is a pointer, %fs:DTV_OFFSET is a 32-bit
32location, not 64-bit. Load the dtv field to RSI_LP instead of rsi.
33This fixes BZ #31184.
34
35(cherry picked from commit 3502440397bbb840e2f7223734aa5cc2cc0e29b6)
36---
37 NEWS | 1 +
38 sysdeps/x86_64/dl-tlsdesc.S | 2 +-
39 2 files changed, 2 insertions(+), 1 deletion(-)
40
41diff --git a/NEWS b/NEWS
42index 5ac488bf9b..71057e4793 100644
43--- a/NEWS
44+++ b/NEWS
45@@ -37,6 +37,7 @@ The following bugs are resolved with this release:
46 [30804] F_GETLK, F_SETLK, and F_SETLKW value change for powerpc64 with
47 -D_FILE_OFFSET_BITS=64
48 [30842] Stack read overflow in getaddrinfo in no-aaaa mode (CVE-2023-4527)
49+ [31184] FAIL: elf/tst-tlsgap
50
51 \f
52 Version 2.38
53diff --git a/sysdeps/x86_64/dl-tlsdesc.S b/sysdeps/x86_64/dl-tlsdesc.S
54index 5593897e29..c4823547d7 100644
55--- a/sysdeps/x86_64/dl-tlsdesc.S
56+++ b/sysdeps/x86_64/dl-tlsdesc.S
57@@ -102,7 +102,7 @@ _dl_tlsdesc_dynamic:
58 /* Preserve call-clobbered registers that we modify.
59 We need two scratch regs anyway. */
60 movq %rsi, -16(%rsp)
61- movq %fs:DTV_OFFSET, %rsi
62+ mov %fs:DTV_OFFSET, %RSI_LP
63 movq %rdi, -8(%rsp)
64 movq TLSDESC_ARG(%rax), %rdi
65 movq (%rsi), %rax
66--
672.39.2
68