Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 413441 - sys-apps/sandbox mishandles open(O_NOFOLLOW) on dangling symlinks (breaks sys-apps/grep-2.12 tests)
Summary: sys-apps/sandbox mishandles open(O_NOFOLLOW) on dangling symlinks (breaks sys...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Sandbox (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Sandbox Maintainers
URL:
Whiteboard:
Keywords:
: 415797 424936 427328 429790 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-04-25 03:02 UTC by Patrick Lauer
Modified: 2012-12-27 09:53 UTC (History)
7 users (show)

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


Attachments
build log (sys-apps:grep-2.14:20121226-212513.log.gz,25.81 KB, application/octet-stream)
2012-12-27 09:53 UTC, Toralf Förster
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Lauer gentoo-dev 2012-04-25 03:02:38 UTC
FAIL: symlink
=============

++ initial_cwd_=/var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/tests
++ fail=0
+++ testdir_prefix_
+++ printf gt
++ pfx_=gt
+++ mktempd_ /var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/tests gt-symlink.XXXX
+++ case $# in
+++ destdir_=/var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/tests
+++ template_=gt-symlink.XXXX
+++ MAX_TRIES_=4
+++ case $destdir_ in
+++ case $template_ in
++++ unset TMPDIR
+++ d=/var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/tests/gt-symlink.XQym
+++ case $d in
+++ test -d /var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/tests/gt-symlink.XQym
++++ ls -dgo /var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/tests/gt-symlink.XQym
++++ tr S -
+++ perms='drwx------ 2 4096 Apr 25 10:57 /var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/tests/gt-symlink.XQym'
+++ case $perms in
+++ test 0 = 0
+++ echo /var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/tests/gt-symlink.XQym
+++ return
++ test_dir_=/var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/tests/gt-symlink.XQym
++ cd /var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/tests/gt-symlink.XQym
++ gl_init_sh_nl_='
'
++ IFS=' 
'
++ for sig_ in 1 2 3 13 15
+++ expr 1 + 128
++ eval 'trap '\''Exit 129'\'' 1'
+++ trap 'Exit 129' 1
++ for sig_ in 1 2 3 13 15
+++ expr 2 + 128
++ eval 'trap '\''Exit 130'\'' 2'
+++ trap 'Exit 130' 2
++ for sig_ in 1 2 3 13 15
+++ expr 3 + 128
++ eval 'trap '\''Exit 131'\'' 3'
+++ trap 'Exit 131' 3
++ for sig_ in 1 2 3 13 15
+++ expr 13 + 128
++ eval 'trap '\''Exit 141'\'' 13'
+++ trap 'Exit 141' 13
++ for sig_ in 1 2 3 13 15
+++ expr 15 + 128
++ eval 'trap '\''Exit 143'\'' 15'
+++ trap 'Exit 143' 15
++ trap remove_tmp_ 0
+ path_prepend_ ../src
+ test 1 '!=' 0
+ path_dir_=../src
+ case $path_dir_ in
++ cd /var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/tests/../src
++ echo /var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/src
+ abs_path_dir_=/var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/src
+ case $abs_path_dir_ in
+ PATH=/var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/src:/var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/src:/usr/lib64/portage/bin/ebuild-helpers:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.3
+ create_exe_shims_ /var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/src
+ case $EXEEXT in
+ return 0
+ shift
+ test 0 '!=' 0
+ export PATH
+ mkdir dir
+ echo a
+ echo b
+ ln -s a dir/c
+ ln -s . dir/d
+ ln -s dangling dir/e
+ touch out
+ for recursion in ''\'''\''' -r -R
+ for files in ''\'''\''' ''\''*'\'''
+ case $recursion,$files in
+ expected_status=0
+ cd dir
+ grep '^'
+ test 0 -eq 0
+ case $recursion,$files in
+ exp='a\n'
+ printf 'a\n'
+ LC_ALL=C
+ sort grepout
+ grep -v Binary out-t
+ case $? in
+ compare exp out
+ compare_dev_null_ exp out
+ test 2 = 2
+ test xexp = x/dev/null
+ test xout = x/dev/null
+ return 2
+ case $? in
+ compare_ exp out
+ diff -u exp out
+ for files in ''\'''\''' ''\''*'\'''
+ case $recursion,$files in
+ expected_status=2
+ cd dir
+ grep '^' a b c d e
grep: d: Is a directory
grep: e: No such file or directory
+ test 2 -eq 2
+ case $recursion,$files in
+ exp='a:a\nb:b\nc:a\n'
+ printf 'a:a\nb:b\nc:a\n'
+ LC_ALL=C
+ sort grepout
+ grep -v Binary out-t
+ case $? in
+ compare exp out
+ compare_dev_null_ exp out
+ test 2 = 2
+ test xexp = x/dev/null
+ test xout = x/dev/null
+ return 2
+ case $? in
+ compare_ exp out
+ diff -u exp out
+ for recursion in ''\'''\''' -r -R
+ for files in ''\'''\''' ''\''*'\'''
+ case $recursion,$files in
+ expected_status=0
+ cd dir
+ grep -r '^'
grep: e: No such file or directory
+ test 2 -eq 0
+ fail=1
+ case $recursion,$files in
+ exp='a:a\nb:b\n'
+ printf 'a:a\nb:b\n'
+ LC_ALL=C
+ sort grepout
+ grep -v Binary out-t
+ case $? in
+ compare exp out
+ compare_dev_null_ exp out
+ test 2 = 2
+ test xexp = x/dev/null
+ test xout = x/dev/null
+ return 2
+ case $? in
+ compare_ exp out
+ diff -u exp out
+ for files in ''\'''\''' ''\''*'\'''
+ case $recursion,$files in
+ expected_status=2
+ cd dir
+ grep -r '^' a b c d e
grep: d/e: No such file or directory
grep: e: No such file or directory
+ test 2 -eq 2
+ case $recursion,$files in
+ exp='a:a\nb:b\nc:a\nd/a:a\nd/b:b\n'
+ printf 'a:a\nb:b\nc:a\nd/a:a\nd/b:b\n'
+ LC_ALL=C
+ sort grepout
+ grep -v Binary out-t
+ case $? in
+ compare exp out
+ compare_dev_null_ exp out
+ test 2 = 2
+ test xexp = x/dev/null
+ test xout = x/dev/null
+ return 2
+ case $? in
+ compare_ exp out
+ diff -u exp out
+ for recursion in ''\'''\''' -r -R
+ for files in ''\'''\''' ''\''*'\'''
+ case $recursion,$files in
+ expected_status=2
+ cd dir
+ grep -R '^'
grep: e: No such file or directory
grep: warning: d: recursive directory loop
+ test 2 -eq 2
+ case $recursion,$files in
+ exp='a:a\nb:b\nc:a\n'
+ printf 'a:a\nb:b\nc:a\n'
+ LC_ALL=C
+ sort grepout
+ grep -v Binary out-t
+ case $? in
+ compare exp out
+ compare_dev_null_ exp out
+ test 2 = 2
+ test xexp = x/dev/null
+ test xout = x/dev/null
+ return 2
+ case $? in
+ compare_ exp out
+ diff -u exp out
+ for files in ''\'''\''' ''\''*'\'''
+ case $recursion,$files in
+ expected_status=2
+ cd dir
+ grep -R '^' a b c d e
grep: d/e: No such file or directory
grep: warning: d/d: recursive directory loop
grep: e: No such file or directory
+ test 2 -eq 2
+ case $recursion,$files in
+ exp='a:a\nb:b\nc:a\nd/a:a\nd/b:b\nd/c:a\n'
+ printf 'a:a\nb:b\nc:a\nd/a:a\nd/b:b\nd/c:a\n'
+ LC_ALL=C
+ sort grepout
+ grep -v Binary out-t
+ case $? in
+ compare exp out
+ compare_dev_null_ exp out
+ test 2 = 2
+ test xexp = x/dev/null
+ test xout = x/dev/null
+ return 2
+ case $? in
+ compare_ exp out
+ diff -u exp out
+ Exit 1
+ set +e
+ exit 1
+ exit 1
+ remove_tmp_
+ __st=1
+ cleanup_
+ :
+ cd /var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/tests
+ chmod -R u+rwx /var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/tests/gt-symlink.XQym
+ rm -rf /var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/tests/gt-symlink.XQym
+ exit 1
Comment 1 Patrick Lauer gentoo-dev 2012-04-25 03:03:59 UTC
============================================================================
Testsuite summary for GNU grep 2.12
============================================================================
# TOTAL: 54
# PASS:  48
# SKIP:  2
# XFAIL: 3
# FAIL:  1
# XPASS: 0
# ERROR: 0
============================================================================
See tests/test-suite.log
Please report to bug-grep@gnu.org
============================================================================
make[3]: *** [test-suite.log] Error 1
make[3]: Leaving directory `/var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/tests'
make[2]: *** [check-TESTS] Error 2
make[2]: Leaving directory `/var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/tests'
make[1]: *** [check-am] Error 2
make[1]: Leaving directory `/var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12/tests'
make: *** [check-recursive] Error 1
 * ERROR: sys-apps/grep-2.12 failed (test phase):
 *   Make check failed. See above for details.
 * 
 * Call stack:
 *          ebuild.sh, line  85:  Called src_test
 *        environment, line 180:  Called _eapi0_src_test
 *   phase-helpers.sh, line 550:  Called die
 * The specific snippet of code:
 *              $emake_cmd -j1 check || \
 *                      die "Make check failed. See above for details."
 * 
 * If you need support, post the output of 'emerge --info =sys-apps/grep-2.12',
 * the complete build log and the output of 'emerge -pqv =sys-apps/grep-2.12'.
 * The complete build log is located at '/var/tmp/portage/sys-apps/grep-2.12/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sys-apps/grep-2.12/temp/environment'.
 * Working directory: '/var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12'
 * S: '/var/tmp/portage/sys-apps/grep-2.12/work/grep-2.12'

>>> Failed to emerge sys-apps/grep-2.12, Log file:

Portage 2.1.10.57 (default/linux/amd64/10.0, gcc-4.5.3, glibc-2.15-r1, 3.3.1-vs2.3.3.2 x86_64)
=================================================================
System uname: Linux-3.3.1-vs2.3.3.2-x86_64-AMD_Phenom-tm-_II_X4_965_Processor-with-gentoo-2.1
Timestamp of tree: Unknown
app-shells/bash:          4.2_p24-r1
dev-lang/python:          2.7.3, 3.2.2-r1
dev-util/pkgconfig:       0.26
sys-apps/baselayout:      2.1
sys-apps/openrc:          0.9.9.3
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.68
sys-devel/automake:       1.11.5
sys-devel/binutils:       2.22-r1
sys-devel/gcc:            4.5.3-r2
sys-devel/gcc-config:     1.7
sys-devel/libtool:        2.4.2
sys-devel/make:           3.82-r3
sys-kernel/linux-headers: 3.3 (virtual/os-headers)
sys-libs/glibc:           2.15-r1
Repositories: gentoo
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/themes/oxygen-gtk/gtk-2.0 /var/lib/hsqldb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs buildpkg distlocks ebuild-locks fixlafiles news parallel-fetch protect-owned sandbox sfperms strict test unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS=""
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_GB.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --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=""
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="acl amd64 berkdb bzip2 cli cracklib crypt cups cxx dri fortran gdbm gpm iconv ipv6 mmx modules mudflap multilib ncurses nls nptl nptlonly openmp pam pcre pppd readline session sse sse2 ssl sysfs tcpd unicode xa 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 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" 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 ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" PHP_TARGETS="php5-3" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="fbdev glint intel mach64 mga neomagic nouveau nv r128 radeon savage sis tdfx trident vesa via vmware dummy v4l" 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, LINGUAS, MAKEOPTS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 2 Toralf Förster gentoo-dev 2012-04-26 12:46:25 UTC
Same here at an unstable x86 system with gcc-4.6.2
Comment 3 Marien Zwart (RETIRED) gentoo-dev 2012-05-12 19:00:07 UTC
This is a sandbox bug. Reassigning to them.

Create a directory with a dangling symlink in it, and run "grep -r '^'" in this directory. Without sandbox grep ignores the dangling symlink. With sandbox you get "grep: e: No such file or directory" ("e" is the name of my dangling symlink) and grep exits with status 2 (indicating an error).

Comparing strace output shows that grep is using openat(4, "e", O_RDONLY|O_NOFOLLOW). This fails with ELOOP if sandbox is not present, but with ENOENT if sandbox is present. I think the "Doesn't exist -> skip permission checks" code in openat_pre_check needs to use lstat instead of stat if O_NOFOLLOW is in checks. Fixes elsewhere in the code may also be necessary, though.
Comment 4 SpanKY gentoo-dev 2012-05-15 17:47:30 UTC
*** Bug 415797 has been marked as a duplicate of this bug. ***
Comment 5 Diego Elio Pettenò (RETIRED) gentoo-dev 2012-07-05 15:48:51 UTC
*** Bug 424936 has been marked as a duplicate of this bug. ***
Comment 6 Jeroen Roovers (RETIRED) gentoo-dev 2012-08-04 11:21:37 UTC
*** Bug 429790 has been marked as a duplicate of this bug. ***
Comment 7 Jeroen Roovers (RETIRED) gentoo-dev 2012-08-04 15:05:13 UTC
*** Bug 427328 has been marked as a duplicate of this bug. ***
Comment 8 SpanKY gentoo-dev 2012-12-24 23:58:53 UTC
clearly few people use O_NOFOLLOW as sandbox has had this bug since the beginning of time :)

http://git.overlays.gentoo.org/gitweb/?p=proj/sandbox.git;a=commitdiff;h=45fa8714a1d35e6555083d88a71851ada2aacac4
Comment 9 Toralf Förster gentoo-dev 2012-12-26 21:18:28 UTC
(In reply to comment #8)
> clearly few people use O_NOFOLLOW as sandbox has had this bug since the
> beginning of time :)
> 
> http://git.overlays.gentoo.org/gitweb/?p=proj/sandbox.git;a=commitdiff;
> h=45fa8714a1d35e6555083d88a71851ada2aacac4

nice to have : if sandox's ebuild would have "epach_user"
Comment 11 Toralf Förster gentoo-dev 2012-12-27 09:53:27 UTC
Created attachment 333452 [details]
build log

(In reply to comment #10)
> (In reply to comment #9)
> 
> http://sources.gentoo.org/sys-apps/sandbox/sandbox-2.6.ebuild?r1=1.2&r2=1.3

cool - thx - issue w/ symlink is now gone.

At a stable Gentoo with gcc-4.6.3 and patched sandbox-2.6 now only 2 test failures happen :

$ zgrep FAIL /var/log/portage/sys-apps:grep-2.14:20121226-212513.log.gz
XFAIL: grep-dir
XFAIL: word-delim-multibyte