This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH v3] Mips support for PT_GNU_STACK
- From: Dragan Mladjenovic <dmladjenovic at wavecomp dot com>
- To: "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>
- Cc: Dragan Mladjenovic <dmladjenovic at wavecomp dot com>, Joseph Myers <joseph at codesourcery dot com>, Carlos O'Donell <carlos at redhat dot com>, Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, "Maciej W . Rozycki" <macro at linux-mips dot org>, Faraz Shahbazker <fshahbazker at wavecomp dot com>
- Date: Sun, 4 Aug 2019 16:30:17 +0000
- Subject: [PATCH v3] Mips support for PT_GNU_STACK
- 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
- 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-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aWFViDZZDnJTiY8R0Sz6pA9qyWtxbtlmlulDma2pVy7qUffhmXTBcMTOBL4XNg1wR5HXNyPsK1Q9viWOeevZa7eEBx7fhute5VLawgw1ENjabSvywTM3O8lSJKVMOnvWqKBFIyo1B/fKOhB8boQXmERwohe97+1Ln7u24DrSko3m06wKNsinjNd7sD/iQjwPkyoJcWsbH8Hfkvv5jZphSYwxei+SUJT825yqQkseioZjfLgDM3bdG2evH0fj7JebX1GnmAtroKQEG6Sb7nrhhkBR2wYgONPamm9AgTOPU8dSnEFZAv1vfAUYZfeNKT+rxv2bc2LoFQgN4Lk0qa249w==
From: "Dragan Mladjenovic" <dmladjenovic@wavecomp.com>
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 <dmladjenovic@wavecomp.com>
* 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
-# <https://sourceware.org/ml/libc-alpha/2016-01/msg00567.html> and
-# <https://sourceware.org/ml/libc-alpha/2016-01/msg00719.html>.
+# 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
--
1.9.1