linux-stable/fs
Lucian Adrian Grijincu 8e6c96935f security/selinux: fix /proc/sys/ labeling
This fixes an old (2007) selinux regression: filesystem labeling for
/proc/sys returned
     -r--r--r-- unknown                          /proc/sys/fs/file-nr
instead of
     -r--r--r-- system_u:object_r:sysctl_fs_t:s0 /proc/sys/fs/file-nr

Events that lead to breaking of /proc/sys/ selinux labeling:

1) sysctl was reimplemented to route all calls through /proc/sys/

    commit 77b14db502
    [PATCH] sysctl: reimplement the sysctl proc support

2) proc_dir_entry was removed from ctl_table:

    commit 3fbfa98112
    [PATCH] sysctl: remove the proc_dir_entry member for the sysctl tables

3) selinux still walked the proc_dir_entry tree to apply
   labeling. Because ctl_tables don't have a proc_dir_entry, we did
   not label /proc/sys/ inodes any more. To achieve this the /proc/sys/
   inodes were marked private and private inodes were ignored by
   selinux.

    commit bbaca6c2e7
    [PATCH] selinux: enhance selinux to always ignore private inodes

    commit 86a71dbd3e
    [PATCH] sysctl: hide the sysctl proc inodes from selinux

Access control checks have been done by means of a special sysctl hook
that was called for read/write accesses to any /proc/sys/ entry.

We don't have to do this because, instead of walking the
proc_dir_entry tree we can walk the dentry tree (as done in this
patch). With this patch:
* we don't mark /proc/sys/ inodes as private
* we don't need the sysclt security hook
* we walk the dentry tree to find the path to the inode.

We have to strip the PID in /proc/PID/ entries that have a
proc_dir_entry because selinux does not know how to label paths like
'/1/net/rpc/nfsd.fh' (and defaults to 'proc_t' labeling). Selinux does
know of '/net/rpc/nfsd.fh' (and applies the 'sysctl_rpc_t' label).

PID stripping from the path was done implicitly in the previous code
because the proc_dir_entry tree had the root in '/net' in the example
from above. The dentry tree has the root in '/1'.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@gmail.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
2011-02-01 11:53:54 -05:00
..
9p fs: dcache per-inode inode alias locking 2011-01-07 17:50:31 +11:00
adfs fs: dcache reduce branches in lookup path 2011-01-07 17:50:28 +11:00
affs fs: dcache per-inode inode alias locking 2011-01-07 17:50:31 +11:00
afs fs: provide rcu-walk aware permission i_ops 2011-01-07 17:50:29 +11:00
autofs4 fs: rcu-walk aware d_revalidate method 2011-01-07 17:50:29 +11:00
befs fs: icache RCU free inodes 2011-01-07 17:50:26 +11:00
bfs fs: icache RCU free inodes 2011-01-07 17:50:26 +11:00
btrfs fs/vfs/security: pass last path component to LSM on inode creation 2011-02-01 11:12:29 -05:00
cachefiles CacheFiles: Add calls to path-based security hooks 2011-01-24 10:49:45 +11:00
ceph fs: provide rcu-walk aware permission i_ops 2011-01-07 17:50:29 +11:00
cifs fs: dcache per-inode inode alias locking 2011-01-07 17:50:31 +11:00
coda fs: provide rcu-walk aware permission i_ops 2011-01-07 17:50:29 +11:00
configfs fs: dcache reduce branches in lookup path 2011-01-07 17:50:28 +11:00
cramfs
debugfs
devpts
dlm
ecryptfs fs: provide rcu-walk aware permission i_ops 2011-01-07 17:50:29 +11:00
efs fs: icache RCU free inodes 2011-01-07 17:50:26 +11:00
exofs fs: icache RCU free inodes 2011-01-07 17:50:26 +11:00
exportfs fs: dcache per-inode inode alias locking 2011-01-07 17:50:31 +11:00
ext2 fs/vfs/security: pass last path component to LSM on inode creation 2011-02-01 11:12:29 -05:00
ext3 fs/vfs/security: pass last path component to LSM on inode creation 2011-02-01 11:12:29 -05:00
ext4 fs/vfs/security: pass last path component to LSM on inode creation 2011-02-01 11:12:29 -05:00
fat fs: rcu-walk aware d_revalidate method 2011-01-07 17:50:29 +11:00
freevxfs fs: icache RCU free inodes 2011-01-07 17:50:26 +11:00
fscache
fuse fs: provide rcu-walk aware permission i_ops 2011-01-07 17:50:29 +11:00
gfs2 fs/vfs/security: pass last path component to LSM on inode creation 2011-02-01 11:12:29 -05:00
hfs fs: rcu-walk aware d_revalidate method 2011-01-07 17:50:29 +11:00
hfsplus Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/hch/hfsplus 2011-01-07 17:16:27 -08:00
hostfs fs: provide rcu-walk aware permission i_ops 2011-01-07 17:50:29 +11:00
hpfs fs: provide rcu-walk aware permission i_ops 2011-01-07 17:50:29 +11:00
hppfs fs: icache RCU free inodes 2011-01-07 17:50:26 +11:00
hugetlbfs fs: icache RCU free inodes 2011-01-07 17:50:26 +11:00
isofs fs: dcache reduce branches in lookup path 2011-01-07 17:50:28 +11:00
jbd
jbd2 jbd2: fix /proc/fs/jbd2/<dev> when using an external journal 2010-11-17 21:46:26 -05:00
jffs2 fs/vfs/security: pass last path component to LSM on inode creation 2011-02-01 11:12:29 -05:00
jfs fs/vfs/security: pass last path component to LSM on inode creation 2011-02-01 11:12:29 -05:00
lockd BKL: remove extraneous #include <smp_lock.h> 2010-11-17 08:59:32 -08:00
logfs fs: provide rcu-walk aware permission i_ops 2011-01-07 17:50:29 +11:00
minix fs: dcache reduce branches in lookup path 2011-01-07 17:50:28 +11:00
ncpfs Merge branch 'for-2.6.38' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq 2011-01-07 16:58:04 -08:00
nfs fs: dcache per-inode inode alias locking 2011-01-07 17:50:31 +11:00
nfs_common
nfsd Merge branch 'for-2.6.38' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq 2011-01-07 16:58:04 -08:00
nilfs2 fs: provide rcu-walk aware permission i_ops 2011-01-07 17:50:29 +11:00
nls
notify fs: dcache per-inode inode alias locking 2011-01-07 17:50:31 +11:00
ntfs fs: icache RCU free inodes 2011-01-07 17:50:26 +11:00
ocfs2 fs/vfs/security: pass last path component to LSM on inode creation 2011-02-01 11:12:29 -05:00
omfs
openpromfs fs: icache RCU free inodes 2011-01-07 17:50:26 +11:00
partitions
proc security/selinux: fix /proc/sys/ labeling 2011-02-01 11:53:54 -05:00
qnx4 fs: icache RCU free inodes 2011-01-07 17:50:26 +11:00
quota
ramfs
reiserfs fs/vfs/security: pass last path component to LSM on inode creation 2011-02-01 11:12:29 -05:00
romfs fs: icache RCU free inodes 2011-01-07 17:50:26 +11:00
squashfs fs: icache RCU free inodes 2011-01-07 17:50:26 +11:00
sysfs fs: provide rcu-walk aware permission i_ops 2011-01-07 17:50:29 +11:00
sysv fs: dcache reduce branches in lookup path 2011-01-07 17:50:28 +11:00
ubifs fs: icache RCU free inodes 2011-01-07 17:50:26 +11:00
udf fs: icache RCU free inodes 2011-01-07 17:50:26 +11:00
ufs fs: icache RCU free inodes 2011-01-07 17:50:26 +11:00
xfs fs/vfs/security: pass last path component to LSM on inode creation 2011-02-01 11:12:29 -05:00
aio.c
anon_inodes.c fs: scale mntget/mntput 2011-01-07 17:50:33 +11:00
attr.c
bad_inode.c fs: provide rcu-walk aware permission i_ops 2011-01-07 17:50:29 +11:00
binfmt_aout.c
binfmt_elf.c
binfmt_elf_fdpic.c
binfmt_em86.c
binfmt_flat.c
binfmt_misc.c
binfmt_script.c
binfmt_som.c
bio-integrity.c
bio.c
block_dev.c fs: icache RCU free inodes 2011-01-07 17:50:26 +11:00
buffer.c fs: Use this_cpu_inc_return in buffer.c 2010-12-17 15:18:05 +01:00
char_dev.c
compat.c exec: copy-and-paste the fixes into compat_do_execve() paths 2010-11-30 17:56:38 -08:00
compat_binfmt_elf.c
compat_ioctl.c Merge branch 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6 2011-01-07 14:39:20 -08:00
dcache.c fs: implement faster dentry memcmp 2011-01-07 17:50:32 +11:00
dcookies.c
direct-io.c
drop_caches.c
eventfd.c
eventpoll.c
exec.c install_special_mapping skips security_file_mmap check. 2010-12-15 12:30:36 -08:00
fcntl.c
fifo.c
file.c
file_table.c
filesystems.c fs: rcu-walk for path lookup 2011-01-07 17:50:27 +11:00
fs-writeback.c
fs_struct.c fs: scale mntget/mntput 2011-01-07 17:50:33 +11:00
generic_acl.c fs: provide simple rcu-walk generic_check_acl implementation 2011-01-07 17:50:29 +11:00
inode.c fs: avoid inode RCU freeing for pseudo fs 2011-01-07 17:50:26 +11:00
internal.h fs: scale mntget/mntput 2011-01-07 17:50:33 +11:00
ioctl.c Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4 2010-11-19 19:46:45 -08:00
ioprio.c ioprio: grab rcu_read_lock in sys_ioprio_{set,get}() 2010-11-15 10:23:31 +01:00
Kconfig
Kconfig.binfmt
libfs.c fs: dcache reduce branches in lookup path 2011-01-07 17:50:28 +11:00
locks.c fs: dcache scale dentry refcount 2011-01-07 17:50:21 +11:00
Makefile
mbcache.c
mpage.c
namei.c fs: scale mntget/mntput 2011-01-07 17:50:33 +11:00
namespace.c fs: scale mntget/mntput 2011-01-07 17:50:33 +11:00
nfsctl.c
no-block.c
open.c
pipe.c fs: scale mntget/mntput 2011-01-07 17:50:33 +11:00
pnode.c fs: scale mntget/mntput 2011-01-07 17:50:33 +11:00
pnode.h
posix_acl.c
read_write.c BKL: remove extraneous #include <smp_lock.h> 2010-11-17 08:59:32 -08:00
read_write.h
readdir.c
select.c
seq_file.c
signalfd.c
splice.c Export 'get_pipe_info()' to other users 2010-11-28 14:09:57 -08:00
stack.c
stat.c
statfs.c
super.c fs: scale mntget/mntput 2011-01-07 17:50:33 +11:00
sync.c
timerfd.c
utimes.c
xattr.c
xattr_acl.c