public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: H.J. Lu <hjl@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc/release/2.37/master] x86-64: Fix the dtv field load for x32 [BZ #31184]
Date: Sat, 23 Dec 2023 17:00:39 +0000 (GMT)	[thread overview]
Message-ID: <20231223170039.DCD713858C98@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8bd00f5b6d42ee89f61b5f15624788ad1aed917e

commit 8bd00f5b6d42ee89f61b5f15624788ad1aed917e
Author: H.J. Lu <hjl.tools@gmail.com>
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 a2f7c96b4f..3634e0c8b5 100644
--- a/NEWS
+++ b/NEWS
@@ -52,6 +52,7 @@ The following bugs are resolved with this release:
   [30477] libc: [RISCV]: time64 does not work on riscv32
   [30515] _dl_find_object incorrectly returns 1 during early startup
   [30842] Stack read overflow in getaddrinfo in no-aaaa mode (CVE-2023-4527)
+  [31184] FAIL: elf/tst-tlsgap
 \f
 Version 2.37
 
diff --git a/sysdeps/x86_64/dl-tlsdesc.S b/sysdeps/x86_64/dl-tlsdesc.S
index 5593897e29..c4823547d7 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

                 reply	other threads:[~2023-12-23 17:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231223170039.DCD713858C98@sourceware.org \
    --to=hjl@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).