From patchwork Wed Dec 6 17:20:00 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: 81544 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 345273870C09 for ; Wed, 6 Dec 2023 17:21:59 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by sourceware.org (Postfix) with ESMTPS id 71F723858002 for ; Wed, 6 Dec 2023 17:20:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 71F723858002 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 71F723858002 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1033 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701883222; cv=none; b=hFBSy9mJxrK25FLmKYggqoz4pPk4z1LLsVYoGFMaikNm/T9H4H4tbpClEu4VrdM4nNJI5Ri7s7FUVt6KRxm0G0CVChPD7QBQt1IldBJiRbIYXz0guvqM+1teGQ4vwoZsoZUAg+MPq3MDzGQwMe9cYk3S2gDoC5pRSsF7qKG+uv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701883222; c=relaxed/simple; bh=VJlKekKsFPa86ZKwlrttJyotssr7E0k1EOF+o9P9sn8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=C1S6x28uOHG4hjHbSZW7Zfm9wV6qSzIwhMhz+qf+rVnxc0VWXYIB2df+ECx6iHCJlzUH4frNkegoOt2SSxjUu1ySczY62z5MhUpF8z95oVrJE04v4rEsbGFBCaqhksE3UJULmYIwfwgdzm4A4YMo/vWpIhluofAI2aJdXcIDczI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2886579d59fso55578a91.1 for ; Wed, 06 Dec 2023 09:20:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701883217; x=1702488017; 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=0d8006v/xxHx85NWEJQnBj70U5Sbx8p61PZOj9Rqv0Q=; b=dRMEvlDKYn0/JDOBvQ7LzmGZSgsGrRLoY24bYuRhbq04W9g4QgMezxdiDKyY2euXEB crm/+5bZxUqqR5bkqlNUrSv90xU0jbpdcKPf2Wo6zxd2t033kZ46YMdJ3Sbmd63I5vF6 Fp0qoqehZpVWnSOZepI518RiL6oRPko5ZCVu0KiOZy+VD111FTfDXNvaDHbIUbAU9lHW zBVqbP27RO9WZqT7vO1yJqX1C2EjuHwnQQlm6dv15QRmYzp1hMc2GPu/RWXPA327JYmE 94pAJGAuU1Ai1es4UgdwGFQfhRwp9mBpsESS0rXlmlvKmRpFzypuMPk5pSnd/AvxF5Qr O5Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701883217; x=1702488017; 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=0d8006v/xxHx85NWEJQnBj70U5Sbx8p61PZOj9Rqv0Q=; b=xJW0LJaFKsp/6DnB+LlA8kAhxfJyIraQBu7+ojiV+PrB2DS/7FDjhY9lvzoaqVekGP Fc8Rx89E/VwNZoUZewPgMP5mj3e95UQrrsEnoID33XgqF8Cv5Ky01O7Z14pMU8ECHJua uNXlb0wXNxltVZA6EcNyzRyg1bgcCVlxhkWJt8evgOGLUktO+XpZaOjkWH9kOJn93OxR ebiKB4LP+pU/W2gPl7RoTjOBNjvY9JhNx0zJoh99fRqJe0Kf5FVBPqrrDSaO3UnGSgI9 nJ8yL0QbKR7kmq63lTAC8d6rwIfanC2xPHozp85DyyQs4QiDtjSPnm3fP2sDUW1Xbtr+ Ss9Q== X-Gm-Message-State: AOJu0Yy+7tJyGBaz23hHBC1HepXoCtu6eqh/VTNXPk7+3MH6u/i0Zgww dvpDNXDHSQwNfNi+YLEpAD7NueBkW3w= X-Google-Smtp-Source: AGHT+IE4erKzPW1wudht/A1xPq/IG+eriY5ExSwi/ZucsxyUcb53s3ttGUWtx2PAp6kjtbQkfyix3w== X-Received: by 2002:a17:90a:df82:b0:286:6cc0:cace with SMTP id p2-20020a17090adf8200b002866cc0cacemr1323409pjv.69.1701883217296; Wed, 06 Dec 2023 09:20:17 -0800 (PST) Received: from gnu-cfl-3.localdomain ([172.59.161.253]) by smtp.gmail.com with ESMTPSA id sr12-20020a17090b4e8c00b002868d090c27sm76728pjb.25.2023.12.06.09.20.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 09:20:16 -0800 (PST) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id 95E91740630; 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 07/17] x86/cet: Check legacy shadow stack code in .init_array section Date: Wed, 6 Dec 2023 09:20:00 -0800 Message-ID: <20231206172010.1023415-8-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 legacy shadow stack code in .init_array section in application and shared library, which are marked as shadow stack enabled, will trigger segfault. --- sysdeps/x86/Makefile | 36 +++++++++++++++ sysdeps/x86/tst-shstk-legacy-1d-static.c | 1 + sysdeps/x86/tst-shstk-legacy-1d.c | 47 ++++++++++++++++++++ sysdeps/x86/tst-shstk-legacy-1e-static.c | 1 + sysdeps/x86/tst-shstk-legacy-1e-static.sh | 32 ++++++++++++++ sysdeps/x86/tst-shstk-legacy-1e.c | 53 +++++++++++++++++++++++ sysdeps/x86/tst-shstk-legacy-1e.sh | 34 +++++++++++++++ sysdeps/x86/tst-shstk-legacy-1f.c | 29 +++++++++++++ sysdeps/x86/tst-shstk-legacy-1g.c | 35 +++++++++++++++ sysdeps/x86/tst-shstk-legacy-1g.sh | 34 +++++++++++++++ sysdeps/x86/tst-shstk-legacy-mod-1.c | 28 ++++++++++++ 11 files changed, 330 insertions(+) create mode 100644 sysdeps/x86/tst-shstk-legacy-1d-static.c create mode 100644 sysdeps/x86/tst-shstk-legacy-1d.c create mode 100644 sysdeps/x86/tst-shstk-legacy-1e-static.c create mode 100755 sysdeps/x86/tst-shstk-legacy-1e-static.sh create mode 100644 sysdeps/x86/tst-shstk-legacy-1e.c create mode 100755 sysdeps/x86/tst-shstk-legacy-1e.sh create mode 100644 sysdeps/x86/tst-shstk-legacy-1f.c create mode 100644 sysdeps/x86/tst-shstk-legacy-1g.c create mode 100755 sysdeps/x86/tst-shstk-legacy-1g.sh create mode 100644 sysdeps/x86/tst-shstk-legacy-mod-1.c diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile index 5f1414fba3..b8b98177e0 100644 --- a/sysdeps/x86/Makefile +++ b/sysdeps/x86/Makefile @@ -139,11 +139,22 @@ tests += \ tst-shstk-legacy-1b-static \ tst-shstk-legacy-1c \ tst-shstk-legacy-1c-static \ + tst-shstk-legacy-1d \ + tst-shstk-legacy-1d-static \ + tst-shstk-legacy-1e \ + tst-shstk-legacy-1e-static \ + tst-shstk-legacy-1f \ + tst-shstk-legacy-1g \ # tests +modules-names += \ + tst-shstk-legacy-mod-1 \ +# modules-names tests-static += \ tst-shstk-legacy-1a-static \ tst-shstk-legacy-1b-static \ tst-shstk-legacy-1c-static \ + tst-shstk-legacy-1d-static \ + tst-shstk-legacy-1e-static \ # tests-static extra-objs += \ tst-shstk-legacy-1-extra.o \ @@ -192,6 +203,9 @@ CFLAGS-tst-cet-legacy-10a-static.c += -fcf-protection=none CFLAGS-tst-shstk-legacy-1a.c += -fcf-protection=none CFLAGS-tst-shstk-legacy-1a-static.c += -fcf-protection=none +CFLAGS-tst-shstk-legacy-1d.c += -fcf-protection=none +CFLAGS-tst-shstk-legacy-1d-static.c += -fcf-protection=none +CFLAGS-tst-shstk-legacy-1f.c += -fcf-protection=none $(objpfx)tst-cet-legacy-1: $(objpfx)tst-cet-legacy-mod-1.so \ $(objpfx)tst-cet-legacy-mod-2.so @@ -234,6 +248,28 @@ 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 +$(objpfx)tst-shstk-legacy-1d: $(objpfx)tst-shstk-legacy-1-extra.o +$(objpfx)tst-shstk-legacy-1d-static: $(objpfx)tst-shstk-legacy-1-extra.o +$(objpfx)tst-shstk-legacy-1e: $(objpfx)tst-shstk-legacy-1-extra.o +$(objpfx)tst-shstk-legacy-1e-static: $(objpfx)tst-shstk-legacy-1-extra.o +$(objpfx)tst-shstk-legacy-1e.out: \ + $(..)/sysdeps/x86/tst-shstk-legacy-1e.sh $(objpfx)tst-shstk-legacy-1e + $(SHELL) $< $(common-objpfx) '$(test-program-prefix)' 2> $@; \ + $(evaluate-test) +$(objpfx)tst-shstk-legacy-1e-static.out: \ + $(..)/sysdeps/x86/tst-shstk-legacy-1e-static.sh \ + $(objpfx)tst-shstk-legacy-1e-static + $(SHELL) $< $(common-objpfx) 2> $@; \ + $(evaluate-test) +$(objpfx)tst-shstk-legacy-1f: $(objpfx)tst-shstk-legacy-mod-1.so +$(objpfx)tst-shstk-legacy-mod-1.so: \ + $(objpfx)tst-shstk-legacy-mod-1.os \ + $(objpfx)tst-shstk-legacy-1-extra.os +$(objpfx)tst-shstk-legacy-1g: $(objpfx)tst-shstk-legacy-mod-1.so +$(objpfx)tst-shstk-legacy-1g.out: \ + $(..)/sysdeps/x86/tst-shstk-legacy-1g.sh $(objpfx)tst-shstk-legacy-1g + $(SHELL) $< $(common-objpfx) '$(test-program-prefix)' 2> $@; \ + $(evaluate-test) endif # Add -fcf-protection to CFLAGS when CET is enabled. diff --git a/sysdeps/x86/tst-shstk-legacy-1d-static.c b/sysdeps/x86/tst-shstk-legacy-1d-static.c new file mode 100644 index 0000000000..dca27a5482 --- /dev/null +++ b/sysdeps/x86/tst-shstk-legacy-1d-static.c @@ -0,0 +1 @@ +#include "tst-shstk-legacy-1d.c" diff --git a/sysdeps/x86/tst-shstk-legacy-1d.c b/sysdeps/x86/tst-shstk-legacy-1d.c new file mode 100644 index 0000000000..465cfab1db --- /dev/null +++ b/sysdeps/x86/tst-shstk-legacy-1d.c @@ -0,0 +1,47 @@ +/* Check that legacy shadow stack code in init_array won't trigger + segfault. + 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 +#include + +/* Check that legacy shadow stack code in init_array won't trigger + segfault. */ +extern void legacy (void); +int done; + +void +legacy_1 (void) +{ + legacy (); + done = 1; +} + +void (*init_array []) (void) + __attribute__ ((section (".init_array"), aligned (sizeof (void *)))) = +{ + &legacy_1 +}; + +static int +do_test (void) +{ + return EXIT_SUCCESS; +} + +#include diff --git a/sysdeps/x86/tst-shstk-legacy-1e-static.c b/sysdeps/x86/tst-shstk-legacy-1e-static.c new file mode 100644 index 0000000000..cb6ce0de00 --- /dev/null +++ b/sysdeps/x86/tst-shstk-legacy-1e-static.c @@ -0,0 +1 @@ +#include "tst-shstk-legacy-1e.c" diff --git a/sysdeps/x86/tst-shstk-legacy-1e-static.sh b/sysdeps/x86/tst-shstk-legacy-1e-static.sh new file mode 100755 index 0000000000..e943aec70e --- /dev/null +++ b/sysdeps/x86/tst-shstk-legacy-1e-static.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Check that legacy shadow stack code in init_array will trigger +# segfault. +# 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 +# . + +common_objpfx=$1; shift + +${common_objpfx}elf/tst-shstk-legacy-1e-static +# The exit status should only be unsupported (77) or segfault (139). +status=$? +if test $status -eq 77; then + exit 77 +elif test $status == 139; then + exit 0 +else + exit 1 +fi diff --git a/sysdeps/x86/tst-shstk-legacy-1e.c b/sysdeps/x86/tst-shstk-legacy-1e.c new file mode 100644 index 0000000000..e78a4b776e --- /dev/null +++ b/sysdeps/x86/tst-shstk-legacy-1e.c @@ -0,0 +1,53 @@ +/* Check that legacy shadow stack code in init_array will trigger + segfault. + 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 +#include +#include +#include + +/* Check that legacy shadow stack code in init_array will trigger + segfault. */ +extern void legacy (void); +int done; + +void +legacy_1 (void) +{ + legacy (); + done = 1; +} + +void (*init_array []) (void) + __attribute__ ((section (".init_array"), aligned (sizeof (void *)))) = +{ + &legacy_1 +}; + +static int +do_test (void) +{ + if (!CPU_FEATURE_ACTIVE (SHSTK)) + return EXIT_UNSUPPORTED; + + return EXIT_FAILURE; +} + +#define EXPECTED_SIGNAL (CPU_FEATURE_ACTIVE (SHSTK) ? SIGSEGV : 0) +#include diff --git a/sysdeps/x86/tst-shstk-legacy-1e.sh b/sysdeps/x86/tst-shstk-legacy-1e.sh new file mode 100755 index 0000000000..b0467aa899 --- /dev/null +++ b/sysdeps/x86/tst-shstk-legacy-1e.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Check that legacy shadow stack code in init_array will trigger +# segfault. +# 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 +# . + +common_objpfx=$1; shift +test_program_prefix=$1; shift + +${test_program_prefix} \ + ${common_objpfx}elf/tst-shstk-legacy-1e +# The exit status should only be unsupported (77) or segfault (139). +status=$? +if test $status -eq 77; then + exit 77 +elif test $status == 139; then + exit 0 +else + exit 1 +fi diff --git a/sysdeps/x86/tst-shstk-legacy-1f.c b/sysdeps/x86/tst-shstk-legacy-1f.c new file mode 100644 index 0000000000..27e01a229e --- /dev/null +++ b/sysdeps/x86/tst-shstk-legacy-1f.c @@ -0,0 +1,29 @@ +/* Check that legacy shadow stack code in init_array won't trigger + segfault. + 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 +#include + +static int +do_test (void) +{ + return EXIT_SUCCESS; +} + +#include diff --git a/sysdeps/x86/tst-shstk-legacy-1g.c b/sysdeps/x86/tst-shstk-legacy-1g.c new file mode 100644 index 0000000000..a1f3d242e9 --- /dev/null +++ b/sysdeps/x86/tst-shstk-legacy-1g.c @@ -0,0 +1,35 @@ +/* Check that legacy shadow stack code in init_array will trigger + segfault. + 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 +#include +#include +#include + +static int +do_test (void) +{ + if (!CPU_FEATURE_ACTIVE (SHSTK)) + return EXIT_UNSUPPORTED; + + return EXIT_FAILURE; +} + +#define EXPECTED_SIGNAL (CPU_FEATURE_ACTIVE (SHSTK) ? SIGSEGV : 0) +#include diff --git a/sysdeps/x86/tst-shstk-legacy-1g.sh b/sysdeps/x86/tst-shstk-legacy-1g.sh new file mode 100755 index 0000000000..c112bf6d8d --- /dev/null +++ b/sysdeps/x86/tst-shstk-legacy-1g.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Check that legacy shadow stack code in init_array will trigger +# segfault. +# 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 +# . + +common_objpfx=$1; shift +test_program_prefix=$1; shift + +${test_program_prefix} \ + ${common_objpfx}elf/tst-shstk-legacy-1g +# The exit status should only be unsupported (77) or segfault (139). +status=$? +if test $status -eq 77; then + exit 77 +elif test $status == 139; then + exit 0 +else + exit 1 +fi diff --git a/sysdeps/x86/tst-shstk-legacy-mod-1.c b/sysdeps/x86/tst-shstk-legacy-mod-1.c new file mode 100644 index 0000000000..b75b5484d9 --- /dev/null +++ b/sysdeps/x86/tst-shstk-legacy-mod-1.c @@ -0,0 +1,28 @@ +/* Check legacy shadow stack code in init_array. + 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 + +/* Check legacy shadow stack code in init_array. */ +extern void legacy (void) __attribute__ ((visibility ("hidden"))); + +void (*init_array []) (void) + __attribute__ ((section (".init_array"), aligned (sizeof (void *)))) = +{ + &legacy +};