From patchwork Sat Dec 16 16:53:15 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: 82302 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 8EAB138618EF for ; Sat, 16 Dec 2023 16:54:59 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by sourceware.org (Postfix) with ESMTPS id D7F66385C6C4 for ; Sat, 16 Dec 2023 16:53:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D7F66385C6C4 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 D7F66385C6C4 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::231 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702745613; cv=none; b=aKh/1LeIlWlFj/YAcfl4zqvADSCTwQcJWNzg4Vr5ZHvyW+HJK2yN92eXFurTt5Ku5ijou4/A6s7za+cD6eB0PKCvt0LdJa1gu5xfqtLHh4nRxvAxc6i/W2UV6dhFzS5VN6JjKBNP+QdlVNXyp+FykaAXpQNeIPJa3fxdtR4JOfo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702745613; c=relaxed/simple; bh=xuNW3G7fIcT5/riJEpyWSbNPrY0kfZDOrGhb6n5v9+k=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=i0MEvqgLmdxuq6QVKVTOTAvsvzdZSy4HU2xaiurMwLAU3oioj+/uKgd1+KkILFoBKuVma0dvkMwVsA1vKsReh2qhrwOrB0zPmBrDKOABdOzn59o9HAaq+h8X+Vjb3/l40A8ID3b8fg8LTpEkUr7CtHWefNf7zojEYFRXkF+csm8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-3b9e07690ccso1267590b6e.3 for ; Sat, 16 Dec 2023 08:53:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702745611; x=1703350411; 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=3uS4E9Itb6cZf7tnzps0O+lBjyy0WZr+iDAMZLzhkys=; b=Ogzo29TVSAFoZvqZ7JEkDV2hY7P/D+wC2UbR2oTj35Ej/EYa3sFDUWVd7zVrWVEsHU 32TsYo5TSqqr+47y7XGDkYa9wIV/jpgLDGPr+wdxOaVZ9AOKbZgcV1qCfQhixzefEAOp DxpQagpSCY1tUK5qyFG0cyr2sopbvNEllHt0S3GNexvxqmcbFiFmquUgv5J9fidzxB2H Da+nbH1moDWMeBQJoJ+htPu7KY9/cnM0oYkQKxYgK8S4jXKieqXLc2hc1IAEfvGAJ9Uo KnLGw6TabxxIl0IjmQUmJQOoSwYG1BJyODDHc/ew22RWFZCaxkRo4i61I+WfL68uqb3+ fIDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702745611; x=1703350411; 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=3uS4E9Itb6cZf7tnzps0O+lBjyy0WZr+iDAMZLzhkys=; b=EbBH7k0F6vPOGwboZoIQm9l5Keb1PFxsIp4k0+JFcqxWMG4ztaBvsUwSvOOl2k3lBQ NECuafXfp1aqYRMm82n+K+tQZI9YMLidBG2V46H+I/Y52Gn5AtZEmCUc2bZW6+2WeMUn vNWqX7zWiex2FSOVD63nhvd778zGAxM4dUmEnUty7PO4m1Glf/h9TW2ILsVAEO9saSK0 qGhTzy4ldzlrEozfaFuwRcIiRY+k3TM1b6d50bRI6UxfvMhMnyOnQDvkrqp7IOEkLg3L Jv9kIjxwQHd8b1IyfxHL+G6PBTJcsw4kVkLcah3aIvPGi5qdTLFFWp+GY2CByIAUSMyR HEOg== X-Gm-Message-State: AOJu0YyHVyoJTao2zaoHPb3TArakHo8l4Xx3Uk4EkySvVpm8s1fDo+AQ kkypnxOYL2bbCk606qllTVxnVOg/6IM= X-Google-Smtp-Source: AGHT+IHlwo0I+iFMZOKXD8pnCj9FP1vac4Xd8a0VwFMCdZSWp3g2PxG9FgTH1TFgZmKym+rmOJQhvw== X-Received: by 2002:a05:6808:16aa:b0:3b9:f0f5:93c6 with SMTP id bb42-20020a05680816aa00b003b9f0f593c6mr15043576oib.41.1702745611104; Sat, 16 Dec 2023 08:53:31 -0800 (PST) Received: from gnu-cfl-3.localdomain ([172.59.129.147]) by smtp.gmail.com with ESMTPSA id y17-20020aa78551000000b006d0d4c87ccasm6517202pfn.159.2023.12.16.08.53.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Dec 2023 08:53:29 -0800 (PST) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id 903D0740634; Sat, 16 Dec 2023 08:53:25 -0800 (PST) From: "H.J. Lu" To: libc-alpha@sourceware.org Cc: rick.p.edgecombe@intel.com Subject: [PATCH v2 06/16] x86/cet: Add tests for GLIBC_TUNABLES=glibc.cpu.hwcaps=-SHSTK Date: Sat, 16 Dec 2023 08:53:15 -0800 Message-ID: <20231216165325.2584919-7-hjl.tools@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231216165325.2584919-1-hjl.tools@gmail.com> References: <20231216165325.2584919-1-hjl.tools@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3024.8 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 23f3ac1430..b857ad6ea6 100644 --- a/sysdeps/x86/Makefile +++ b/sysdeps/x86/Makefile @@ -171,10 +171,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 \ @@ -272,6 +275,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"