From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 37BA21F461 for ; Tue, 16 Jul 2019 11:16:14 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:references :in-reply-to:content-type:content-transfer-encoding :mime-version; q=dns; s=default; b=lbuQe08Tmk2Jhzsj88F+w6mKMr/LJ DPFWwvNv+IxU5STOs7oP9LCHODM1IQDCv3HYvgyo800jCBfWWYVuEHleUDfAuG0f z52jxjH3yapXL9A3KHpbOcE7686xGezKlruELTzYIL+UYVNyFr/nNeXBVf6BhnZk gKNH7Pf9GjswBU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:references :in-reply-to:content-type:content-transfer-encoding :mime-version; s=default; bh=lj6fRwHn9j9AFYBtKoHkTbiZS/M=; b=Gjl 38lv2GeOpg8zOCTQrzAnHur4u3Uk1OfKJRkJDTklkWpRTa+qvfGWz+TyyB3gWeG0 xzwMsvinRbx21AwbT/Nre63KOl4nrYM0bdhx6whcs8a8n6DADNk0XMtAlDVAOOZR f1ztAGw9OAEDGbavDhMrjVemlaYQAdF3tLZxMzAU= Received: (qmail 88955 invoked by alias); 16 Jul 2019 11:16:09 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 88865 invoked by uid 89); 16 Jul 2019 11:16:08 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: NAM04-BN3-obe.outbound.protection.outlook.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=falOWXQoyo/D3rEdtNEzucxKMXidfIbYuAK2ku2umG/A4RNxo1ioW72bMNSn/sBHqWcdezFmV2ePGapYoSVfIcfUZc3T5jNi+By7I0V3WrxpQRLmRp94t2oYx4HiTwN9I9/9UA6A6R1wiCUKMJchRuspFbq1Uz7KJDnjCbRENiWtdjdfn3wUsQqsjjGgVtQ7Xdx5n9K4mE07F+jTiGHWGQnyc+AjE5BlH3MbfZI2XXv9YoX/Eq2m4JWKfKxyD3pvFfDU/fthuoJXGo+rfmDDnUWFNtG2xoXHDghRXKiHCq270Dxegkur4CngR+CG8vi3h7MAPVTbxufbs6srUorDJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/27nW/mUFs6UwOylVytLUcGHt8NuJm8SiqR94qTzorw=; b=J5WYC7QLEVKVfCS+7OPfl1Xvxl4QYVJhlLUfYzBbtXkfvtY5TyKA59dPH+5tTRoGvOtM3T7ew3OgDCnig3qz0tGsRGFlN+wgwQKuglDfFHDEobsG/e+uO8MVKHo4qJsnw6GqDp8SBrC2RVgpO8J7DYwKNxoAhpJwvwkdA1IntIWDcS6GezgjqFBYrT8XxK4J+wH5zABL0In4i0FmUXHcp5XQU2Rt5Q8+I57u4+P0dgqnaiWzo+W8Py3r8uCP+mqbdrp6S4IMmB6LCYaFn1zFoLePpdAxm7FBvy71q+j6ypb1uRwaJ7PLHjUGhAEpgs9qEjCAf3Pfb5uh6WBWXqz8BQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=wavecomp.com;dmarc=pass action=none header.from=wavecomp.com;dkim=pass header.d=wavecomp.com;arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wavesemi.onmicrosoft.com; s=selector1-wavesemi-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/27nW/mUFs6UwOylVytLUcGHt8NuJm8SiqR94qTzorw=; b=hBEivb/Az+V1lZtsNgA5VHoawZ9fM9Lzuirv4yI0gTRhElVJge8vKIpZWgD8A8512QIjsrBSrB8SKSOsMGKiPpregNvE42VBMfMsl+/Y9s/K0I7o2blBGhnJnGRZDgA+jqictjl7HJNeMZ6Y5ZgNhYLaugGXIdJiiXMqEHS2ShU= From: Dragan Mladjenovic To: "libc-alpha@sourceware.org" CC: Joseph Myers , Carlos O'Donell , "Maciej W. Rozycki" , Faraz Shahbazker , Dragan Mladjenovic Subject: [PATCH v2 2/3] [MIPS] Define DL_EXEC_STACK_OVERRIDE Date: Tue, 16 Jul 2019 11:16:02 +0000 Message-ID: <1563275697-30825-2-git-send-email-dmladjenovic@wavecomp.com> References: <1563214941-16203-1-git-send-email-dmladjenovic@wavecomp.com> <1563275697-30825-1-git-send-email-dmladjenovic@wavecomp.com> In-Reply-To: <1563275697-30825-1-git-send-email-dmladjenovic@wavecomp.com> authentication-results: spf=none (sender IP is ) smtp.mailfrom=dmladjenovic@wavecomp.com; x-ms-exchange-purlcount: 2 x-ms-oob-tlc-oobclassifiers: OLM:8273; received-spf: None (protection.outlook.com: wavecomp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: dmladjenovic@wavecomp.com For hard-float builds targeting minimum Linux kernel version lower than 4.8 DL_EXEC_STACK_OVERRIDE will request executable stack if it detects that runtime kernel version is also lower than 4.8. Build now detects if mips toolchain uses GNU.stack note and updates the expected result of check-execstack accordingly. * sysdeps/unix/sysv/linux/mips/Makefile [$(subdir) =3D=3D elf][$(mips-float) =3D=3D hard] (tests): Add tst-execstack-ovrd and tst-execstack-ovrd1. (tests-static): Add tst-execstack-ovrd-static and tst-execstack-ovrd1-static. (LDFLAGS-tst-execstack-ovrd*, tst-execstack-ovrd*-ENV): New rules. * sysdeps/unix/sysv/linux/mips/Makefile [$(subdir) =3D=3D elf][$(mips-has-gnustack) !=3D yes] (test-xfail-check-execstack): Move test-xfail-check-execstack here. (test-xfail-tst-execstack-ovrd1): New xfail. * sysdeps/unix/sysv/linux/mips/configure.ac (mips-has-gnustack): New var. Set to value of libc_cv_as_noexecstack. (mips-float): New var. Set to value of libc_mips_float. * sysdeps/unix/sysv/linux/mips/configure: Regenerated. * sysdeps/unix/sysv/linux/mips/ldsodefs.h (__GNU_STACK_SAFE_KERNEL_VERSION): New. Define to 4.8.0. (DL_EXEC_STACK_OVERRIDE): New. Check dl_osversion against previous define. * sysdeps/unix/sysv/linux/mips/tst-execstack-ovrd-static.c: New file. * sysdeps/unix/sysv/linux/mips/tst-execstack-ovrd.c: New file. * sysdeps/unix/sysv/linux/mips/tst-execstack-ovrd1-static.c: New file. * sysdeps/unix/sysv/linux/mips/tst-execstack-ovrd1.c: New file. --- sysdeps/unix/sysv/linux/mips/Makefile | 26 ++++++++++++++++++= ---- sysdeps/unix/sysv/linux/mips/configure.ac | 3 +++ sysdeps/unix/sysv/linux/mips/ldsodefs.h | 11 +++++++++ .../sysv/linux/mips/tst-execstack-ovrd-static.c | 1 + sysdeps/unix/sysv/linux/mips/tst-execstack-ovrd.c | 2 ++ .../sysv/linux/mips/tst-execstack-ovrd1-static.c | 1 + sysdeps/unix/sysv/linux/mips/tst-execstack-ovrd1.c | 10 +++++++++ 7 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/mips/tst-execstack-ovrd-static.= c create mode 100644 sysdeps/unix/sysv/linux/mips/tst-execstack-ovrd.c create mode 100644 sysdeps/unix/sysv/linux/mips/tst-execstack-ovrd1-static= .c create mode 100644 sysdeps/unix/sysv/linux/mips/tst-execstack-ovrd1.c diff --git a/sysdeps/unix/sysv/linux/mips/Makefile b/sysdeps/unix/sysv/linu= x/mips/Makefile index 8217f42..328f0b4 100644 --- a/sysdeps/unix/sysv/linux/mips/Makefile +++ b/sysdeps/unix/sysv/linux/mips/Makefile @@ -64,11 +64,29 @@ sysdep-dl-routines +=3D dl-static sysdep_routines +=3D dl-vdso endif =20 -# Supporting non-executable stacks on MIPS requires changes to both -# the Linux kernel and glibc. See -# and -# . +ifeq ($(mips-float),hard) +tests-static +=3D tst-execstack-ovrd-static +tests +=3D tst-execstack-ovrd-static +tests +=3D tst-execstack-ovrd +tests-static +=3D tst-execstack-ovrd1-static +tests +=3D tst-execstack-ovrd1-static +tests +=3D tst-execstack-ovrd1 +LDFLAGS-tst-execstack-ovrd =3D -Wl,-z,noexecstack +LDFLAGS-tst-execstack-ovrd-static =3D -Wl,-z,noexecstack +LDFLAGS-tst-execstack-ovrd1 =3D -Wl,-z,noexecstack +LDFLAGS-tst-execstack-ovrd1-static =3D -Wl,-z,noexecstack +tst-execstack-ovrd-ENV =3D LD_ASSUME_KERNEL=3D4.5.0 +tst-execstack-ovrd-static-ENV =3D LD_ASSUME_KERNEL=3D4.5.0 +tst-execstack-ovrd1-ENV =3D LD_ASSUME_KERNEL=3D4.8.0 +tst-execstack-ovrd1-static-ENV =3D LD_ASSUME_KERNEL=3D4.8.0 +endif +# If the compiler doesn't use GNU.stack note, +# thease tests are expected to fail. +ifneq ($(mips-has-gnustack),yes) test-xfail-check-execstack =3D yes +test-xfail-tst-execstack-ovrd1 =3D yes +endif + endif =20 ifeq ($(subdir),stdlib) diff --git a/sysdeps/unix/sysv/linux/mips/configure.ac b/sysdeps/unix/sysv/= linux/mips/configure.ac index 9147aa4..1ff77e7 100644 --- a/sysdeps/unix/sysv/linux/mips/configure.ac +++ b/sysdeps/unix/sysv/linux/mips/configure.ac @@ -118,6 +118,9 @@ fi LIBC_CONFIG_VAR([default-abi], [${libc_mips_abi}_${libc_mips_float}${libc_mips_nan}]) =20 +LIBC_CONFIG_VAR([mips-has-gnustack],[${libc_cv_as_noexecstack}]) +LIBC_CONFIG_VAR([mips-float],[${libc_mips_float}]) + case $machine in mips/mips64/n64/*) LIBC_SLIBDIR_RTLDDIR([lib64], [lib64]) diff --git a/sysdeps/unix/sysv/linux/mips/ldsodefs.h b/sysdeps/unix/sysv/li= nux/mips/ldsodefs.h index 8dde855..803fdd1 100644 --- a/sysdeps/unix/sysv/linux/mips/ldsodefs.h +++ b/sysdeps/unix/sysv/linux/mips/ldsodefs.h @@ -37,4 +37,15 @@ extern void _dl_static_init (struct link_map *map); || (osabi =3D=3D ELFOSABI_SYSV && ver < 4) \ || (osabi =3D=3D ELFOSABI_GNU && ver < LIBC_ABI_MAX)) =20 + +#define __GNU_STACK_SAFE_KERNEL_VERSION (0x040800) + +#ifdef __mips_hard_float +# if (__LINUX_KERNEL_VERSION < __GNU_STACK_SAFE_KERNEL_VERSION) +# undef DL_EXEC_STACK_OVERRIDE +# define DL_EXEC_STACK_OVERRIDE \ + ((GLRO(dl_osversion) < __GNU_STACK_SAFE_KERNEL_VERSION)) +# endif +#endif + #endif /* ldsodefs.h */ diff --git a/sysdeps/unix/sysv/linux/mips/tst-execstack-ovrd-static.c b/sys= deps/unix/sysv/linux/mips/tst-execstack-ovrd-static.c new file mode 100644 index 0000000..0e5e61b --- /dev/null +++ b/sysdeps/unix/sysv/linux/mips/tst-execstack-ovrd-static.c @@ -0,0 +1 @@ +#include "tst-execstack-ovrd.c" diff --git a/sysdeps/unix/sysv/linux/mips/tst-execstack-ovrd.c b/sysdeps/un= ix/sysv/linux/mips/tst-execstack-ovrd.c new file mode 100644 index 0000000..9d2f4ef --- /dev/null +++ b/sysdeps/unix/sysv/linux/mips/tst-execstack-ovrd.c @@ -0,0 +1,2 @@ +#include "tst-execstack-prog.c" + diff --git a/sysdeps/unix/sysv/linux/mips/tst-execstack-ovrd1-static.c b/sy= sdeps/unix/sysv/linux/mips/tst-execstack-ovrd1-static.c new file mode 100644 index 0000000..e45ac94 --- /dev/null +++ b/sysdeps/unix/sysv/linux/mips/tst-execstack-ovrd1-static.c @@ -0,0 +1 @@ +#include "tst-execstack-ovrd1.c" diff --git a/sysdeps/unix/sysv/linux/mips/tst-execstack-ovrd1.c b/sysdeps/u= nix/sysv/linux/mips/tst-execstack-ovrd1.c new file mode 100644 index 0000000..953dd37 --- /dev/null +++ b/sysdeps/unix/sysv/linux/mips/tst-execstack-ovrd1.c @@ -0,0 +1,10 @@ +#include + +/* This test will fail (not produce a SIGSEGV) either because + DL_SYSDEP_OSCHECK detects that we are running on kernel older + than what we specify via LD_ASSUME_KERNEL or the execution + environment doesn't support NX semantics (no RIXI). */ +#define EXPECTED_SIGNAL SIGSEGV + +#include "tst-execstack-prog.c" + --=20 1.9.1