From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 87DE33858D37 for ; Sat, 16 Mar 2024 15:04:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 87DE33858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 87DE33858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710601484; cv=none; b=YNNDyp8jGZavDgwSPJqkZAqolZ+XrmQIjo/UFfljmha1h2Jh94Zuq2fwQ89FDEGIAoHo7o0loNdkI6Zso4DT+QbwEvNqTHTqJVk7eG+5Me+swboqOqQ0xT3LErb30aIIesdAJOVMZvZ68fmooEnG8FyvqYmZ9WP20oiC3TZbxTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710601484; c=relaxed/simple; bh=hijWmztlXXl9IHrmITmyakUWKFb0OVoYCAAuejbtufw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=NuZYiCbh0ZiMiY6kz1o4Q3h92b1EHPRcXAE5Do1S/R0/g9T8x7V+uzOoqb7iiDmsLCNtiT/T2PWnrqGSSiq/hsoSaDDgfAeLEFKoRRQOqOIaQh5PJZNamvJpTWKWL5Ilg7N7H1WvVHBFiQBy2bCPq566vkMbku/I7yoydmqIvm8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710601482; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kawhSHDxGntPYwxDCt8duw5ZKUvtGg1M7niUS5HjONQ=; b=SfNbdf+nHXmOCub7fVZR9BayONZTdFwyMdUaInEFNWSQzB+TAW+luVr50fokUhuqySqDZl Lr1fPbgdBYnsBBh2gzrRgAMBKJaNNyJf5/5i5zadAlyzhJxzG3hfaJ1xgjH1rQOf5WDZnk WUwjz2ABlFHoswmF1c53oU+bGZu3b8k= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-78-YKjFKq-sMvu_Fvh_50CODg-1; Sat, 16 Mar 2024 11:04:40 -0400 X-MC-Unique: YKjFKq-sMvu_Fvh_50CODg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 06ABC3C0C8AC; Sat, 16 Mar 2024 15:04:40 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7D2AD2166B31; Sat, 16 Mar 2024 15:04:39 +0000 (UTC) From: Florian Weimer To: "H.J. Lu" Cc: libc-alpha@sourceware.org Subject: Re: [PATCH] x86-64: Stack alignment in _dl_tlsdesc_dynamic and red zone usage (bug 31501) References: <878r2ifdrx.fsf@oldenburg.str.redhat.com> Date: Sat, 16 Mar 2024 16:04:33 +0100 In-Reply-To: (H. J. Lu's message of "Sat, 16 Mar 2024 07:47:04 -0700") Message-ID: <87y1aidxq6.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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: * H. J. Lu: > On Sat, Mar 16, 2024 at 7:43=E2=80=AFAM H.J. Lu wro= te: >> >> On Sat, Mar 16, 2024 at 7:37=E2=80=AFAM H.J. Lu wr= ote: >> > >> > 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 exist= ing >> > > framework. We saw this as a random LTO plugin crash when building G= CC >> > > with -mtls-dialect=3Dgnu2. The existing tests on pass on x86_64-lin= ux-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? Thanks, Florian