From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1039) id 4EADE3858D33; Sat, 23 Dec 2023 17:36:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4EADE3858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1703353012; bh=NxnKFo0maVfFLZ/M6ikgQ5xL2chRJBdyiZquvD7pcXI=; h=From:To:Subject:Date:From; b=xmvliEblPuE48Wg0cbajNvLTVfraAdT4zrriH+F6DyaNvgwwMVw1TWuZuvaLS8mq7 oN0PLZHzZjX3O5Wce7LMbyvexapR3bUjWBxrJqfFVhhZivuOLmlc1TB6m+npL112yI 8nTcI7pkJrP5+/h7GYVWU/IVmOE40Ro9aVLA718w= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: H.J. Lu To: glibc-cvs@sourceware.org Subject: [glibc/release/2.35/master] x86-64: Fix the dtv field load for x32 [BZ #31184] X-Act-Checkin: glibc X-Git-Author: H.J. Lu X-Git-Refname: refs/heads/release/2.35/master X-Git-Oldrev: 5f08ec08d03930050befec16fcc6264fa00c66fe X-Git-Newrev: 2d87262c1c4ed877a51a4689db0ac2e08fba2f43 Message-Id: <20231223173652.4EADE3858D33@sourceware.org> Date: Sat, 23 Dec 2023 17:36:52 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=2d87262c1c4ed877a51a4689db0ac2e08fba2f43 commit 2d87262c1c4ed877a51a4689db0ac2e08fba2f43 Author: H.J. Lu Date: Wed Dec 20 16:31:43 2023 -0800 x86-64: Fix the dtv field load for x32 [BZ #31184] On x32, I got FAIL: elf/tst-tlsgap $ gdb elf/tst-tlsgap ... open tst-tlsgap-mod1.so Thread 2 "tst-tlsgap" received signal SIGSEGV, Segmentation fault. [Switching to LWP 2268754] _dl_tlsdesc_dynamic () at ../sysdeps/x86_64/dl-tlsdesc.S:108 108 movq (%rsi), %rax (gdb) p/x $rsi $4 = 0xf7dbf9005655fb18 (gdb) This is caused by _dl_tlsdesc_dynamic: _CET_ENDBR /* Preserve call-clobbered registers that we modify. We need two scratch regs anyway. */ movq %rsi, -16(%rsp) movq %fs:DTV_OFFSET, %rsi Since the dtv field in TCB is a pointer, %fs:DTV_OFFSET is a 32-bit location, not 64-bit. Load the dtv field to RSI_LP instead of rsi. This fixes BZ #31184. (cherry picked from commit 3502440397bbb840e2f7223734aa5cc2cc0e29b6) Diff: --- NEWS | 1 + sysdeps/x86_64/dl-tlsdesc.S | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 70936f90a9..e4777c13da 100644 --- a/NEWS +++ b/NEWS @@ -84,6 +84,7 @@ The following bugs are resolved with this release: [30515] _dl_find_object incorrectly returns 1 during early startup [30804] F_GETLK, F_SETLK, and F_SETLKW value change for powerpc64 with -D_FILE_OFFSET_BITS=64 + [31184] FAIL: elf/tst-tlsgap Security related changes: diff --git a/sysdeps/x86_64/dl-tlsdesc.S b/sysdeps/x86_64/dl-tlsdesc.S index 0db2cb4152..706856e095 100644 --- a/sysdeps/x86_64/dl-tlsdesc.S +++ b/sysdeps/x86_64/dl-tlsdesc.S @@ -102,7 +102,7 @@ _dl_tlsdesc_dynamic: /* Preserve call-clobbered registers that we modify. We need two scratch regs anyway. */ movq %rsi, -16(%rsp) - movq %fs:DTV_OFFSET, %rsi + mov %fs:DTV_OFFSET, %RSI_LP movq %rdi, -8(%rsp) movq TLSDESC_ARG(%rax), %rdi movq (%rsi), %rax