From patchwork Sun Aug 4 16:30:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dragan Mladjenovic X-Patchwork-Id: 1141793 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-104151-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="tdaj1r1O"; dkim=pass (1024-bit key; unprotected) header.d=wavecomp.com header.i=@wavecomp.com header.b="Uj6UgAyb"; 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 461mbv5fYfz9sDB for ; Mon, 5 Aug 2019 02:30:51 +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 :content-type:content-transfer-encoding:mime-version; q=dns; s= default; b=F9ChF9MoPhHjo2UtA6eX1DFdKAIMHenPeZL2oAl5t8f6eHYRCMVrc Mq+5W+9vF7vh2uEgs8XjhRD561H965P8znFe9AnZkfX+PhSm44tf6h2LkdDAfIk6 AXJhL4zjkWS57OO3kUA/q83JAzD5W/Hv8KDN6tzUpDBK6pf8y3gzm0= 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 :content-type:content-transfer-encoding:mime-version; s=default; bh=FbYH0Idwd25E4WEQKXvmwFfpmWc=; b=tdaj1r1Od/kj/P+xNMF2YkIKOMvk 53sl970X8B6Nk//Qiy1FPRkktGnIFMmXWjJOz6qT5q7nH+taW0Bu+bQjPnWsCUnf rq7V1WZUPS9D0qWgt+jMIv9XYNT+P+gtAl9+4ZxufJbulS8G17eRGUMRYaRU5G/o C+hcOA/1q2aU5ds= Received: (qmail 125785 invoked by alias); 4 Aug 2019 16:30:40 -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 125696 invoked by uid 89); 4 Aug 2019 16:30:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.1 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=H*Ad:U*macro, third, 4.8, HCC:D*com X-HELO: NAM02-CY1-obe.outbound.protection.outlook.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aWFViDZZDnJTiY8R0Sz6pA9qyWtxbtlmlulDma2pVy7qUffhmXTBcMTOBL4XNg1wR5HXNyPsK1Q9viWOeevZa7eEBx7fhute5VLawgw1ENjabSvywTM3O8lSJKVMOnvWqKBFIyo1B/fKOhB8boQXmERwohe97+1Ln7u24DrSko3m06wKNsinjNd7sD/iQjwPkyoJcWsbH8Hfkvv5jZphSYwxei+SUJT825yqQkseioZjfLgDM3bdG2evH0fj7JebX1GnmAtroKQEG6Sb7nrhhkBR2wYgONPamm9AgTOPU8dSnEFZAv1vfAUYZfeNKT+rxv2bc2LoFQgN4Lk0qa249w== 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=cnsgIDNagbWJ553lNhZ+rPD0X9dPmffcBGUOhb+A6CM=; b=Px8BB6taR9wV7nQzVEoBG2UD6knyfiNPOpXnbfgsMw5MxJ8zNOmj8JR/hRq7zioFgTMYH9TJtWirU5CryiqBOp+2RjY6F3M7j+Thy4IkE5ZAjRXW/AMdQ5PpzoXATGs2EPBmcqgx8NDnPHePouEUECiROlfd0gWDe/bmU15NcZvWY7WIwKIGaDPkLteXo0kH49waJ7DWUJLtrMkHR6BpDpl+l2GyI8da2vIOcCwSbg4+/gBRXETYdKjRWTOGIADDO0o5CrZabc51j2FtIuXqwpBb3RmaO0ZaUX/GxIHO9tmzaWBfTXoKcszgreRZygY0oeXjxSwQNuWv3PP2C/mJLw== 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=wavecomp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cnsgIDNagbWJ553lNhZ+rPD0X9dPmffcBGUOhb+A6CM=; b=Uj6UgAybs6USSV2rrH/nznj2CT0sEr5MM0LjSFKN5zN50EeoMc0zBdddJWMn0+a9P2H2YmqpIZRhOC2SZznW5fnfmC/0Nk77ImBocnJaz3EWHZcyywjkkJRVDV1kt1yy4lP18/3ClJsKe4hczZY0tC4bCKCrZlhpLlI7sf0RTVQ= From: Dragan Mladjenovic To: "libc-alpha@sourceware.org" CC: Dragan Mladjenovic , Joseph Myers , Carlos O'Donell , Adhemerval Zanella , "Maciej W . Rozycki" , Faraz Shahbazker Subject: [PATCH v3] Mips support for PT_GNU_STACK Date: Sun, 4 Aug 2019 16:30:17 +0000 Message-ID: <1564936138-30899-1-git-send-email-dmladjenovic@wavecomp.com> authentication-results: spf=none (sender IP is ) smtp.mailfrom=dmladjenovic@wavecomp.com; x-ms-exchange-purlcount: 5 x-ms-oob-tlc-oobclassifiers: OLM:9508; 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 From: "Dragan Mladjenovic" Hello everyone, This is a third attempt to enable glibc to safely handle PT_GNU_STACK on Linux/Mips. You can check out the previous discussion about this issue at [1] and [2]. A brief summary of the issue this is trying to address: Up until the Linux kernel version 4.8 [3] MIPS FPU emulator used a small trampoline, created on user stack, to handle delay slots when emulating FPU branches. Because of this non-executable stack could not be enabled by default on MIPS. The compatibility issue is that these old kernels respect PT_GNU_STACK, making the stack non-executable if requested, and could crash the user process if there would be need to emulate an instruction in the delay slot of an FPU branch. In order to allow for the tool-chain to safely use PT_GNU_STACK by default, this patch bumps the minimum kernel version to 4.8 for the hard-float builds done with GNU.stack enabled tool-chain. It would be nice if this could be back-ported as far back as glibc's policy allows. Will be posting gcc side of the patch soon. Best regards, Dragan [1] https://sourceware.org/ml/libc-alpha/2019-06/msg00889.html [2] https://sourceware.org/ml/libc-alpha/2019-07/msg00280.html [3] https://github.com/torvalds/linux/commit/432c6bacbd0c16ec210c43da411ccc3855c4c010 2019-08-04 Dragan Mladjenovic * sysdeps/unix/sysv/linux/mips/Makefile (test-xfail-check-execstack): Move under mips-has-gnustack != yes. * sysdeps/unix/sysv/linux/mips/configure.ac (mips-has-gnustack): New var. Use value of libc_cv_as_noexecstack. Set arch_minimum_kernel=4.8.0 for hard-float, noexecstack builds. * sysdeps/unix/sysv/linux/mips/configure: Regenerated. --- sysdeps/unix/sysv/linux/mips/Makefile | 9 ++++----- sysdeps/unix/sysv/linux/mips/configure.ac | 5 +++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/sysdeps/unix/sysv/linux/mips/Makefile b/sysdeps/unix/sysv/linux/mips/Makefile index 8217f42..e9206fa 100644 --- a/sysdeps/unix/sysv/linux/mips/Makefile +++ b/sysdeps/unix/sysv/linux/mips/Makefile @@ -63,13 +63,12 @@ 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 -# . +# If the compiler doesn't use GNU.stack note, +# this test is expected to fail. +ifneq ($(mips-has-gnustack),yes) test-xfail-check-execstack = yes endif +endif ifeq ($(subdir),stdlib) gen-as-const-headers += ucontext_i.sym diff --git a/sysdeps/unix/sysv/linux/mips/configure.ac b/sysdeps/unix/sysv/linux/mips/configure.ac index 9147aa4..b195137 100644 --- a/sysdeps/unix/sysv/linux/mips/configure.ac +++ b/sysdeps/unix/sysv/linux/mips/configure.ac @@ -118,6 +118,8 @@ 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}]) + case $machine in mips/mips64/n64/*) LIBC_SLIBDIR_RTLDDIR([lib64], [lib64]) @@ -133,4 +135,7 @@ if test -z "$arch_minimum_kernel"; then if test x$libc_cv_mips_nan2008 = xyes; then arch_minimum_kernel=4.5.0 fi + if test x"$libc_cv_as_noexecstack" = xyes -a x"$libc_mips_float" = xhard; then + arch_minimum_kernel=4.8.0 + fi fi