If a file or directory has an unknown context, ls -Z segfaults when trying to display the context information. An example of this is /dev on a udev system without tmpfs xattr/security label support. Reproducible: Always Steps to Reproduce: 1. ls -Z / 2. 3. Actual Results: Segmentation Fault. Portage 2.0.51_rc9 (selinux/2004.1/x86, gcc-vanilla, glibc-2.3.4.20041006-r0, 2.6.7-hardened-mt2 i686) ================================================================= System uname: 2.6.7-hardened-mt2 i686 AMD Athlon(tm) XP 1600+ Gentoo Base System version 1.6.2 ccache version 2.3 [enabled] Autoconf: sys-devel/autoconf-2.59-r5 Automake: sys-devel/automake-1.8.5-r1 Binutils: sys-devel/binutils-2.15.92.0.2-r1 Headers: sys-kernel/linux26-headers-2.6.8.1-r1 Libtools: sys-devel/libtool-1.5.2-r5 ACCEPT_KEYWORDS="x86 ~x86" AUTOCLEAN="yes" CFLAGS="-Os -pipe -mtune=athlon-xp -march=athlon-xp -fomit-frame-pointer -msse -m3dnow -g" CHOST="i686-pc-linux-gnu" COMPILER="" CONFIG_PROTECT="/etc /opt/openjms/config /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3.2/share/config /usr/kde/3.3/share/config:/usr/kde/3.3/env:/usr/kde/3.3/shutdown /usr/kde/3/share/config /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control /var/service" CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d" CXXFLAGS="-Os -pipe -mtune=athlon-xp -march=athlon-xp -fomit-frame-pointer -msse -m3dnow -g" DISTDIR="/usr/portage/distfiles" FEATURES="autoaddcvs candy ccache collision-protect confcache cvs digest distclean distlocks flawfinder loadpolicy maketest mirror noinfo nostrip rats sandbox sfperms sign strict userpriv usersandbox" GENTOO_MIRRORS="http://gentoo.osuosl.org http://distro.ibiblio.org/pub/Linux/distributions/gentoo" MAKEOPTS="-j2" PKGDIR="/opt/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="/usr/local/bmg-main /gentoo/apache-overlay /gentoo/vim-overlay /gentoo/kernel-overlay /gentoo/kaiowas-overlay /gentoo/kde-overlay" SYNC="rsync://rsync.gentoo.org/gentoo-portage" USE="3dnow X Xaw3d a aalib acl acpi adns aim alsa apache2 audiofile avi berkdb bindist bonobo bzlib calendar cdr crypt cscope ctype cups dba debug dga dio directfb divx4linux doc dr dvd emacs esd ethereal evo exif faac faad fam firebird flac flash foomaticdb ftp gb gd gdbm ggi gif gmp gnome gphoto2 gpm gps gstreamer gtk gtk2 gtkhtml guile hal icq imagemagick imap imlib inifile innodb ipv6 jabber java joystick jpeg junit ldap libg++ libwww mad magick maildir mcal mhash mikmod mime ming mmx mng motif moz mozilla mpeg mpi mpm-threadpool msn mysql nas ncurses nls odbc offensive oggvorbis openal opengl oscar pam pcntl pcre pda perl php pic plotutils png posix postgres prelink python readline ruby samba scheme sdl selinux session shared slang slp snmp soap sockets speex spell sqlite sse ssl svg svga sysvipc tcltk tcpd tetex theora threads tiff tokenizer treamer truetype usb v vhosts vos work x x86 xinerama xml xml2 xmlrpc xmlterm xmms xpm xsl xv xvid yahoo zlib" I have attached a patch that fixes ls.c to display (unknown context) instead of segfaulting.
Created attachment 42234 [details, diff] Patch for ls -Z This currently prints (null), Im investigating why and will post a new patch once I have another fix.
Created attachment 42394 [details, diff] Patch against ls.c This is a fixed version of ls -Z. It now exhibits the proper (unknown context) behavior, rather than segfaulting. Here is an example of its output: urilith coreutils-5.2.1 # src/ls -Z / drwxr-xr-x root root system_u:object_r:bin_t bin drwxr-xr-x root root system_u:object_r:boot_t boot drwxr-xr-x root root (unknown context) dev
seemant: go ahead and drop the selinux+acl patch. we decided to use.mask acl on the selinux profiles, this this is wontfix or invalid now.
spanky bumped the latest coreutils and took out the acl+selinux stuff, as requested. Thanks Spanks.