Date: Tue, 18 Oct 2011 13:06:27 -0400 From: Arnaud Lacombe <lacombar@gmail.com> To: Oliver Pinter <oliver.pntr@gmail.com> Cc: Garrett Cooper <yanegomi@gmail.com>, Kostik Belousov <kostikbel@gmail.com>, current@freebsd.org Subject: Re: [RFC] Enable nxstack by default Message-ID: <CACqU3MXm1P1P2FBMCKhYOC%2BeCn_3QyQmd98b%2B_Kiq98usuqiPA@mail.gmail.com> In-Reply-To: <CAPjTQNE5-kGJ%2BD2c3Z2y-e_h95i5VY0Yc=C26BJ_Oq0n2DNz6A@mail.gmail.com> References: <CAPjTQNFCT5LBKwVQFf9FHk4aTzrJ243j2uN1nPmMeFp=cTdMUA@mail.gmail.com> <20111018090750.GG50300@deviant.kiev.zoral.com.ua> <CACqU3MWftO=FG4GbnKCFjTcKg1narJWuYnCwv-Mcu=WGriScwA@mail.gmail.com> <alpine.BSF.2.00.1110180838200.38610@toaster.local> <CACqU3MWOXTMfu0LySukcwAz=NGSzyN=ettiY0fQj3Ehp5MONug@mail.gmail.com> <CAPjTQNE5-kGJ%2BD2c3Z2y-e_h95i5VY0Yc=C26BJ_Oq0n2DNz6A@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi, On Tue, Oct 18, 2011 at 12:53 PM, Oliver Pinter <oliver.pntr@gmail.com> wro= te: > On 10/18/11, Arnaud Lacombe <lacombar@gmail.com> wrote: >> Hi, >> >> On Tue, Oct 18, 2011 at 11:44 AM, Garrett Cooper <yanegomi@gmail.com> wr= ote: >>> On Tue, 18 Oct 2011, Arnaud Lacombe wrote: >>> >>>> Hi, >>>> >>>> On Tue, Oct 18, 2011 at 5:07 AM, Kostik Belousov <kostikbel@gmail.com> >>>> wrote: >>>>> >>>>> On Mon, Oct 17, 2011 at 09:30:56PM +0200, Oliver Pinter wrote: >>>>>> >>>>>> Hi all! >>>>>> >>>>>> I think, it's the time to enable the nxstack feature. Any comments, >>>>>> pros, cons? >>>>> >>>>> I dragged the change long enough for it to miss the 9.0. >>>>> After the 9.0 is released, I will flip the switch with the following >>>>> change. >>>>> >>>>> diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c >>>>> index 8455f48..926fe64 100644 >>>>> --- a/sys/kern/imgact_elf.c >>>>> +++ b/sys/kern/imgact_elf.c >>>>> @@ -118,7 +118,12 @@ static int elf_legacy_coredump =3D 0; >>>>> =A0SYSCTL_INT(_debug, OID_AUTO, __elfN(legacy_coredump), CTLFLAG_RW, >>>>> =A0 =A0 &elf_legacy_coredump, 0, ""); >>>>> >>>>> -static int __elfN(nxstack) =3D 0; >>>>> +int __elfN(nxstack) =3D >>>>> +#if defined(__amd64__) || defined(__powerpc64__) /* both 64 and 32 b= it >>>>> */ >>>>> >>>> Why leaving 32bits x86 CPU supporting the NX feature behind ? >>> >>> Most likely because it was assumed that i386 doesn't fully support it. >>> According to ye great Wikipedia, NX support didn't roll into i386 until >>> Prescott, which was pretty late in the non-64-bit capable family of CPU= s, >>> as >>> its successor -- Conroe -- was 64-bit. Intel detuned some of the early >>> Dual >>> Core Pentiums, e.g. the Yonahs to not talk 64-bit. Not sure about AMD. >>> >>> There are probably more details in binutils, gcc, etc, that I'm missing >>> and >>> Kostik can expound on. >>> >> NX support is advertised in the cpuid flags, just add the logic to >> handle this interface. Kostik's patch is just incomplete, but he's got >> a commit bit so he can commit it as-is, as he will. >> >> If nonexec_stack becomes the default, it should be on every CPU >> supporting the feature, not just the low-hanging one. >> >> =A0- Arnaud >> > > the NX detection code already implemented in i386, but this feature > required PAE: > yes, this is the conclusion I reached too. But this does not change the fact that the VM should know about that, and this is missing from Kostik's patch. I guess the first hunk should read: @@ -118,7 +118,12 @@ static int elf_legacy_coredump =3D 0; SYSCTL_INT(_debug, OID_AUTO, __elfN(legacy_coredump), CTLFLAG_RW, &elf_legacy_coredump, 0, ""); -static int __elfN(nxstack) =3D 0; +int __elfN(nxstack) =3D +#if defined(PAE) || defined(__amd64__) || defined(__powerpc64__) /* 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 stac= k"); - Arnaud
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CACqU3MXm1P1P2FBMCKhYOC%2BeCn_3QyQmd98b%2B_Kiq98usuqiPA>