Gentoo Archives: gentoo-hardened

From: Alexander Gabert <pappy@g.o>
To: "Peter S. Mazinger" <ps.m@×××.net>
Cc: gentoo-hardened@g.o, pageexec@××××××××.hu
Subject: Re: [gentoo-hardened] Re: hardened-gcc-3.3.2.1
Date: Mon, 15 Dec 2003 13:10:51
Message-Id: 1071514816.23584.12.camel@camille.external
In Reply to: [gentoo-hardened] Re: hardened-gcc-3.3.2.1 by "Peter S. Mazinger"
1 Hi Peter,
2
3 > > # conservative PIE PIC and SSP options, on by default, suppress flags
4 > > take precedence
5 > > HGCC_33_DEFAULT_SPECS_CPP_SECTION_PIC_ACTIVATION="%{!yet_exec: %{!nopie:
6 > > -D__PIC__ -D__pic__ -DPIC}}"
7 > omitted -Dpic (although I haven't found any app needing it).
8 -Dpic is bad because apache2 for example uses a pointer for ip
9 addresses, called "pic", when you define pic, this will bail out with a
10 very very odd error message.
11 thanks go fully to solar for making this shortcut and slapping my weak
12 head for this mistake.
13
14 > > HGCC_33_DEFAULT_SPECS_CC1_SECTION_PIC_ACTIVATION="%{!yet_exec: %{!nopie:
15 > > -fPIC -fpie}}"
16 > Why have you added -fpie?
17 because i thought it is the gcc accomodating flag to ld -pie
18 > this has the problems with libraries as described earlier (try
19 > zlib-1.2.1.ebuild, comment the pic patch and build the shared lib, check
20 > with readelf -d for TEXTREL. I have to remove -fpie from it, also if it
21 hmmm, very odd, i dont think its the -fpie, but we need to look at it in
22 detail
23 > somehow could work, I think it should be
24 > %{!yet_exec: %{!nopie: -fPIC %{!static|!shared: -fpie}}} (the static part
25 thanks, i will think about it and test it here, maybe pipacs can help us
26 here too.
27 > is solved probably with %{!static: %{pie:-pie}} at the end of the
28 > specfile, but for shared libs I do not think -fpie is good.
29 well, we need to find out what -fpie does
30 >
31 > > HGCC_33_DEFAULT_SPECS_CC1_SECTION_SSP_ACTIVATION="%{!yno_propolice:
32 > > %{!fno-stack-protector: -fstack-protector %{!fno-stack-protector-all:
33 > > -fstack-protector-all -fforce-addr}}}"
34 >
35 > I like this one better, have you checked that fforce is only needed by
36 > -all?
37 no, fforce-addr is needed by newer gcc's with high optimizations.
38 afaik we can take it out for sure
39 on the other hand, it does not hurt any building other than assembler
40 hardcore where we already filter on hardened-gcc, speak kernel and boot
41 loaders...
42 i think the real line would be
43 HGCC_33_DEFAULT_SPECS_CC1_SECTION_SSP_ACTIVATION="%{!yno_propolice:
44 %{!fno-stack-protector: -fforce-addr -fstack-protector
45 %{!fno-stack-protector-all: -fstack-protector-all}}}"
46
47 > # the Scrt1.o provided by Redhat has relocation errors when -pie builds
48 > > executables with -shared and no main function
49 > > HGCC_33_DEFAULT_SPECS_STRTSECTION_CRT_ACTIVATION="crt1S.o"
50 >
51 > I'll stay with my Scrt1.o for uClibc then (I do not have another one ;-)
52 yeah, i talked about this also earlier
53 you could do the -fpie exclude for crt1.o and Scrt1.o also:
54 18:37:11 <pappy-> while this is not the -shared -pie problem that the
55 Scrt1.o has unresolved relocation error against nonexisting
56 main()
57 18:37:24 <pappy-> i think we could filter -shared
58 18:37:26 <pappy-> and filter -static
59 18:37:31 <pappy-> and either use crt1S.o from pipacs or the natural
60 crt1.o from glibc for them
61
62 so the line would look like: %{!static: %{!shared: Scrt1.o}} otherwise
63 the respective %{!static|shared: crt1.o} line applies, i will introduce
64 this into a later version of hardened-gcc i think.
65 >
66 > > # final static linking executables breaks when -pie is given
67 > > HGCC_33_DEFAULT_SPECS_LINKSECTION_PIE_ACTIVATION="%{!yet_exec: %{!nopie:
68 > > %{!static: -pie -z combreloc}}}"
69 > this is the same as earlier and provides one of the doubles.
70 yeah, i saw it now, i will remove the static from the config entry too,
71 thanks again
72 >
73 > >
74 > > can you please try these lines in hcc.conf and activate them?
75 > >
76 > > TIA,
77 > >
78 > > Alex
79 > >
80 > > On Mon, 2003-12-15 at 15:06, Peter S. Mazinger wrote:
81 > > > On Mon, 15 Dec 2003, Peter S. Mazinger wrote:
82 > > >
83 > > > New problem: I have rebuilt rpm-4.0.4 and got text relocation in
84 > > > librpmbuild shared library hardened-gcc-3.3.2.0 worked)
85 > > > I think we have to enforce -fPIC for all (also for static, because if
86 > > > later a binary is built against static and dynamic libraries, it will have
87 > > > problems (like bash's included readline, this is static)
88 > > > The problem happens with libraries due to the change in cc1 section from
89 > > > -fPIC to -fPIC -fpie (simple test: build zlib w/o the pic patch)
90 > > >
91 > > > > Hello!
92 > > > >
93 > > > > The link section has a !static redundancy (from EXC_FRONT and
94 > > > > PIE_ACTIVATION), see attached diff (edited manually based on hcc.conf and
95 > > > > the scripts)
96 > > > >
97 > > > > Why is crt1S.o added in the default config, the conservative one adds
98 > > > > Scrt1.o? (crt1S.S is the same as in hardened 2.4.6 non_csu version), it is
99 > > > > rather a glibc issue having it or not.
100 > > > >
101 > > > > Also I am not so sure about the stack-protector[-all] running together, I
102 > > > > have the impression, that they work separately, but for all cases I would
103 > > > > suggest the possibility to use only fstack-protector if -all is
104 > > > > deactivated (there could be some apps that cannot be built with -all) like
105 > > > > this, or similar
106 > > > > %{!yno_propolice: %{!fno-stack-protector: -fstack-protector}
107 > > > > %{!fno-stack-protector-all: -fstack-protector-all}}.
108 > > > >
109 > > > > I do not really know which one needs fforce-addr (the kernel works with
110 > > > > both, using my patch -earlier mail, but does not like fforce-addr).
111 > > > > So adapt accordingly.
112 > > > >
113 > > > > Peter
114 > > > >
115 > > > >
116 > >
117 --
118 Alexander Gabert <pappy@g.o>
119 http://www.gentoo.org/proj/en/hardened
120
121
122 --
123 gentoo-hardened@g.o mailing list

Replies

Subject Author
Re: [gentoo-hardened] Re: hardened-gcc-3.3.2.1 "Peter S. Mazinger" <ps.m@×××.net>