Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 443156 - sandbox logging is disabled in enforcing mode
Summary: sandbox logging is disabled in enforcing mode
Status: VERIFIED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: SELinux (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Sven Vermeulen (RETIRED)
URL:
Whiteboard: sec-policy r8
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-14 20:50 UTC by Amadeusz Sławiński
Modified: 2012-12-13 10:13 UTC (History)
1 user (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 Amadeusz Sławiński 2012-11-14 20:50:36 UTC
Not sure if this one is a bug or same mistake on my part (mainly because I'm not sure how to reproduce it, as it seems to depend on pid), but I will report just in case


It seems like it couldn't remove log file

>>> Emerging (16 of 22) sec-policy/selinux-rpm-9999
>>> Unpacking source...
GIT update -->
   repository:               git://git.overlays.gentoo.org/proj/hardened-refpolicy.git
   at the commit:            682d8946d13ce9bb5e5ec4faef96077c9f08c359
   branch:                   master
   storage directory:        "/usr/portage/distfiles/egit-src/hardened-refpolicy.git"
   checkout type:            bare repository
Cloning into '/var/tmp/portage/sec-policy/selinux-rpm-9999/work/refpolicy'...
done.
Branch branch-master set up to track remote branch master from origin.
Switched to a new branch 'branch-master'
>>> Unpacked to /var/tmp/portage/sec-policy/selinux-rpm-9999/work/refpolicy
>>> Source unpacked in /var/tmp/portage/sec-policy/selinux-rpm-9999/work
sandbox:setup_sandbox  could not unlink old log file: /var/log/sandbox/sandbox-23713.log: Permission denied

sandbox:main  failed to setup sandbox
 * The ebuild phase 'prepare' has exited unexpectedly. This type of
 * behavior is known to be triggered by things such as failed variable
 * assignments (bug #190128) or bad substitution errors (bug #200313).
 * Normally, before exiting, bash should have displayed an error message
 * above. If bash did not produce an error message above, it's possible
 * that the ebuild has called `exit` when it should have called `die`
 * instead. This behavior may also be triggered by a corrupt bash binary or
 * a hardware problem such as memory or cpu malfunction. If the problem is
 * not reproducible or it appears to occur randomly, then it is likely to
 * be triggered by a hardware problem. If you suspect a hardware problem
 * then you should try some basic hardware diagnostics such as memtest.
 * Please do not report this as a bug unless it is consistently
 * reproducible and you are sure that your bash binary and hardware are
 * functioning properly.

>>> Failed to emerge sec-policy/selinux-rpm-9999, Log file:

Indeed there is a lot of them:

# ls -lZ /var/log/sandbox
total 160
-rw-r--r--. 1 root root system_u:object_r:var_log_t  390 Sep 11 03:20 sandbox-17165.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  631 Oct 18 00:34 sandbox-23632.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  577 Oct 18 00:34 sandbox-23634.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  647 Oct 18 00:34 sandbox-23711.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t 1003 Oct 18 00:34 sandbox-23713.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  344 Nov 13 21:46 sandbox-24394.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  413 Oct 18 00:35 sandbox-31767.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  415 Oct 18 00:35 sandbox-31771.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  396 Oct 18 00:35 sandbox-31809.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  408 Oct 18 00:35 sandbox-31811.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  410 Oct 18 00:35 sandbox-31812.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  412 Oct 18 00:35 sandbox-31813.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  431 Oct 18 00:35 sandbox-31816.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  398 Oct 18 00:35 sandbox-31817.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  419 Oct 18 00:35 sandbox-31818.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  414 Oct 18 00:35 sandbox-31819.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  422 Oct 18 00:35 sandbox-31821.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  426 Oct 18 00:35 sandbox-31822.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  428 Oct 18 00:35 sandbox-31823.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  430 Oct 18 00:35 sandbox-31824.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  420 Oct 18 00:35 sandbox-31825.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  428 Oct 18 00:35 sandbox-31827.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  416 Oct 18 00:35 sandbox-31829.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  442 Oct 18 00:35 sandbox-31832.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  405 Oct 18 00:35 sandbox-31840.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  431 Oct 18 00:35 sandbox-31857.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  430 Oct 18 00:35 sandbox-31870.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  422 Oct 18 00:35 sandbox-31884.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  406 Oct 18 00:35 sandbox-31887.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  404 Oct 18 00:35 sandbox-31889.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  405 Oct 18 00:35 sandbox-31891.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  403 Oct 18 00:35 sandbox-31893.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  411 Oct 18 00:35 sandbox-31899.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  407 Oct 18 00:35 sandbox-31901.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  408 Oct 18 00:35 sandbox-31905.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  440 Oct 18 00:35 sandbox-31916.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  439 Oct 18 00:35 sandbox-31917.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  451 Oct 18 00:35 sandbox-31928.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  441 Nov  7 14:43 sandbox-8087.log
-rw-r--r--. 1 root root system_u:object_r:var_log_t  518 Nov  7 04:49 sandbox-8304.log

When grepping log for 23713 it's the only one on 21:18:39
Nov 14 21:18:39 lain kernel: [41071.803979] type=1400 audit(1352924319.901:182): avc:  denied  { write } for  pid=23713 comm="sandbox" name="sandbox" dev="dm-0" ino=2490386 scontext=staff_u:sysadm_r:portage_sandbox_t tcontext=system_u:object_r:var_log_t tclass=dir






Reproducible: Always




Portage 2.1.11.31 (hardened/linux/amd64/no-multilib/selinux, gcc-4.6.3, glibc-2.16.0, 3.6.6-hardened x86_64)
=================================================================
System uname: Linux-3.6.6-hardened-x86_64-Intel-R-_Core-TM-_i3_CPU_M_350_@_2.27GHz-with-gentoo-2.2
Timestamp of tree: Wed, 14 Nov 2012 16:30:01 +0000
ld GNU ld (GNU Binutils) 2.23
app-shells/bash:          4.2_p39
dev-lang/python:          2.7.3-r2, 3.2.3-r1
dev-util/cmake:           2.8.9-r1
dev-util/pkgconfig:       0.27.1
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.11.5
sys-apps/sandbox:         2.6
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.11.6, 1.12.4
sys-devel/binutils:       2.23
sys-devel/gcc:            4.6.3
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4.2
sys-devel/make:           3.82-r4
sys-kernel/linux-headers: 3.6 (virtual/os-headers)
sys-libs/glibc:           2.16.0
Repositories: gentoo x11 hardened-dev my_local_overlay
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA AdobeFlash-10.3 PUEL skype-4.0.0.7-copyright google-talkplugin"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O3 -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="-march=native -O3 -pipe"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch protect-owned sandbox selinux sesandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="en en_GB pl"
MAKEOPTS="-j5"
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="/var/lib/layman/x11 /var/lib/layman/hardened-development /usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X acpi alsa amd64 bash-completion berkdb bluetooth bzip2 cli cracklib crypt cups cxx dbus dri dvd gdbm gif gpm hardened iconv icu ipv6 jpeg justify mmx mng modules mp3 mudflap ncurses nls nptl open_perms opengl openmp pam pax_kernel pcre png pppd readline selinux session sse sse2 sse4_1 sse4_2 ssl ssse3 tcpd tiff udev unicode urandom usb v4l vaapi vim-syntax wacom wifi xft xinerama xtpax zlib zsh-completion" 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="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" 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="mouse keyboard evdev" 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" PHP_TARGETS="php5-3" PYTHON_TARGETS="python2_7 python3_2" QEMU_SOFTMMU_TARGETS="x86_64 ppc" RUBY_TARGETS="ruby18 ruby19" USERLAND="GNU" VIDEO_CARDS="nouveau" 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 1 Amadeusz Sławiński 2012-11-14 22:49:13 UTC
I think I got it (created a lot of links to one file with var_log_t context after restorecon)

Enforcing:
Nov 14 23:46:53 lain kernel: [49948.096304] type=1400 audit(1352933213.845:1496): avc:  denied  { write } for  pid=742 comm="sandbox" name="sandbox" dev="dm-0" ino=2490386 scontext=staff_u:sysadm_r:portage_sandbox_t tcontext=system_u:object_r:var_log_t tclass=dir

Permissive:
Nov 14 23:47:12 lain kernel: [49966.622178] type=1400 audit(1352933232.408:1498): avc:  denied  { write } for  pid=877 comm="sandbox" name="sandbox" dev="dm-0" ino=2490386 scontext=staff_u:sysadm_r:portage_sandbox_t tcontext=system_u:object_r:var_log_t tclass=dir
Nov 14 23:47:12 lain kernel: [49966.622201] type=1400 audit(1352933232.408:1499): avc:  denied  { remove_name } for  pid=877 comm="sandbox" name="sandbox-877.log" dev="dm-0" ino=2492418 scontext=staff_u:sysadm_r:portage_sandbox_t tcontext=system_u:object_r:var_log_t tclass=dir
Nov 14 23:47:12 lain kernel: [49966.622220] type=1400 audit(1352933232.408:1500): avc:  denied  { unlink } for  pid=877 comm="sandbox" name="sandbox-877.log" dev="dm-0" ino=2492418 scontext=staff_u:sysadm_r:portage_sandbox_t tcontext=staff_u:object_r:var_log_t tclass=lnk_file
Comment 2 Sven Vermeulen (RETIRED) gentoo-dev 2012-11-16 14:24:30 UTC
Probably needs a separate type (either sandbox_log_t or portage_sandbox_log_t, depends a bit) as it seems to be very isolated (and specific).
Comment 3 Sven Vermeulen (RETIRED) gentoo-dev 2012-11-17 21:03:21 UTC
When SELinux is running in enforcing mode, any sandbox-trapped failures are not properly logged inside /var/log/sandbox. This means we need to allow this (as it is an important source for debugging).

I *might* have a file transition towards portage_log_t if portage_sandbox_t writes inside a var_log_t, although I would like /var/log/sandbox to be something like sandbox_log_t. But then that means I'll need to have a sandbox module (which doesn't exist yet). Or I have it marked as portage_log_t, but that means that other applications using sandbox might suddenly not be able to write to this location. So the first thought is probably the best one to pick for now.
Comment 4 Sven Vermeulen (RETIRED) gentoo-dev 2012-11-18 07:50:44 UTC
Should be fixed in repo, will be in r8
Comment 5 Sven Vermeulen (RETIRED) gentoo-dev 2012-11-23 21:40:40 UTC
r8 in hardened-dev overlay
Comment 6 Sven Vermeulen (RETIRED) gentoo-dev 2012-12-03 09:36:04 UTC
r8 is now in main tree, ~arch
Comment 7 Sven Vermeulen (RETIRED) gentoo-dev 2012-12-13 10:13:38 UTC
r8 is now stable