WSL2-Linux-Kernel/net/sunrpc
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
..
auth_gss Merge branch 'for-3.9' of git://linux-nfs.org/~bfields/linux 2013-02-28 18:02:55 -08:00
xprtrdma Merge branch 'for-3.9' of git://linux-nfs.org/~bfields/linux 2013-02-28 18:02:55 -08:00
Kconfig net/sunrpc: remove depends on CONFIG_EXPERIMENTAL 2013-01-11 11:40:02 -08:00
Makefile SUNRPC: sunrpc should not explicitly depend on NFS config options 2011-07-15 09:12:23 -04:00
addr.c sunrpc: move address copy/cmp/convert routines and prototypes from clnt.h to addr.h 2013-02-05 09:41:14 -05:00
auth.c hlist: drop the node parameter from iterators 2013-02-27 19:10:24 -08:00
auth_generic.c sunrpc: Convert kuids and kgids to uids and gids for printing 2013-02-13 06:15:19 -08:00
auth_null.c SUNRPC: Move the bound cred to struct rpc_rqst 2010-08-04 08:54:09 -04:00
auth_unix.c sunrpc: Properly encode kuids and kgids in RPC_AUTH_UNIX credentials 2013-02-13 06:15:24 -08:00
backchannel_rqst.c SUNRPC: remove two BUG_ON asserts 2012-11-04 14:43:41 -05:00
bc_svc.c SUNRPC: remove BUG_ON from bc_send 2012-11-04 14:43:41 -05:00
cache.c Merge branch 'for-3.9' of git://linux-nfs.org/~bfields/linux 2013-02-28 18:02:55 -08:00
clnt.c NFS client bugfixes for Linux 3.9 2013-03-02 16:46:07 -08:00
netns.h SUNRPC: create GSS auth cache per network namespace 2012-01-31 19:28:15 -05:00
rpc_pipe.c fs: Limit sys_mount to only request filesystem modules. 2013-03-03 19:36:31 -08:00
rpcb_clnt.c sunrpc: move address copy/cmp/convert routines and prototypes from clnt.h to addr.h 2013-02-05 09:41:14 -05:00
sched.c SUNRPC: When changing the queue priority, ensure that we change the owner 2013-01-30 17:45:14 -05:00
socklib.c sunrpc: remove the second argument of k[un]map_atomic() 2012-03-20 21:48:28 +08:00
stats.c SUNRPC: Use RCU to dereference the rpc_clnt.cl_xprt field 2012-03-02 15:36:38 -05:00
sunrpc.h SUNRPC: subscribe RPC clients to pipefs notifications 2012-01-31 18:20:25 -05:00
sunrpc_syms.c SUNRPC: register PipeFS file system after pernet sybsystem 2012-04-18 11:05:48 -04:00
svc.c svcrpc: fix rpc server shutdown races 2013-02-17 10:53:51 -05:00
svc_xprt.c svcrpc: fix rpc server shutdown races 2013-02-17 10:53:51 -05:00
svcauth.c hlist: drop the node parameter from iterators 2013-02-27 19:10:24 -08:00
svcauth_unix.c Merge branch 'for-3.9' of git://linux-nfs.org/~bfields/linux 2013-02-28 18:02:55 -08:00
svcsock.c ipv6: rename datagram_send_ctl and datagram_recv_ctl 2013-01-31 13:53:08 -05:00
sysctl.c SUNRPC: make SUNPRC clients list per network namespace context 2012-01-31 18:20:25 -05:00
timer.c net: cleanup unsigned to unsigned int 2012-04-15 12:44:40 -04:00
xdr.c sunrpc: trim off trailing checksum before returning decrypted or integrity authenticated buffer 2013-02-08 15:19:10 -05:00
xprt.c SUNRPC: Don't start the retransmission timer when out of socket space 2013-02-22 15:17:17 -05:00
xprtsock.c Merge branch 'for-3.9' of git://linux-nfs.org/~bfields/linux 2013-02-28 18:02:55 -08:00