android_kernel_google_msm/fs/nfs
Eric W. Biederman 3e34c77b60 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.

Change-Id: I623b13dbdb44bb9ba7481f29575e1ca4ad8102f4
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>
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2020-12-14 20:34:05 +01:00
..
blocklayout
objlayout
Kconfig
Makefile
cache_lib.c
cache_lib.h
callback.c nfs: fix high load average due to callback thread sleeping 2015-09-18 09:20:32 +08:00
callback.h
callback_proc.c
callback_xdr.c NFSv4.1: Fix a kfree() of uninitialised pointers in decode_cb_sequence_args 2015-06-19 11:40:14 +08:00
client.c
delegation.c NFSv4: Don't call put_rpccred() under the rcu_read_lock() 2015-06-19 11:40:20 +08:00
delegation.h
dir.c don't pass nameidata to ->create() 2018-12-07 22:28:00 +04:00
direct.c
dns_resolve.c
dns_resolve.h
file.c mm: kill vma flag VM_CAN_NONLINEAR 2020-11-29 16:11:40 +03:00
fscache-index.c
fscache.c
fscache.h
getroot.c move d_rcu from overlapping d_child to overlapping d_alias 2017-09-22 19:11:55 +03:00
idmap.c
inode.c Merge remote-tracking branch 'stable/linux-3.4.y' into lineage-15.1 2017-12-27 17:13:15 +03:00
internal.h
iostat.h
mount_clnt.c
namespace.c
netns.h
nfs2xdr.c
nfs3acl.c fs: make posix_acl_create more useful 2020-12-07 21:02:49 +03:00
nfs3proc.c nfs: clean up ->create in nfs_rpc_ops 2018-12-07 22:20:38 +04:00
nfs3xdr.c NFS: Fix size of NFSACL SETACL operations 2015-10-22 09:20:03 +08:00
nfs4_fs.h
nfs4filelayout.c
nfs4filelayout.h
nfs4filelayoutdev.c
nfs4namespace.c
nfs4proc.c nfs: clean up ->create in nfs_rpc_ops 2018-12-07 22:20:38 +04:00
nfs4renewd.c NFSv4.1: Fix an NFSv4.1 state renewal regression 2015-02-02 17:04:46 +08:00
nfs4state.c Failing to send a CLOSE if file is opened WRONLY and server reboots on a 4.x mount 2015-10-22 09:20:08 +08:00
nfs4xdr.c
nfsroot.c
pagelist.c
pnfs.c NFSv4.1: Fix a race in pNFS layoutcommit 2014-06-07 16:02:05 -07:00
pnfs.h
pnfs_dev.c
proc.c nfs: clean up ->create in nfs_rpc_ops 2018-12-07 22:20:38 +04:00
read.c
super.c fs: Limit sys_mount to only request filesystem modules. 2020-12-14 20:34:05 +01:00
symlink.c
sysctl.c
unlink.c
write.c