Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Apr 2011 17:02:16 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        current@freebsd.org
Cc:        ports@freebsd.org
Subject:   NX stacks on amd64 and powerpc
Message-ID:  <20110425140216.GI48734@deviant.kiev.zoral.com.ua>

next in thread | raw e-mail | index | archive | help

--LFN/h9p3ZzIorjyq
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

I added a support for non-executable stacks on amd64 and PowerPC
architectures some time ago, but did not enabled it. Passed time allowed
to fix some bugs in the implementation, and I consider it would be good
to have NX stacks enabled for architectures that support it.

I plan to commit the following knob twiddle in approximately a week.
Some ports, if any, that erronously handle PT_GNU_STACK phdr may break.

Anybody interested should and could test the change before the commit,
by setting sysctl kern.elf64.nxstack and kern.elf32.nxstack to 1.


diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index b41741a..7358e40 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -116,7 +115,12 @@ static int elf_legacy_coredump =3D 0;
 SYSCTL_INT(_debug, OID_AUTO, __elfN(legacy_coredump), CTLFLAG_RW,=20
     &elf_legacy_coredump, 0, "");
=20
-static int __elfN(nxstack) =3D 0;
+static int __elfN(nxstack) =3D
+#if defined(__amd64__) || defined(__powerpc__) /* both 64 and 32 bit */
+	1;
+#else
+	0;
+#endif
 SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO,
     nxstack, CTLFLAG_RW, &__elfN(nxstack), 0,
     __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) ": enable non-executable sta=
ck");

--LFN/h9p3ZzIorjyq
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (FreeBSD)

iEYEARECAAYFAk21fuUACgkQC3+MBN1Mb4jAfACfdORTV/jFy9b2ue6EugbyLRf1
zDMAniPXcyuURzmVw/5P/Yryq8BfotQc
=kMuV
-----END PGP SIGNATURE-----

--LFN/h9p3ZzIorjyq--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110425140216.GI48734>