Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 267335 - i486-gentoo-linux-uclibc SSP build segfaults
Summary: i486-gentoo-linux-uclibc SSP build segfaults
Status: RESOLVED DUPLICATE of bug 470608
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: The Gentoo Linux Hardened Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-24 14:14 UTC by Gordon Schumacher
Modified: 2013-09-12 20:26 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gordon Schumacher 2009-04-24 14:14:15 UTC
A i486-gentoo-linux-uclibc toolchain produces binaries that segfault if built with SSP support.  This does not appear to be affected by C/CXX/LDFLAGS or USE flag changes.

A working toolchain is produced with:
USE="-* hardened" crossdev -t i486-gentoo-linux-uclibc

But the following produces the broken toolchain:
USE="-* hardened ssp" crossdev -t i486-gentoo-linux-uclibc


Package versions:
Binutils	2.19.1-r1
Linux-headers	2.6.28-r1
GCC		4.3.3-r2
uClibc		0.9.30.1-r1

Reproducible: Always

Steps to Reproduce:
//=== gcctest.c ===//
#include <stdio.h>
int main(int argc, char* argv[])
{
   int i;
   for (i = 0; i < argc; ++i)  printf("%d: %s\n", i, argv[i]);
   return 0;
}
end_gcctest_c


# Build a toolchain
USE="-* hardened ssp" crossdev -t i486-gentoo-linux-uclibc

# This will output:
# 0: ./gcctest
# 1: foo
x86_64-pc-linux-gnu-gcc -o gcctest gcctest.c && ./gcctest foo

# This will segfault
i486-gentoo-linux-uclibc-gcc -o gcctest gcctest.c && ./gcctest foo



emerge --info:

Portage 2.2_rc30 (!../usr/portage/base/profiles/default/linux/amd64/2008.0, gcc-4.3.3, glibc-2.9_p20081201-r2, 2.6.29-gcs-r1-gcs x86_64)
=================================================================
System uname: Linux-2.6.29-gcs-r1-gcs-x86_64-Intel-R-_Core-TM-2_Duo_CPU_T9300_@_2.50GHz-with-gentoo-2.0.0
Timestamp of tree: Unknown
dev-lang/python:     2.5.4-r2, 2.6.1-r1
sys-devel/autoconf:  2.63-r1
sys-devel/automake:  1.10.2
sys-devel/binutils:  2.19.1-r1
sys-devel/libtool:   2.2.6a
virtual/os-headers:  2.6.28-r1
ACCEPT_KEYWORDS="amd64 ~amd64"
CFLAGS="-march=core2 -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/udev/rules.d"
CXXFLAGS="-O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="distlocks fixpackages parallel-fetch preserve-libs protect-owned sandbox sfperms strict unmerge-orphans userfetch"
GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="acl alsa amd64 berkdb bzip2 cdr cli cracklib crypt cups dri dvd dvdr dvdread encode fortran gdbm gif gpm iconv ipv6 isdnlog jpeg mad midi mmx mp3 mpeg mudflap multilib ncurses nls nptl nptlonly ogg openmp pam pcre perl png pppd python readline reflection session spl sse sse2 ssl sysfs tcpd tiff truetype unicode vorbis xml xorg zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" USERLAND="GNU" VIDEO_CARDS="fbdev glint i810 intel mach64 mga neomagic nv r128 radeon savage sis tdfx trident vesa vga via vmware voodoo"
Unset:  EMERGE_DEFAULT_OPTS, PORTDIR_OVERLAY


Let me know what additional information I can provide; I'm presently building a cross-gdb so perhaps I can figure out what is segfaulting.
Comment 1 Gordon Schumacher 2009-04-24 14:20:23 UTC
Er, sorry... couldn't remember which issue I was tracking.  I'm building the cross-gdb to tackle a different issue; I will be building a *native* gdb to chase this one :)
Comment 2 Peter Alfredsen (RETIRED) gentoo-dev 2009-05-05 23:41:24 UTC
Hardened, this looks like your alley.
Comment 3 Magnus Granberg gentoo-dev 2009-08-09 00:38:29 UTC
jasmin / # gcc -Os -fstack-protector-all gcctest.c -o gcctest
jasmin / # ./gcctest
0: ./gcctest
jasmin / # ./gcctest foo
0: ./gcctest
1: foo
jasmin / #
jasmin / # emerge --info
Portage 2.1.6.13 (uclibc/x86, gcc-4.4.1, uclibc-0.9.30.1-r1, 2.6.28-gentoo-r3 i686)
Added the patch gcc4-stack-protector-uclibc-no_tls.patch to GCC from #149292
It segfaulted before the patch.
Comment 4 Anthony Basile gentoo-dev 2013-09-12 14:37:28 UTC
(In reply to Magnus Granberg from comment #3)
> jasmin / # gcc -Os -fstack-protector-all gcctest.c -o gcctest
> jasmin / # ./gcctest
> 0: ./gcctest
> jasmin / # ./gcctest foo
> 0: ./gcctest
> 1: foo
> jasmin / #
> jasmin / # emerge --info
> Portage 2.1.6.13 (uclibc/x86, gcc-4.4.1, uclibc-0.9.30.1-r1,
> 2.6.28-gentoo-r3 i686)
> Added the patch gcc4-stack-protector-uclibc-no_tls.patch to GCC from #149292
> It segfaulted before the patch.

I can't speak directly to this bug, but as far as uclibc-0.9.33.2, if you enable tls and nptl, then you shouldn't have any problems with hardening.  All the hardened stages on the mirrors under /experimental/<arch>/uclibc are configured this way and they "just work".

I'm really not sure how to deal with this except to say, if you want hardening then you need the following in your uclibc config.  Since uclibc is configurable, unlike glibc, you must expect that if some needed feature is missing, then you get breakage.

# HAS_NO_THREADS is not set
# LINUXTHREADS_OLD is not set
# LINUXTHREADS_NEW is not set
UCLIBC_HAS_THREADS_NATIVE=y
UCLIBC_HAS_THREADS=y
UCLIBC_HAS_TLS=y
PTHREADS_DEBUG_SUPPORT=y


Finally, I really don't want the gcc4-stack-protector-uclibc-no_tls.patch back because that's just hacky stuff and we can now do it properly.

I'd close obsolete.
Comment 5 Anthony Basile gentoo-dev 2013-09-12 18:40:55 UTC
As per discussion in IRC, this one is done.
Comment 6 Anthony Basile gentoo-dev 2013-09-12 20:26:11 UTC
Perhaps the best approach here is as in bug #470608 where we should stub stack_guard.

*** This bug has been marked as a duplicate of bug 470608 ***