From patchwork Wed Dec 6 17:19:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 81538 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 855753858002 for ; Wed, 6 Dec 2023 17:21:23 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by sourceware.org (Postfix) with ESMTPS id E60983857C69 for ; Wed, 6 Dec 2023 17:20:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E60983857C69 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 E60983857C69 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701883219; cv=none; b=GcpIyBkyjo4jeUi1Z8/VvoBvDoy1GZefx/CfeVHN+MxMsTtRHavCqZZvywbrzZ7/zuRT/bWuxfE+CAT4MDt+EibLW1pELqlrF/bCO9aaTd4UEsVmPelfEqDM49B30x5tywD2sRl6/Gnr3C8lK4ZzhmnRwc0nnPuiRK8+wDK8ZKk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701883219; c=relaxed/simple; bh=wV7BjJu894nE4AYl90sNAjHFW+N7Ska8uveZsjZHLHw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ugqf2Wswn4u1b/kd6NRF98oC+Uc6vKd43IyIQv6DPR03+U0x2vpvTCvLk7uY+9CBG6F1Y0unzQp+U1wxlFZ0QLlcIvXwWStz0/87057TkQ9wzeotUGhPYfjtK83FTsiUg4IiT8mIrMCdmMc166uKXlSQC081RT4zG20FmoOUrjM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-28647f4ebd9so38436a91.3 for ; Wed, 06 Dec 2023 09:20:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701883216; x=1702488016; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GOSE4t1msgsYWOi+j3WV+bBpkEvf1QHzZChc7NU2YRM=; b=cOXJzpfGKhsTTOPc9P349wfG1K4dpDW3dneN8vwDX7GgEXHB9Ud3UbL6N8ZOlIQ+fZ mJzzpOFFKfnonRU2HzbpIvJlAt57ji/e4E2QMwHke1lXmGyLAPMa1g3uqrVhv/PUpcvC mE+sdw4kx+yoW+O53EpD0bgkn32h7LwQ8mTBj8VClXx6Qxmj4WGIYdDZejJeS6TT8c0g sOge3v8ZHmdZNv8lk1IRD0c2ryB5TIJ3gKnKobGmI1PwlTxp3TFd/KqFr58ixU565dWt xWd9+pFNgJU3ROFW05CtwY/8R5OgKCF9ZWEasbtTEhzpNcD8Vx1/7fH0ODfWtPCFtEsu +czQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701883216; x=1702488016; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GOSE4t1msgsYWOi+j3WV+bBpkEvf1QHzZChc7NU2YRM=; b=C/RIe4BvHKmdixxvlCSz2nsAtUlOIPYsEI6YkkiWElJRcl494/aJ9o65Rh9MxdkLVW iMLRlrgey/XBk7Dxs4zVaSiuLOk03s412y+A/OogD2rbq095wV0gVii/GjOLGrQ5lJPF M89AtGdjXMdRKTHyubbJy29WhfuV4zMrHrb066xAnZ56XCY0HS5xqtYIrQOhj7pfnhsj Ug/8e31t71lpGjXoXa9gT84q5vHKKG4Mce36liMH042WIFBh8/qb7j0EtE9bixjzF+Ja Jol1nofvcjvKkAFBDSc2km1oJnghDPHn3p37Y3+IrIWjdXwrImu6Newj6eME4ycSFTYt pe3A== X-Gm-Message-State: AOJu0Ywy0wr7tcbMq9YPNR9qNq3LraP+EskSPWVXy8lp9p7fgyp9+P5S wX/44kZ9s00jSjQ7LmXn2ex4Aeijh30= X-Google-Smtp-Source: AGHT+IGZA/048B8tlvq6RCB7nInTffi5+2h/QYfwqt+klfFpWhhuXC9Qw9pPGPN1X9xLFYfCRFYyOQ== X-Received: by 2002:a17:90b:1241:b0:286:6cc1:5fce with SMTP id gx1-20020a17090b124100b002866cc15fcemr1031711pjb.81.1701883215842; Wed, 06 Dec 2023 09:20:15 -0800 (PST) Received: from gnu-cfl-3.localdomain ([172.59.161.253]) by smtp.gmail.com with ESMTPSA id d7-20020a17090b004700b002864c14063fsm80973pjt.20.2023.12.06.09.20.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 09:20:14 -0800 (PST) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id 8A1F174062F; Wed, 6 Dec 2023 09:20:10 -0800 (PST) From: "H.J. Lu" To: libc-alpha@sourceware.org Cc: rick.p.edgecombe@intel.com Subject: [PATCH 06/17] x86/cet: Add tests for GLIBC_TUNABLES=glibc.cpu.hwcaps=-SHSTK Date: Wed, 6 Dec 2023 09:19:59 -0800 Message-ID: <20231206172010.1023415-7-hjl.tools@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231206172010.1023415-1-hjl.tools@gmail.com> References: <20231206172010.1023415-1-hjl.tools@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3025.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Verify that GLIBC_TUNABLES=glibc.cpu.hwcaps=-SHSTK turns off shadow stack properly. --- sysdeps/x86/Makefile | 7 +++++++ sysdeps/x86/tst-shstk-legacy-1c-static.c | 1 + sysdeps/x86/tst-shstk-legacy-1c.c | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 sysdeps/x86/tst-shstk-legacy-1c-static.c create mode 100644 sysdeps/x86/tst-shstk-legacy-1c.c diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile index 580c3ecdc5..5f1414fba3 100644 --- a/sysdeps/x86/Makefile +++ b/sysdeps/x86/Makefile @@ -137,10 +137,13 @@ tests += \ tst-shstk-legacy-1a-static \ tst-shstk-legacy-1b \ tst-shstk-legacy-1b-static \ + tst-shstk-legacy-1c \ + tst-shstk-legacy-1c-static \ # tests tests-static += \ tst-shstk-legacy-1a-static \ tst-shstk-legacy-1b-static \ + tst-shstk-legacy-1c-static \ # tests-static extra-objs += \ tst-shstk-legacy-1-extra.o \ @@ -227,6 +230,10 @@ $(objpfx)tst-shstk-legacy-1a: $(objpfx)tst-shstk-legacy-1-extra.o $(objpfx)tst-shstk-legacy-1a-static: $(objpfx)tst-shstk-legacy-1-extra.o $(objpfx)tst-shstk-legacy-1b: $(objpfx)tst-shstk-legacy-1-extra.o $(objpfx)tst-shstk-legacy-1b-static: $(objpfx)tst-shstk-legacy-1-extra.o +tst-shstk-legacy-1c-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-SHSTK +tst-shstk-legacy-1c-static-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-SHSTK +$(objpfx)tst-shstk-legacy-1c: $(objpfx)tst-shstk-legacy-1-extra.o +$(objpfx)tst-shstk-legacy-1c-static: $(objpfx)tst-shstk-legacy-1-extra.o endif # Add -fcf-protection to CFLAGS when CET is enabled. diff --git a/sysdeps/x86/tst-shstk-legacy-1c-static.c b/sysdeps/x86/tst-shstk-legacy-1c-static.c new file mode 100644 index 0000000000..91ea346aaf --- /dev/null +++ b/sysdeps/x86/tst-shstk-legacy-1c-static.c @@ -0,0 +1 @@ +#include "tst-shstk-legacy-1c.c" diff --git a/sysdeps/x86/tst-shstk-legacy-1c.c b/sysdeps/x86/tst-shstk-legacy-1c.c new file mode 100644 index 0000000000..eb218c6c70 --- /dev/null +++ b/sysdeps/x86/tst-shstk-legacy-1c.c @@ -0,0 +1,20 @@ +/* Check that legacy shadow stack code won't trigger segfault with + GLIBC_TUNABLES=glibc.cpu.hwcaps=-SHSTK + Copyright (C) 2023 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 "tst-shstk-legacy-1a.c"