Jeff Layton
094f7b69ea
selinux: make security_sb_clone_mnt_opts return an error on context mismatch
...
I had the following problem reported a while back. If you mount the
same filesystem twice using NFSv4 with different contexts, then the
second context= option is ignored. For instance:
# mount server:/export /mnt/test1
# mount server:/export /mnt/test2 -o context=system_u:object_r:tmp_t:s0
# ls -dZ /mnt/test1
drwxrwxrwt. root root system_u:object_r:nfs_t:s0 /mnt/test1
# ls -dZ /mnt/test2
drwxrwxrwt. root root system_u:object_r:nfs_t:s0 /mnt/test2
When we call into SELinux to set the context of a "cloned" superblock,
it will currently just bail out when it notices that we're reusing an
existing superblock. Since the existing superblock is already set up and
presumably in use, we can't go overwriting its context with the one from
the "original" sb. Because of this, the second context= option in this
case cannot take effect.
This patch fixes this by turning security_sb_clone_mnt_opts into an int
return operation. When it finds that the "new" superblock that it has
been handed is already set up, it checks to see whether the contexts on
the old superblock match it. If it does, then it will just return
success, otherwise it'll return -EBUSY and emit a printk to tell the
admin why the second mount failed.
Note that this patch may cause casualties. The NFSv4 code relies on
being able to walk down to an export from the pseudoroot. If you mount
filesystems that are nested within one another with different contexts,
then this patch will make those mounts fail in new and "exciting" ways.
For instance, suppose that /export is a separate filesystem on the
server:
# mount server:/ /mnt/test1
# mount salusa:/export /mnt/test2 -o context=system_u:object_r:tmp_t:s0
mount.nfs: an incorrect mount option was specified
...with the printk in the ring buffer. Because we *might* eventually
walk down to /mnt/test1/export, the mount is denied due to this patch.
The second mount needs the pseudoroot superblock, but that's already
present with the wrong context.
OTOH, if we mount these in the reverse order, then both mounts work,
because the pseudoroot superblock created when mounting /export is
discarded once that mount is done. If we then however try to walk into
that directory, the automount fails for the similar reasons:
# cd /mnt/test1/scratch/
-bash: cd: /mnt/test1/scratch: Device or resource busy
The story I've gotten from the SELinux folks that I've talked to is that
this is desirable behavior. In SELinux-land, mounting the same data
under different contexts is wrong -- there can be only one.
Cc: Steve Dickson <steved@redhat.com>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Acked-by: Eric Paris <eparis@redhat.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
2013-04-02 11:30:13 +11:00
..
9p
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
adfs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
affs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
afs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
autofs4
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
befs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
bfs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
btrfs
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace
2013-03-09 16:51:13 -08:00
cachefiles
FS-Cache: Mark cancellation of in-progress operation
2012-12-20 22:34:00 +00:00
ceph
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
cifs
CIFS: Fix missing of oplock_read value in smb30_values structure
2013-03-06 19:37:01 -06:00
coda
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
configfs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
cramfs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
debugfs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
devpts
fs: Limit sys_mount to only request filesystem modules (Part 2).
2013-03-07 01:08:55 -08:00
dlm
hlist: drop the node parameter from iterators
2013-02-27 19:10:24 -08:00
ecryptfs
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace
2013-03-09 16:51:13 -08:00
efs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
exofs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
exportfs
hlist: drop the node parameter from iterators
2013-02-27 19:10:24 -08:00
ext2
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
ext3
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
ext4
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
f2fs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
fat
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
freevxfs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
fscache
hlist: drop the node parameter from iterators
2013-02-27 19:10:24 -08:00
fuse
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
gfs2
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
hfs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
hfsplus
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
hostfs
hostfs: directory methods have no business in non-directory inode_operations
2013-02-22 23:31:37 -05:00
hpfs
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2013-02-26 20:16:07 -08:00
hppfs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
hugetlbfs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
isofs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
jbd
jbd: don't wake kjournald unnecessarily
2013-01-14 22:50:45 +01:00
jbd2
jbd2: fix ERR_PTR dereference in jbd2__journal_start
2013-03-02 17:08:46 -05:00
jffs2
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
jfs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
lockd
Merge branch 'for-3.9' of git://linux-nfs.org/~bfields/linux
2013-02-28 18:02:55 -08:00
logfs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
minix
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
ncpfs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
nfs
selinux: make security_sb_clone_mnt_opts return an error on context mismatch
2013-04-02 11:30:13 +11:00
nfs_common
nfs_common: Update the translation between nfsv3 acls linux posix acls
2013-02-13 06:15:14 -08:00
nfsd
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
nilfs2
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
nls
notify
hlist: drop the node parameter from iterators
2013-02-27 19:10:24 -08:00
ntfs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
ocfs2
fs: Limit sys_mount to only request filesystem modules (Part 2).
2013-03-07 01:08:55 -08:00
omfs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
openpromfs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
proc
proc: Use nd_jump_link in proc_ns_follow_link
2013-03-09 00:14:45 -08:00
pstore
A few fixes to reduce places where pstore might hang
2013-02-21 09:38:18 -08:00
qnx4
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
qnx6
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
quota
ramfs
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2013-02-26 20:16:07 -08:00
reiserfs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
romfs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
squashfs
new helper: file_inode(file)
2013-02-22 23:31:31 -05:00
sysfs
hlist: drop the node parameter from iterators
2013-02-27 19:10:24 -08:00
sysv
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
ubifs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
udf
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2013-02-26 20:16:07 -08:00
ufs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
xfs
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
aio.c
hlist: drop the node parameter from iterators
2013-02-27 19:10:24 -08:00
anon_inodes.c
get_empty_filp()/alloc_file() leave both ->f_pos and ->f_version zero
2013-02-26 02:46:11 -05:00
attr.c
bad_inode.c
lseek: the "whence" argument is called "whence"
2012-12-17 17:15:12 -08:00
binfmt_aout.c
new helper: file_inode(file)
2013-02-22 23:31:31 -05:00
binfmt_elf.c
ImgTec Meta architecture changes for v3.9-rc1
2013-03-03 12:06:09 -08:00
binfmt_elf_fdpic.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2013-02-26 20:16:07 -08:00
binfmt_em86.c
exec: use -ELOOP for max recursion depth
2012-12-17 17:15:23 -08:00
binfmt_flat.c
new helper: file_inode(file)
2013-02-22 23:31:31 -05:00
binfmt_misc.c
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
binfmt_script.c
exec: do not leave bprm->interp on stack
2012-12-20 17:40:19 -08:00
binfmt_som.c
bio-integrity.c
bio.c
block: add missing block_bio_complete() tracepoint
2013-01-14 15:00:36 +01:00
block_dev.c
Merge branch 'for-3.9/core' of git://git.kernel.dk/linux-block
2013-02-28 12:52:24 -08:00
buffer.c
Merge branch 'for-3.9/core' of git://git.kernel.dk/linux-block
2013-02-28 12:52:24 -08:00
char_dev.c
compat.c
switch timerfd compat syscalls to COMPAT_SYSCALL_DEFINE
2013-02-03 15:09:25 -05:00
compat_binfmt_elf.c
compat_ioctl.c
new helper: file_inode(file)
2013-02-22 23:31:31 -05:00
coredump.c
coredump: remove redundant defines for dumpable states
2013-02-27 19:10:11 -08:00
coredump.h
dcache.c
hlist: drop the node parameter from iterators
2013-02-27 19:10:24 -08:00
dcookies.c
direct-io.c
fs: Fix possible use-after-free with AIO
2013-02-22 23:31:36 -05:00
drop_caches.c
eventfd.c
fs, eventfd: add procfs fdinfo helper
2012-12-17 17:15:27 -08:00
eventpoll.c
epoll: prevent missed events on EPOLL_CTL_MOD
2013-01-02 09:16:43 -08:00
exec.c
coredump: remove redundant defines for dumpable states
2013-02-27 19:10:11 -08:00
fcntl.c
new helper: file_inode(file)
2013-02-22 23:31:31 -05:00
fhandle.c
Merge branch 'for-3.8' of git://linux-nfs.org/~bfields/linux
2012-12-20 14:04:11 -08:00
fifo.c
file.c
locking: Various static lock initializer fixes
2013-02-19 08:42:45 +01:00
file_table.c
cache the value of file_inode() in struct file
2013-03-01 19:48:30 -05:00
filesystems.c
fs: Limit sys_mount to only request filesystem modules.
2013-03-03 19:36:31 -08:00
fs-writeback.c
2 writeback fixes
2013-02-28 13:21:44 -08:00
fs_struct.c
constify path_get/path_put and fs_struct.c stuff
2013-03-01 23:51:07 -05:00
generic_acl.c
inode.c
hlist: drop the node parameter from iterators
2013-02-27 19:10:24 -08:00
internal.h
constify path_get/path_put and fs_struct.c stuff
2013-03-01 23:51:07 -05:00
ioctl.c
new helper: file_inode(file)
2013-02-22 23:31:31 -05:00
ioprio.c
Kconfig
fuse: Move CUSE Kconfig entry from fs/Kconfig into fs/fuse/Kconfig
2013-01-17 13:08:45 +01:00
Kconfig.binfmt
libfs.c
vfs: drop vmtruncate
2012-12-20 18:46:29 -05:00
locks.c
new helper: file_inode(file)
2013-02-22 23:31:31 -05:00
Makefile
mbcache.c
mount.h
mpage.c
namei.c
vfs: don't BUG_ON() if following a /proc fd pseudo-symlink results in a symlink
2013-03-08 09:03:07 -08:00
namespace.c
new helper: file_inode(file)
2013-02-22 23:31:31 -05:00
no-block.c
open.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2013-03-03 13:23:03 -08:00
pipe.c
fs: Preserve error code in get_empty_filp(), part 2
2013-02-22 23:31:32 -05:00
pnode.c
pnode.h
posix_acl.c
proc_namespace.c
read_write.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal
2013-03-02 08:34:06 -08:00
read_write.h
readdir.c
new helper: file_inode(file)
2013-02-22 23:31:31 -05:00
select.c
sched/rt: Move rt specific bits into new header file
2013-02-07 20:51:08 +01:00
seq_file.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2013-03-03 13:23:03 -08:00
signalfd.c
fs, epoll: add procfs fdinfo helper
2012-12-17 17:15:27 -08:00
splice.c
export kernel_write(), convert open-coded instances
2013-02-26 02:46:11 -05:00
stack.c
stat.c
switch vfs_getattr() to struct path
2013-02-26 02:46:08 -05:00
statfs.c
vfs: fix user_statfs to retry once on ESTALE errors
2012-12-20 18:50:07 -05:00
super.c
hlist: drop the node parameter from iterators
2013-02-27 19:10:24 -08:00
sync.c
new helper: file_inode(file)
2013-02-22 23:31:31 -05:00
timerfd.c
compat: restore timerfd settime and gettime compat syscalls
2013-03-02 09:35:13 -05:00
utimes.c
vfs: allow utimensat() calls to retry once on an ESTALE error
2012-12-20 18:50:08 -05:00
xattr.c
vfs: make lremovexattr retry once on ESTALE error
2012-12-20 18:50:11 -05:00
xattr_acl.c