Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 119382 - Hardened support for gnat
Summary: Hardened support for gnat
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Kevin F. Quinn (RETIRED)
URL: http://dev.gentoo.org/~kevquinn/gnat
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-18 00:03 UTC by Kevin F. Quinn (RETIRED)
Modified: 2008-02-04 21:03 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
add PaX marking to bootstrap compiler (gnatbuild.eclass.diff,773 bytes, patch)
2006-01-22 06:52 UTC, Kevin F. Quinn (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin F. Quinn (RETIRED) gentoo-dev 2006-01-18 00:03:18 UTC
This bug is for issues related to using gnat on hardened systems.

The first issue is for PaX kernels, which kill the bootstrap compiler when it tries to use a trampoline.  Adding the appropriate PaX marking to the gnat1 compiler is sufficient to overcome this.
Comment 1 Kevin F. Quinn (RETIRED) gentoo-dev 2006-01-22 06:51:56 UTC
ok; committed the pax-utils.eclass, so to sort out the PaX issue on the bootstrap compiler it's enough to inherit pax-utils and add:

pax-mark -execstack $(find ${GNATBOOT} -name gnat1)

to the base_unpack) section in gnatbuild.eclass (patch to follow for clarity).


The remaining issues for hardened are the possibility of removing the requirement for executable stack from the compiler itself and gnatlib.

I'll post here when I have some results.


Comment 2 Kevin F. Quinn (RETIRED) gentoo-dev 2006-01-22 06:52:41 UTC
Created attachment 77819 [details, diff]
add PaX marking to bootstrap compiler
Comment 3 George Shapovalov (RETIRED) gentoo-dev 2007-02-15 15:28:22 UTC
Hi Kevin

Thanks for this fix! And sorry for delay - my stored ada search did not look for ada@g.o in CC :(. Anyway, I added this fix (tested on non-hardened system Ok) to the eclass.

Also, what about the execstacks? Is there any reasonable possibility of it being fixed or should we simply QA mark necessary files and forget about it?

George
Comment 4 Kevin F. Quinn (RETIRED) gentoo-dev 2007-02-15 22:54:42 UTC
ooh; that patch was somewhat out of date :)
the line needs to be:

pax-mark E $(find ${GNATBOOT} -name gnat1)

sorry about that.

re removing the execstacks in gnatlib - no progress yet (!) - been doing other stuff.  I think more instances have been added since I last looked...
Comment 5 Kevin F. Quinn (RETIRED) gentoo-dev 2007-02-15 22:56:43 UTC
meant to say - I'm away for a few days, I'll look at the execstack thing again propertly when I get back.
Comment 6 PaX Team 2007-04-24 10:09:33 UTC
i wonder, where do the nested function trampolines occur in gnat? in the main executable itself or some library only? i'm asking it because in the former case gcc/ld should have already marked the executable with -E. also, are we really talking about the gcc style nested function trampolines here at all? the EMUTRAMP logic assumes/emulates specific insn sequences only, if gnat has its own, they need to be added explicitly in PaX.
Comment 7 Kevin F. Quinn (RETIRED) gentoo-dev 2007-04-24 18:18:24 UTC
They're in a library, and in code that forms part of the compiler driver.  Once the bootstrap is marked, the compilation successfully builds gnat1 (the Ada compiler driver) with the correct markings.

We are talking standard GCC trampolines (the backend is the unchanged).  It's natural in Ada to express nested subprograms; on strict Ada83 and Ada95 standard compilers these are implementable without a trampoline (since the language restricts calls to nested subprograms to the scope of their _declaration_ rather than just the scope of their runtime creation).  The GNAT people however extended the language to provide the C-style ability to reference a nested function outside of the scope of its declaration (and introduced the ability therefore to write bad code that called such nested functions when they are out of their run-time scope), so they could implement things like a generic 'sort' (IIRC) the same way the C library does.  I had hoped to rewrite the relevant sections of the Ada front-end to eliminate the execstack requirement from the compiler, and also to look at providing a variation of the sort & hashing stuff provided by gnatlib that wouldn't require execstack.  However time has been extremely short...
Comment 8 Philipp Riegger 2007-09-05 12:09:22 UTC
Which versions of gnat are fixed for pax kernels? I get this error:

Sep  4 22:52:29 chris PAX: From 192.168.0.6: execution attempt in: <anonymous mapping>, 5c21d000-5c235000 5c21d000
Sep  4 22:52:29 chris PAX: terminating task: /var/tmp/portage/dev-lang/gnat-gcc-3.4.6/work/usr/bin/gnat1(gnat1):15369, uid/euid: 250/250, PC: 5c2301e0, SP: 5c23018c
Sep  4 22:52:29 chris PAX: bytes at PC: b9 10 02 23 5c e9 96 91 fa ab 00 00 30 e0 00 00 b9 10 02 23 
Sep  4 22:52:29 chris PAX: bytes at SP-4: 5c2301a8 081235ec 00000001 00000000 5c2301a8 5c2301b0 00000003 00000001 5c230228 081d9498 00000003 5c2301e0 5c2301f0 0000e030 5c2301e0 081170a2 5c230190 0000e030 00005133 00005134 00000003 
Comment 9 PaX Team 2007-09-14 07:07:30 UTC
(In reply to comment #8)
> Which versions of gnat are fixed for pax kernels?

i think none is, the short term solution should be to paxctl -E gnat1 and other executables that link to the libraries with trampolines.
Comment 10 George Shapovalov (RETIRED) gentoo-dev 2008-01-23 22:05:37 UTC
Does not look like there is going to be any activity on this in any foreseeable future. Should we close this bug with LATER?
Comment 11 Kevin F. Quinn (RETIRED) gentoo-dev 2008-02-04 21:03:33 UTC
(In reply to comment #10)
> Does not look like there is going to be any activity on this in any foreseeable
> future. Should we close this bug with LATER?

You're right - haven't had time for over a year, that's not likely to change...
There's probably very few people, if any, actually interested.

Closing WONTFIX