linux/fs/ecryptfs
Eric W. Biederman 7f78e03513 fs: Limit sys_mount to only request filesystem modules.
Modify the request_module to prefix the file system type with "fs-"
and add aliases to all of the filesystems that can be built as modules
to match.

A common practice is to build all of the kernel code and leave code
that is not commonly needed as modules, with the result that many
users are exposed to any bug anywhere in the kernel.

Looking for filesystems with a fs- prefix limits the pool of possible
modules that can be loaded by mount to just filesystems trivially
making things safer with no real cost.

Using aliases means user space can control the policy of which
filesystem modules are auto-loaded by editing /etc/modprobe.d/*.conf
with blacklist and alias directives.  Allowing simple, safe,
well understood work-arounds to known problematic software.

This also addresses a rare but unfortunate problem where the filesystem
name is not the same as it's module name and module auto-loading
would not work.  While writing this patch I saw a handful of such
cases.  The most significant being autofs that lives in the module
autofs4.

This is relevant to user namespaces because we can reach the request
module in get_fs_type() without having any special permissions, and
people get uncomfortable when a user specified string (in this case
the filesystem type) goes all of the way to request_module.

After having looked at this issue I don't think there is any
particular reason to perform any filtering or permission checks beyond
making it clear in the module request that we want a filesystem
module.  The common pattern in the kernel is to call request_module()
without regards to the users permissions.  In general all a filesystem
module does once loaded is call register_filesystem() and go to sleep.
Which means there is not much attack surface exposed by loading a
filesytem module unless the filesystem is mounted.  In a user
namespace filesystems are not mounted unless .fs_flags = FS_USERNS_MOUNT,
which most filesystems do not set today.

Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Acked-by: Kees Cook <keescook@chromium.org>
Reported-by: Kees Cook <keescook@google.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
2013-03-03 19:36:31 -08:00
..
crypto.c fs/ecryptfs/crypto.c: make ecryptfs_encode_for_filename() static 2012-12-18 10:10:13 -06:00
debug.c eCryptfs: update comment and debug statement 2007-10-16 09:43:11 -07:00
dentry.c stop passing nameidata * to ->d_revalidate() 2012-07-14 16:34:14 +04:00
ecryptfs_kernel.h switch vfs_getattr() to struct path 2013-02-26 02:46:08 -05:00
file.c new helper: file_inode(file) 2013-02-22 23:31:31 -05:00
inode.c switch vfs_getattr() to struct path 2013-02-26 02:46:08 -05:00
Kconfig fs/ecryptfs: remove depends on CONFIG_EXPERIMENTAL 2013-01-11 11:39:04 -08:00
keystore.c eCryptfs: Improve statfs reporting 2012-02-16 16:06:21 -06:00
kthread.c eCryptfs: fix to use list_for_each_entry_safe() when delete items 2012-12-18 10:07:29 -06:00
main.c fs: Limit sys_mount to only request filesystem modules. 2013-03-03 19:36:31 -08:00
Makefile eCryptfs: remove netlink transport 2008-10-16 11:21:39 -07:00
messaging.c hlist: drop the node parameter from iterators 2013-02-27 19:10:24 -08:00
miscdev.c eCryptfs: Make all miscdev functions use daemon ptr in file private_data 2012-07-08 12:51:44 -05:00
mmap.c eCryptfs: Avoid unnecessary disk read and data decryption during writing 2012-11-07 17:56:16 -08:00
read_write.c export kernel_write(), convert open-coded instances 2013-02-26 02:46:11 -05:00
super.c vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00