From patchwork Tue Jul 16 11:15:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dragan Mladjenovic X-Patchwork-Id: 1132607 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-103663-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=wavecomp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="H3MZuEi0"; dkim=pass (1024-bit key; unprotected) header.d=wavesemi.onmicrosoft.com header.i=@wavesemi.onmicrosoft.com header.b="bj0Y5q0d"; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 45nyWW2CT0z9s7T for ; Tue, 16 Jul 2019 21:16:07 +1000 (AEST) 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=NCOL9bNMWrE+ZBWLofAlrv5krZcm+ R1VKzewxd8cR9QMmJb/hPGk+eHeiJQ6fIyXT0J/c57SiW/Z7ckf5iIX44dYwzwZf 9ov8ny4vlATWgUqoTE5T/WoTzRja31H5zjTvJXStbvkxZrE+14y3HTuTl6W2tBkN FCJ1F+7xBQFft4= 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=Dgu21q334v/bRHB7LX9rL8siSvo=; b=H3M ZuEi0rDbQU69VlFfs74+qRyPY4y22i2rYSzYTw1wjuzbzhlUIP4UTw7pQHH3n5Jz ahvDV5n7E2eWmiH/wX/vz9zQ4BsqWLx5sPLjoNoHA/qXY+JVMJBuEJOdsLhGKr5L 1EBNLknEJ2A2fothQ7jA1i7/5VSkoP9FKnc6fUmQ= Received: (qmail 87918 invoked by alias); 16 Jul 2019 11:16:00 -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 Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 87884 invoked by uid 89); 16 Jul 2019 11:15:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_WEB, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=lesser, structures X-HELO: NAM01-BY2-obe.outbound.protection.outlook.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mGgmSK0zieYVRmIE4dL+pjw8u1fiXFTVvAqFn6lUzKyzAHCpYthL6Y3s8U3UZ6ubYc0BuiuhLrFie5K25bsR1xtttMg50GD6YCrO9eFQ9OiyuRzhBCg3xIEXyYGnKInhGMbA4ZVWkEgnG/zMLRaKzIHhscaFOz5nFMO3rivYvqOmcAlu7r7M1hXR1XM9JKd9H5+QKC3nqhvaxH5wzjfm/ks2/hpIAyM+/Gm75Rr1F/llkHXzoGYNoDTVGpHvpr+TbwLhvx7rdj5JmASTeioxDEOCQSVw5S4ZV1NCYbbrpv1A/td+KtpJznwkxqd9uK1GvhB1BDA5TsEvxekLQ+s5Xw== 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=95GOQ6fOXjB4kJo7RvT5o9kUKjmGGdmiOC2UYkgpc5U=; b=WT5dhc48DqS/LsfitmJcb9fgMqELvNtwc/Ve4oi918b3WECzuHNCTByu1sM9trr9S6vkg+dZbL5Cv1Zjw0HwkVaZTwjt99AeIDwOHz4wQmyfTuTGCL2LRkJKob20vfykogHkcPtjHi5NBcHKBhRU40ewUXyQFpB4X6kZIA87BDkkmSaaYnl9beK/DtEl1UsD6nWDSJmx6BeMCOVUGAuZb+mA2gJSFswf0JHzIbTM+fkly+uZeBfrJa8GfRmsm9isOb1DBSuUGeYWRpBHSbJAHf5nuxxr9+ZXpMYcA7F5j5YaIAeFp6S4ekUXnpijMezVLqRnxJV/WDl0rkEtstpoTw== 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=95GOQ6fOXjB4kJo7RvT5o9kUKjmGGdmiOC2UYkgpc5U=; b=bj0Y5q0dW3dleXmuIo4wkEGfm8drI0esSIMDKghuAWhyXKUut/f7g88KSMoojtvncLwxmNQFt6E8NUSdhQZrsbGwkXLQg2MH85FziBkwhGfEoecxYEXo8lVHRyB1KV/zvbsiMQ0Fglr18osuVft4p3NThFcs8qUN+Czxz6+X3NM= From: Dragan Mladjenovic To: "libc-alpha@sourceware.org" CC: Joseph Myers , Carlos O'Donell , "Maciej W. Rozycki" , Faraz Shahbazker , Dragan Mladjenovic Subject: [PATCH v2 1/3] [ELF] Allow the machine support to enforce executable stack Date: Tue, 16 Jul 2019 11:15:52 +0000 Message-ID: <1563275697-30825-1-git-send-email-dmladjenovic@wavecomp.com> References: <1563214941-16203-1-git-send-email-dmladjenovic@wavecomp.com> In-Reply-To: <1563214941-16203-1-git-send-email-dmladjenovic@wavecomp.com> authentication-results: spf=none (sender IP is ) smtp.mailfrom=dmladjenovic@wavecomp.com; x-ms-exchange-purlcount: 1 x-ms-oob-tlc-oobclassifiers: OLM:8882; received-spf: None (protection.outlook.com: wavecomp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: dmladjenovic@wavecomp.com This patch allows the machine-dependent code to override non-executable stack permissions by defining DL_EXEC_STACK_OVERRIDE to the condition under which the stack should be made executable. * elf/dl-exec-stack-override.h: New file. * elf/dl-support.c (_dl_non_dynamic_init): Call _dl_exec_stack_override. * elf/rtld.c (dl_main): Likewise. * sysdeps/generic/ldsodefs.h: Default DL_EXEC_STACK_OVERRIDE to false. --- elf/dl-exec-stack-override.h | 36 ++++++++++++++++++++++++++++++++++++ elf/dl-support.c | 3 +++ elf/rtld.c | 3 +++ sysdeps/generic/ldsodefs.h | 4 ++++ 4 files changed, 46 insertions(+) create mode 100644 elf/dl-exec-stack-override.h diff --git a/elf/dl-exec-stack-override.h b/elf/dl-exec-stack-override.h new file mode 100644 index 0000000..10401a8 --- /dev/null +++ b/elf/dl-exec-stack-override.h @@ -0,0 +1,36 @@ +/* Make stack executable if the machine requires it. Generic version. + Copyright (C) 2019 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 + +extern int __stack_prot attribute_relro attribute_hidden; + +static __always_inline void +_dl_exec_stack_override (void) +{ + if (__glibc_unlikely ((GL(dl_stack_flags) & PF_X) == 0 + && DL_EXEC_STACK_OVERRIDE)) + { + __stack_prot |= PROT_READ|PROT_WRITE|PROT_EXEC; + + void *stack_end = __libc_stack_end; + int err = _dl_make_stack_executable (&stack_end); + if (__glibc_unlikely (err)) + _dl_fatal_printf ("cannot enable executable stack as machine requires\n"); + } +} diff --git a/elf/dl-support.c b/elf/dl-support.c index 0a8b636..923aa4c 100644 --- a/elf/dl-support.c +++ b/elf/dl-support.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -375,6 +376,8 @@ _dl_non_dynamic_init (void) _dl_stack_flags = _dl_phdr[i].p_flags; break; } + + _dl_exec_stack_override (); } #ifdef DL_SYSINFO_IMPLEMENTATION diff --git a/elf/rtld.c b/elf/rtld.c index c9490ff..f3e00f9 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -1542,6 +1543,8 @@ ERROR: '%s': cannot process note segment.\n", _dl_argv[0]); DL_SYSDEP_OSCHECK (_dl_fatal_printf); #endif + _dl_exec_stack_override (); + /* Initialize the data structures for the search paths for shared objects. */ _dl_init_paths (library_path); diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index b1fc5c3..70e96c0 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -119,6 +119,10 @@ dl_symbol_visibility_binds_local_p (const ElfW(Sym) *sym) # define DL_STATIC_INIT(map) #endif +#ifndef DL_EXEC_STACK_OVERRIDE +# define DL_EXEC_STACK_OVERRIDE false +#endif + /* Reloc type classes as returned by elf_machine_type_class(). ELF_RTYPE_CLASS_PLT means this reloc should not be satisfied by some PLT symbol, ELF_RTYPE_CLASS_COPY means this reloc should not be From patchwork Tue Jul 16 11:16:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dragan Mladjenovic X-Patchwork-Id: 1132608 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-103664-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=wavecomp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="rQKNfV5k"; dkim=pass (1024-bit key; unprotected) header.d=wavesemi.onmicrosoft.com header.i=@wavesemi.onmicrosoft.com header.b="hBEivb/A"; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 45nyWj5xYYz9s7T for ; Tue, 16 Jul 2019 21:16:17 +1000 (AEST) 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=VFZYEGlvKOYt6kwwbWU/yvwxL3WZ2 b1w7TvJMVxx2fMWZ2J8lpa6vF+pxTMNYeHm083+XMZ0c2FS9xC80ONq+rT6RlapP 2zLPlt1ya8X2uX/EjWiHhRKx9hwWV1oqLn5eVQ2KOzBKBXLcKJTaLCYCXr8vQ8Ie 3riBYAoXE9fjm4= 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=rQK NfV5kw5s5cWr0IHWiyv7tNd9IHf6SajBURwp4zxe3jRKP6p2yt1ZRooURpqrsC9Q PhRwA/FYZWocgKHreqWvi0VaCEtFRcfQjGBJyA4haB2PpM//hT56piJBcn3CU0Dw CDJTSOpRqGMcVXbrXp99wzJokwE5T43cim0wf5PQ= 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 Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 88865 invoked by uid 89); 16 Jul 2019 11:16:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_WEB, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy= 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 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) == elf][$(mips-float) == 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) == elf][$(mips-has-gnustack) != 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/linux/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 += dl-static sysdep_routines += dl-vdso endif -# Supporting non-executable stacks on MIPS requires changes to both -# the Linux kernel and glibc. See -# and -# . +ifeq ($(mips-float),hard) +tests-static += tst-execstack-ovrd-static +tests += tst-execstack-ovrd-static +tests += tst-execstack-ovrd +tests-static += tst-execstack-ovrd1-static +tests += tst-execstack-ovrd1-static +tests += tst-execstack-ovrd1 +LDFLAGS-tst-execstack-ovrd = -Wl,-z,noexecstack +LDFLAGS-tst-execstack-ovrd-static = -Wl,-z,noexecstack +LDFLAGS-tst-execstack-ovrd1 = -Wl,-z,noexecstack +LDFLAGS-tst-execstack-ovrd1-static = -Wl,-z,noexecstack +tst-execstack-ovrd-ENV = LD_ASSUME_KERNEL=4.5.0 +tst-execstack-ovrd-static-ENV = LD_ASSUME_KERNEL=4.5.0 +tst-execstack-ovrd1-ENV = LD_ASSUME_KERNEL=4.8.0 +tst-execstack-ovrd1-static-ENV = LD_ASSUME_KERNEL=4.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 = yes +test-xfail-tst-execstack-ovrd1 = yes +endif + endif 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}]) +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/linux/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 == ELFOSABI_SYSV && ver < 4) \ || (osabi == ELFOSABI_GNU && ver < LIBC_ABI_MAX)) + +#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/sysdeps/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/unix/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/sysdeps/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/unix/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" + From patchwork Tue Jul 16 11:16:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dragan Mladjenovic X-Patchwork-Id: 1132609 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-103665-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=wavecomp.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="vbJnwVSo"; dkim=pass (1024-bit key; unprotected) header.d=wavesemi.onmicrosoft.com header.i=@wavesemi.onmicrosoft.com header.b="Oh2j+6qx"; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 45nyWt203Tz9s7T for ; Tue, 16 Jul 2019 21:16:26 +1000 (AEST) 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=ZZKRQ5qkKog3iom+vJxjm3ZsGjEmk e0Rsvmdk0hhidtu4x1+sTYfGKQ+BBJHyJCZbvn2wAR5KF28DTEWHcCZQ5P1eScZ0 JCt0JW2HSrApwaUqz0fd6x+Z32RNsco2rnxK8heEZiA1gQ7FhspLie6wM4H6Cm4b 7L2TZBSy3PrlLs= 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=5jnkaQTwL/PegK8zNhNFz1SrlsQ=; b=vbJ nwVSoXQAXUkwLmRyWvfUdyUEESmorrtqCbUUWNwdNqCT+nyeQlrBt4OvfG/aLOQ7 0y8GCzblrgHuA+h3Evbf1AnAFYv8lUeh3G9nrwef0H8ZHeDgaljgm0I8Scr0g5V8 swh088gkLHsEUJo6z1Mq7/wbzbudiksf8et88nno= Received: (qmail 89658 invoked by alias); 16 Jul 2019 11:16:14 -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 Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 89541 invoked by uid 89); 16 Jul 2019 11:16:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_WEB, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: NAM04-BN3-obe.outbound.protection.outlook.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d/ZjwbKjY6CLa05WSGUOy/x+9mq+6dbWyKn5KWl6et4UC+//QgaWRpNk3a26QEVT22BFrtKXV1UldYSgSDfkCZxG+SxK+0hrpONxP50I6cdq/j78ubkq6o6meT2WOJ4/MroqZlOEDho25z8RoFCAkA2PmEBiTcfUxXVE28qFxZ/8S4R2gjdMG7hPSihIKypfBbbI7p1oOC3+axoDDaYWEMlfgobEtjuWNxRSRcXuNoAUDVaUBvqNfbo56E8yJGpb2LDuvntwcRlo4LiEpuNkQ+oNHALSU64dGOUHltDlwkbtHBdwcidC8iBvcG7riXZJHIfBugaZafYrb7kpFN0Y+A== 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=NpdgVrnb0sgrp9sTnFlpmohteHi41UWZtBvN07oImYA=; b=GnfaheP2jxdb3IiR094CoM8RsnhOdgK3c25KhjGvQk/QXlIaarricYtESDNR4btV6F/N+xCsb5oDDTyMldhqk5/kOSLFDF1eph7HmsqAKkwZNLYW0nQ9ZnfhDWCd01URxU452DVz57iEzbqkpgzYfVwz/2om5mqnssLJ10oH8w45W0Mzq/t0MZGvDKeg0jRCTTrLeNe5PwYwsRUmQ1bWtWC/a5YZxPjLQ+eShaksV0wXGsLXADb+ZcOr83yEJrIoxqxnIvvhfv5xJf0g3bQg5BLpleLnXRPLTHB6DFkySWVBdwxGB9+nMAkbo5G1GfLLsoKLc08z8+4gH4I93ucjrg== 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=NpdgVrnb0sgrp9sTnFlpmohteHi41UWZtBvN07oImYA=; b=Oh2j+6qxxj3Albn7o5YLifJ3Qp2a7+kd9ueuY7x4zilGWgLl8opDx1RE/56gzuCuSHOTjD7d8qnKVwY09rAZOEK6ksXMs8t/xws113P1R9GL6YG/oJ5cTmzRY++1p3kACRJU/kskEasnypYgmeIOoBQn6ge1qaBYfwzIYp5eZio= From: Dragan Mladjenovic To: "libc-alpha@sourceware.org" CC: Joseph Myers , Carlos O'Donell , "Maciej W. Rozycki" , Faraz Shahbazker , Dragan Mladjenovic Subject: [PATCH v2 3/3] [RFC][MIPS] Define GNU_STACK ABI Date: Tue, 16 Jul 2019 11:16:09 +0000 Message-ID: <1563275697-30825-3-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-oob-tlc-oobclassifiers: OLM:2331; received-spf: None (protection.outlook.com: wavecomp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: dmladjenovic@wavecomp.com * sysdeps/unix/sysv/linux/mips/ldsodefs.h (VALID_ELF_ABIVERSION): Bump max ABI version for ELFOSABI_SYSV to 6. * sysdeps/unix/sysv/linux/mips/libc-abis (GNU_STACK): New ABI. --- sysdeps/unix/sysv/linux/mips/ldsodefs.h | 2 +- sysdeps/unix/sysv/linux/mips/libc-abis | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sysdeps/unix/sysv/linux/mips/ldsodefs.h b/sysdeps/unix/sysv/linux/mips/ldsodefs.h index 803fdd1..c9835b7 100644 --- a/sysdeps/unix/sysv/linux/mips/ldsodefs.h +++ b/sysdeps/unix/sysv/linux/mips/ldsodefs.h @@ -34,7 +34,7 @@ extern void _dl_static_init (struct link_map *map); #undef VALID_ELF_ABIVERSION #define VALID_ELF_ABIVERSION(osabi,ver) \ (ver == 0 \ - || (osabi == ELFOSABI_SYSV && ver < 4) \ + || (osabi == ELFOSABI_SYSV && ver < 6) \ || (osabi == ELFOSABI_GNU && ver < LIBC_ABI_MAX)) diff --git a/sysdeps/unix/sysv/linux/mips/libc-abis b/sysdeps/unix/sysv/linux/mips/libc-abis index eaea558..cdf413b 100644 --- a/sysdeps/unix/sysv/linux/mips/libc-abis +++ b/sysdeps/unix/sysv/linux/mips/libc-abis @@ -16,3 +16,5 @@ UNIQUE MIPS_O32_FP64 mips*-*-linux* # Absolute (SHN_ABS) symbols working correctly. ABSOLUTE +# Non-executable stack support working correctly +MIPS_GNU_STACK mips*-*-linux*