From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by sourceware.org (Postfix) with ESMTPS id 3B7013858D38 for ; Sat, 16 Mar 2024 15:18:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3B7013858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3B7013858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::b2f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710602330; cv=none; b=cCWBvzwSwQc4bmUEF2mNayMcSci+Nb/TLwxKPI5HArvAnIwzcabJGG0eRjmnTIeRmnPzi4RU/JdHMpIzIznlbB2qiEBeSicjtDq32VmW3bqVeMMy6tqMsGGLggnYEtwKlU/6gxmu6HQ+UTclzd7uepQFgzyY5P4IU4ch3JEDuJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710602330; c=relaxed/simple; bh=grdWCdUFmV7QqoJKVi41a1zmk/mliYZY3e1CL7+T4WM=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=H4dWilBDtmUczAH6y5kx1jx0Vp34WQh7+L+a2zjfG5bbTF9UEh3swI+5yGiEekgdohrJoR/enSHXRJOBoamJqVaKBJFz7ZNFO2tX/W0x3l9nB1qNDMnu14oGBld7UortnIqiRMPpKgdaY4qX7HsvanCdrrbGskcy/b0tgzTT1Dw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yb1-xb2f.google.com with SMTP id 3f1490d57ef6-dc742543119so2677662276.0 for ; Sat, 16 Mar 2024 08:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710602327; x=1711207127; darn=sourceware.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=xjdt2gPJBnPtFZj60snlGJxIjkHHDBqsm6tN9UXY8kM=; b=hmhFsyJZ9BFrD3tqa1QwaXgjFu8MNpVVe0quCG0fuir79B+ZJD5oaCV+JP3ItNgIZo n8EfXvquWhXnHpxrkPSeI0ReCXjiTvnWLi6maoSrKajxFZUBfCrDSGk14zPNSVekheri 0DJe8sRIlvAIuCX0fi4FkOotcVjA4mb4QP8z+SFoxfiPJFa/iQ//enjuR0SP0tQGZC2A 8Q1h/yMacaRyImuYEIO6IjtvhhnVxcg5ENdZsdGdI8NHTl0UmCEvjKzeMYAJLeY42R9B kdhM7kqTTWriU3SdHyBWZ+0LgoYWrd/Z34Bo6Epi7Rd5ivD+vrdf3YzvpyWKqLiWNVZf TXBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710602327; x=1711207127; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xjdt2gPJBnPtFZj60snlGJxIjkHHDBqsm6tN9UXY8kM=; b=fodZUm8OhMEfqJIMES9e+5MOM/8YcBRYVzzNvekm8CXDHmrYCRAEWGAEAOYCojXKXe P6hU9K4geG+xLeRV2s8557UmaytEV/GjeER7iPEja8pGRW6HTIC/evKO0jOggJ7b4/K2 IAKoFLL7cSCfzyQrrOGWdSTSPUbSWDdNvnoW6EwSl74M0Mv/8qh/kMR2qOjgmzpJct7R iDk2zMRtrnwSXwAPlh0KQ1Vl51vzvcn/k3eEdjg5B6rt4saf2+Hl2oX6hi7xV2S6y0x4 T+uwr2c4KBrreIAhIdj3xexCEZfDmJQYSuFDvWot9AUAPHoB7OVrMA4/T+M/CpG04KBs a2kQ== X-Gm-Message-State: AOJu0Yyyw9W0NweEwUwsPdnRZgLr8mQnkukfVev5YWE+MsaERNJRWY/k 9b8oFhCVMHC4oaOniMJ9euOJEOOKSU5cBfTIhIUevcXiZRZwJT72OIuQbPp7j4iJ5pehMTgDXNn AEGBewpmG7clk+MUk6FCyvJCLFiXCZhQO X-Google-Smtp-Source: AGHT+IFVcTrwjEq5aUsNeRONznpSc+GcIndQMQBXGzBPLeH+QUplovRF5u8Ve3bT2tp5A3XXg65PsApxzLlQebBDSME= X-Received: by 2002:a0d:d556:0:b0:60a:c510:89f1 with SMTP id x83-20020a0dd556000000b0060ac51089f1mr6984599ywd.19.1710602327547; Sat, 16 Mar 2024 08:18:47 -0700 (PDT) MIME-Version: 1.0 References: <878r2ifdrx.fsf@oldenburg.str.redhat.com> <87y1aidxq6.fsf@oldenburg.str.redhat.com> In-Reply-To: <87y1aidxq6.fsf@oldenburg.str.redhat.com> From: "H.J. Lu" Date: Sat, 16 Mar 2024 08:18:11 -0700 Message-ID: Subject: Re: [PATCH] x86-64: Stack alignment in _dl_tlsdesc_dynamic and red zone usage (bug 31501) To: Florian Weimer Cc: libc-alpha@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3013.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Sat, Mar 16, 2024 at 8:04=E2=80=AFAM Florian Weimer = wrote: > > * H. J. Lu: > > > On Sat, Mar 16, 2024 at 7:43=E2=80=AFAM H.J. Lu w= rote: > >> > >> On Sat, Mar 16, 2024 at 7:37=E2=80=AFAM H.J. Lu = wrote: > >> > > >> > On Sat, Mar 16, 2024 at 7:33=E2=80=AFAM Florian Weimer wrote: > >> > > > >> > > In sysdeps/x86_64/dl-tlsdesc-dynamic.h, the stack pointer is > >> > > realigned for some variants (notably _dl_tlsdesc_dynamic_xsavec). > >> > > This realignment does not take into account that the function has > >> > > already used part of the red zone at this point, thus clobbering > >> > > the initally saved register values located there if the stack > >> > > alignment inherited from the caller is unfortunate. > >> > > > >> > > (Note: I do not know to write a good test case for this in the exi= sting > >> > > framework. We saw this as a random LTO plugin crash when building= GCC > >> > > with -mtls-dialect=3Dgnu2. The existing tests on pass on x86_64-l= inux-gnu > >> > > with this change here.) > > > > We should try to find a testcase. Can you provide a backtrace when it > > happens? It should be possible to write a testcase with the backtrace. > > In my reproducer, when %rbx is about to be clobbered, I see > (%rsp % 64) =3D=3D 8 at the start of _dl_tlsdesc_dynamic_xsavec. > > The %rbx register does not get clobbered if (%rsp % 64) =3D=3D 56. > > Does this help? > Yes. I am working on a testcase. --=20 H.J.