From patchwork Tue Mar 16 17:28:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella via Libc-alpha X-Patchwork-Id: 401717 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp4505104jai; Tue, 16 Mar 2021 10:28:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9/uVsoCX4KW/BlDehJLq/0EcwwM44jPkcUT5WHmNmXWS2vJnR2C5I78wA99KABRAKnKFe X-Received: by 2002:a17:906:d9c9:: with SMTP id qk9mr30417790ejb.504.1615915716935; Tue, 16 Mar 2021 10:28:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615915716; cv=none; d=google.com; s=arc-20160816; b=Elzrbt848h3rpiJMjIYxwALlD+uGNMyAUlNQ1bHjXZlGdoiskH+v3ObMM8PaYnTwiW 5B+bNdFppKtEV0lmOmYlp4WCIittjNZEz/2vRUbg4xlogfhEtLyqms9z1pbS0pQY5Vdw tmO8B+pZGaQPevVJxCu4WvtEgucuUMsu0hytmbcitZoxo4PMLqQbYGV92I7r9P7MoxjH bdFylaa+2Gq9hTlibdAfOq1zZWsmzJLCy5mAl6ghrGmW6jtYzK6MJmHUflh/zK/pY6X/ Hl5M7ubzllxfz3uQjzJYupnfZXuFx5xs5S4UQ0Vs2EuQWDNTUGPN97vmtZpR+EA8TvcY DSCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :user-agent:date:message-id:references:in-reply-to:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=xRRNenQTGs/uwGsLMoPrIFdVk0neS0LRa06O4Nnw7DY=; b=KRiF/QyjMM7bkaGDUbwyNOyLzAR2uc6E+A7RtMyF8KblmxjoTu1VuEjpkj3Il8bMaa wkx4SFIUPa4hpvZ7wttGzKK6p+m0IT/S5vRyWbuY8Y5bjpSTXQXQnSyquRsKql88TbNx z4etLLxSBtsEaBSvtwN1f8xpNPOeUPoOaZbf5i6e6OvAHRIIakb5S61dnHDE3HAYAGGJ M+INUmRSoCPIgEBXAdaTaDzrUbVftl9PeDRX8RysSo6QASviJIE6o7I7y0Ec/gQdfRc4 DD/KM/Z97AbEZDkaj0fkN9oD6F+0fTRdZ0rYEI4+HUiJfv9Cx6tw0484+0/nuDGicG55 NIQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=PPAISf9F; spf=pass (google.com: domain of libc-alpha-bounces@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom=libc-alpha-bounces@sourceware.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Return-Path: Received: from sourceware.org ([8.43.85.97]) by mx.google.com with ESMTPS id n5si14605480eji.285.2021.03.16.10.28.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 10:28:36 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=PPAISf9F; spf=pass (google.com: domain of libc-alpha-bounces@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom=libc-alpha-bounces@sourceware.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BD4493850407; Tue, 16 Mar 2021 17:28:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BD4493850407 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1615915715; bh=xRRNenQTGs/uwGsLMoPrIFdVk0neS0LRa06O4Nnw7DY=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=PPAISf9Fe2rSRNMqgy3RclQMywP17hro1mGvsz89NvOt/XAA73rAD2WCvay3T/IF+ Z3lcE1K915omz0VUHkVYHWqZOQiC+kA1osPZNP0/I9YjATW1jz6VpsxrkXvTs1CpF6 kMOCkWjLGFaTnxxH8gUbxUL950Ods3DI3czk2Thw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id CB8C1385480F for ; Tue, 16 Mar 2021 17:28:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CB8C1385480F Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-510-zhW9D5O6PpyhHmbPPpGNSA-1; Tue, 16 Mar 2021 13:28:31 -0400 X-MC-Unique: zhW9D5O6PpyhHmbPPpGNSA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A9FD6801596 for ; Tue, 16 Mar 2021 17:28:30 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-112-254.ams2.redhat.com [10.36.112.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0C5D75D9C0 for ; Tue, 16 Mar 2021 17:28:29 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH v3 06/37] x86: Restore compile-time check for shadow stack pointer in longjmp In-Reply-To: References: Message-Id: Date: Tue, 16 Mar 2021 18:28:38 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Adhemerval Zanella via Libc-alpha Reply-To: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: Adhemerval Zanella --- sysdeps/unix/sysv/linux/x86/longjmp.c | 39 +++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/x86/longjmp.c -- 2.29.2 diff --git a/sysdeps/unix/sysv/linux/x86/longjmp.c b/sysdeps/unix/sysv/linux/x86/longjmp.c new file mode 100644 index 0000000000..1cc8b8dfad --- /dev/null +++ b/sysdeps/unix/sysv/linux/x86/longjmp.c @@ -0,0 +1,39 @@ +/* __libc_siglongjmp for Linux/x86 + Copyright (C) 2018-2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#include +#include + +#ifdef __x86_64__ +# define SHADOW_STACK_POINTER_SIZE 8 +#else +# define SHADOW_STACK_POINTER_SIZE 4 +#endif + +/* Assert that the priv field in struct pthread_unwind_buf has space + to store shadow stack pointer. */ +_Static_assert ((offsetof (struct pthread_unwind_buf, priv) + <= SHADOW_STACK_POINTER_OFFSET) + && ((offsetof (struct pthread_unwind_buf, priv) + + sizeof (((struct pthread_unwind_buf *) 0)->priv)) + >= (SHADOW_STACK_POINTER_OFFSET + + SHADOW_STACK_POINTER_SIZE)), + "Shadow stack pointer is not within private storage " + "of pthread_unwind_buf.");