Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 32740 - Can anything be done to enable xfree modules with hardened-gcc?
Summary: Can anything be done to enable xfree modules with hardened-gcc?
Status: RESOLVED CANTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: Normal enhancement (vote)
Assignee: Alexander Gabert (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-11-04 13:51 UTC by Radoslaw Szkodzinski
Modified: 2003-11-14 11:56 UTC (History)
1 user (show)

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


Attachments
xfree-4.3.0-r3.ebuild.patch (x,760 bytes, patch)
2003-11-04 13:54 UTC, Radoslaw Szkodzinski
Details | Diff
xfree-4.3.0-r3.ebuild.patch v2 (x,580 bytes, patch)
2003-11-04 15:19 UTC, Radoslaw Szkodzinski
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Radoslaw Szkodzinski 2003-11-04 13:51:13 UTC
I've designed an enhanced check which can detect if xfree is compiled
by hardened-gcc, but with forced propolice disabled through hcc.
You can still have -fstack-protector in CFLAGS.
It makes nvidia drivers work on hardened system.

I don't know since which version of hcc this format of output exists, you should check it.
I know it works at least for 2.4.2 and 2.4.4.
Comment 1 Radoslaw Szkodzinski 2003-11-04 13:54:22 UTC
Created attachment 20263 [details, diff]
xfree-4.3.0-r3.ebuild.patch
Comment 2 Radoslaw Szkodzinski 2003-11-04 15:19:21 UTC
Created attachment 20269 [details, diff]
xfree-4.3.0-r3.ebuild.patch v2

The problem isn't caused by propolice, but by et_dyn.
Changing the check.
Comment 3 Radoslaw Szkodzinski 2003-11-04 15:54:16 UTC
Still can't get it right, changing summary.
Comment 4 Alexander Gabert (RETIRED) gentoo-dev 2003-11-11 01:09:17 UTC
the reason why modules do not work with hardened-gcc in xfree is that the
hardened-gcc demands xfree to be built without module support, this is no
kernel module stuff, it is a proprietary load mechanism of xfree itself.

look for DoLoadServer=NO in the ebuild or something like that.
hppa even needs this always because the load mechanism is borked on this
arch.

the DoLoadServer=NO prevents modules like nvidia core drivers to load.
if you cannot accept that, do not use hardened-gcc.
The reason we need to do this is because under PaX kernels, which is what
the hardened-gcc was designed for (!), you will not even be able to run xfree
in generic module mode but instead would need to chpax it anyway if you had
this load module mechanism active.

i think its for your own good.

thanks for your attention,

Alex
Comment 5 Radoslaw Szkodzinski 2003-11-11 12:17:53 UTC
hmmm... Thank you for your explanation. So the culprit is propolice-enabled
kernel.
So probably this is why I got duplicate symbols on loading the modules even
with propolice/et_dyn disabled.
I can live with that on this machine, I was just checking if it would be
feasible to harden my terminals.
(Anyway, I'm using -fstack-protector on these, only et_dyn is missing)

Resolving CANTFIX.
Comment 6 Alexander Gabert (RETIRED) gentoo-dev 2003-11-12 03:00:40 UTC
what makes you think that propolice is kicking xfree by any means into doing this or that?

i am talking about the PaX MPROTECT feature (do not get confused with the mprotect() system call here!).

propolice is needed for linear stack overflow protection, it does not care about the proprietary module load mechanisms of programs.

PaX however does.

and this is what we did:

if users have hardened-gcc, they care about secure systems and want to employ a PaX kernel with etdyn and propolice enabled binaries.

so the reason we decided to remove the LoadServer mechanism from XFree86 when the user has hardened-gcc was simple: only few users have the nvidia modules active and yes, even they can be told not to use them ;-)

dont misunderstand this as a propolice issue or something like that, we had quite a lot of trouble with propolice in the past times and i made my mistakes but i think its all solved in 2.4.5 2.4.6 and the hopefully soon to be implemented patches for the glibc containing propolice now instead of libgcc.

anyway, i hope you understood it fully now :-)
Comment 7 solar (RETIRED) gentoo-dev 2003-11-14 02:11:49 UTC
I've got some small patches here that could use a little porting to the 
gentoo, that would allow us to have etdyn plus a LoadAbleServer if
anybody is interested in testing/porting. 
The patch changes the xfree's default behavior from an elfloader 
to a dlloader like in freebsd.
Comment 8 Alexander Gabert (RETIRED) gentoo-dev 2003-11-14 11:56:15 UTC
diff -uNr xc.old/config/cf/host.def xc/config/cf/host.def
--- xc.old/config/cf/host.def	Thu Jan  1 01:00:00 1970
+++ xc/config/cf/host.def	Mon Oct 13 14:29:04 2003
@@ -0,0 +1,6 @@
+#define DoLoadableServer YES
+#define MakeDllModules	YES

given these two options that can also be added to the ebuild the usual way:
    if has_version ">=sys-devel/hardened-gcc-1.2"; then
        einfo "setting DoLoadableServer to NO for PaX and compiler for etdyn building"
        # this is good for a pax kernel to load the xfree server without the specific module support
        # that normally prevents xfree from being memory protected, pappy
        # it only breaks some people using external nvidia core modules and such, but this is not avoidable
        echo "#define DoLoadableServer  Yes" >>config/cf/host.def
        echo "#define MakeDllModules	Yes" >>config/cf/host.def
    fi

the first one reenables the mod loader
the second one changes the proprietary loading of objects into dlopen() of natural .so, this way PaX does not kill it

now the question is:

1) who really does need this
2) who knows how insecure it is or may be in future exploits
3) what impact does it have to hardened-gcc compiling a secure by default userland

make your wishes, until then i will not add it to the ebuild.

thanks to solar for pointing out the technical fix (by Peter Busser from Adamantix)