Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 508684 - >=sys-apps/coreutils-8.22 has cp segfault during package install phase with SELinux
Summary: >=sys-apps/coreutils-8.22 has cp segfault during package install phase with S...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: SELinux (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
: 512144 516624 (view as bug list)
Depends on: 517796
Blocks:
  Show dependency tree
 
Reported: 2014-04-25 14:44 UTC by Alec Blayne
Modified: 2014-07-28 09:44 UTC (History)
8 users (show)

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


Attachments
strace of cp command (file_508684.txt,75.70 KB, text/plain)
2014-04-25 14:46 UTC, Alec Blayne
Details
emerge --info (file_508684.txt,4.31 KB, text/plain)
2014-04-25 14:47 UTC, Alec Blayne
Details
emerge urlgrabber results (file_508684.txt,12.26 KB, text/plain)
2014-04-25 14:49 UTC, Alec Blayne
Details
patch cp segfault with selinux (coreutils-patch-cp-segfault-bug-508684.patch,4.54 KB, patch)
2014-05-18 19:02 UTC, Sven Vermeulen (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alec Blayne 2014-04-25 14:44:22 UTC
urlgrabber-3.9.1-r1 is working properly but urlgrabber-3.9.1-r2, migrated to using distutils-r1, and now results in a cp segmentation fault during the installphase if selinux is enabled. It installs properly if it is disabled at boot time.

The culprit is the following command:
"cp -a --reflink=auto /var/tmp/portage/dev-python/urlgrabber-3.0.1-r2/image//_python2.7/. /var/tmp/portage/dev-python/urlgrabber-3.0.1-r2/image//", called 
by multibuild_merge_root 

the last file cp is handling before segfaulting seems to be usr/bin/urlgrabber, at this point in the strace:


lstat("/var/tmp/portage/dev-python/urlgrabber-3.9.1-r2/image//_python2.7/./usr/bin/urlgrabber", {st_mode=S_IFLNK|0777, st_size=39, ...}) = 0
lstat("/var/tmp/portage/dev-python/urlgrabber-3.9.1-r2/image/./usr/bin/urlgrabber", {st_mode=S_IFLNK|0777, st_size=39, ...}) = 0
stat("/var/tmp/portage/dev-python/urlgrabber-3.9.1-r2/image//_python2.7/./usr/bin", {st_mode=S_IFDIR|0755, st_size=20, ...}) = 0
stat("/var/tmp/portage/dev-python/urlgrabber-3.9.1-r2/image/./usr/bin", {st_mode=S_IFDIR|0755, st_size=20, ...}) = 0
unlink("/var/tmp/portage/dev-python/urlgrabber-3.9.1-r2/image/./usr/bin/urlgrabber") = 0
lgetxattr("/var/tmp/portage/dev-python/urlgrabber-3.9.1-r2/image//_python2.7/./usr/bin/urlgrabber", "security.selinux", "root:object_r:portage_tmp_t:s0", 255) = 31
readlink("/var/tmp/portage/dev-python/urlgrabber-3.9.1-r2/image//_python2.7/./usr/bin/urlgrabber", "../lib/python-exec/python2.7/url"..., 40) = 39
symlink("../lib/python-exec/python2.7/urlgrabber", "/var/tmp/portage/dev-python/urlgrabber-3.9.1-r2/image/./usr/bin/urlgrabber") = 0
open("/proc/self/task/4063/attr/fscreate", O_RDWR|O_CLOEXEC) = 3
write(3, NULL, 0)                       = 0
close(3)                                = 0
lchown("/var/tmp/portage/dev-python/urlgrabber-3.9.1-r2/image/./usr/bin/urlgrabber", 0, 0) = 0
utimensat(AT_FDCWD, "/var/tmp/portage/dev-python/urlgrabber-3.9.1-r2/image/./usr/bin/urlgrabber", {{1398350932, 637558643}, {1398350932, 637558643}}, AT_SYMLINK_NOFOLLOW) = 0
open("/proc/self/task/4063/attr/fscreate", O_RDONLY|O_CLOEXEC) = 3
read(3, "", 4095)                       = 0
close(3)                                = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0} ---
+++ killed by SIGSEGV +++

The full strace for cp is anexed here, as is the output of emerge urlgrabber and emerge --info.

Reproducible: Always

Steps to Reproduce:
1. Enable SELinux
2. emerge urlgrabber
3.
Actual Results:  
the emerge process calls a cp command that segfaults

Expected Results:  
successfull installation
Comment 1 Alec Blayne 2014-04-25 14:46:10 UTC
Created attachment 375672 [details]
strace of cp command
Comment 2 Alec Blayne 2014-04-25 14:47:12 UTC
Created attachment 375674 [details]
emerge --info
Comment 3 Alec Blayne 2014-04-25 14:49:22 UTC
Created attachment 375676 [details]
emerge urlgrabber results
Comment 4 Alec Blayne 2014-04-25 14:55:50 UTC
I'm getting the same issue with other packages, gdbus-codegen for instance.
Comment 5 Sven Vermeulen (RETIRED) gentoo-dev 2014-04-28 16:59:34 UTC
Do you get any other error messages in audit log and/or dmesg?
Comment 6 Amadeusz Sławiński 2014-05-14 12:36:51 UTC
I've also hit it with dev-util/cppcheck, the culprit seems to be

multibuild_merge_root () from multibuild.eclass

it fails at this line:
cp "${cp_args[@]}" "${src}"/. "${dest}"/;

There seems like there was some recent changes to multibuild.eclass with relation to how copying is done

http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/multibuild.eclass?view=log

I've tried two of the revisions
1.14 - works fine
1.15 - fails
Comment 7 Amadeusz Sławiński 2014-05-18 17:10:02 UTC
another package I hit it with net-wireless/aircrack-ng-1.2_beta3-r1

from dmesg:
[25218.508125] cp[22756]: segfault at 0 ip 000002c5912493ea sp 0000039238150888 error 4 in libc-2.19.so[2c5911be000+1ae000]

no denials either in permissive or enforcing

my emerge --info:

Portage 2.2.10 (hardened/linux/amd64/no-multilib/selinux, gcc-4.8.2, glibc-2.19, 3.14.3-hardened-r2 x86_64)
=================================================================
System uname: Linux-3.14.3-hardened-r2-x86_64-Intel-R-_Core-TM-_i3_CPU_M_350_@_2.27GHz-with-gentoo-2.2
KiB Mem:     2996908 total,   1490712 free
KiB Swap:    3145724 total,   3145160 free
Timestamp of tree: Sun, 18 May 2014 00:45:01 +0000
ld GNU ld (GNU Binutils) 2.24
app-shells/bash:          4.2_p47
dev-lang/python:          2.7.6-r1, 3.3.5, 3.4.0
dev-util/cmake:           2.8.12.2-r1
dev-util/pkgconfig:       0.28-r1
sys-apps/baselayout:      2.2
sys-apps/openrc:          9999
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.11.6, 1.14.1
sys-devel/binutils:       2.24-r2
sys-devel/gcc:            4.8.2
sys-devel/gcc-config:     1.8
sys-devel/libtool:        2.4.2-r1
sys-devel/make:           4.0-r1
sys-kernel/linux-headers: 3.14 (virtual/os-headers)
sys-libs/glibc:           2.19
Repositories: gentoo gamerlay local-overlay
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA AdobeFlash-11.x skype-4.0.0.7-copyright"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -march=native -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -march=native -pipe"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs clean-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox selinux sesandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync webrsync-gpg xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j4"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/gamerlay /home/amade/overlay"
SYNC=""
USE="X aac acl acpi alsa amd64 berkdb bzip2 cli cracklib crypt cxx dri dvd ffmpeg flac gdbm gif gnutls gold gpg hardened iconv icu ipv6 jpeg jpeg2k justify mmx mmxext mng modules mp3 ncurses nls nptl open_perms opengl openmp pam pax_kernel pcre png qt3support readline selinux session sse sse2 sse4_1 sse4_2 ssl ssse3 svg tcpd theora threads tiff udev unicode urandom usb v4l vaapi vdpau vim-syntax x264 xattr xcb xft xinerama xpm xtpax zlib zsh-completion" ABI_X86="64" 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" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd 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 cgi cgid 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" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en en_GB pl" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_3" QEMU_SOFTMMU_TARGETS="x86_64 ppc" RUBY_TARGETS="ruby20" USERLAND="GNU" VIDEO_CARDS="nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 8 Amadeusz Sławiński 2014-05-18 18:11:08 UTC
So as Anarchy mentioned on irc it's caused by coreutils

sys-apps/coreutils-8.21 works fine

sys-apps/coreutils-8.22 and sys-apps/coreutils-8.22-r1 both segfault
Comment 9 Sven Vermeulen (RETIRED) gentoo-dev 2014-05-18 19:01:24 UTC
It has been reported and fixed upstream since.

https://lists.gnu.org/archive/html/bug-coreutils/2014-01/msg00009.html

I've confirmed by patching coreutils locally with the upstream patch (http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=commit;h=d718331e5)

I'll attach the patch for reference as well
Comment 10 Sven Vermeulen (RETIRED) gentoo-dev 2014-05-18 19:02:04 UTC
Created attachment 377200 [details, diff]
patch cp segfault with selinux
Comment 11 Alpha Bravo 2014-06-16 18:21:23 UTC
*** Bug 512144 has been marked as a duplicate of this bug. ***
Comment 12 Sven Vermeulen (RETIRED) gentoo-dev 2014-07-21 09:33:08 UTC
*** Bug 516624 has been marked as a duplicate of this bug. ***
Comment 13 Anton Kochkov 2014-07-21 21:52:56 UTC
coreutils-8.23 was released two days ago, including this fix. See the release commit http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=commit;h=22c8c23f4090adf98f790f7dd6704c51415e475d
Comment 14 SpanKY gentoo-dev 2014-07-28 09:44:53 UTC
8.23 is in the tree now