WSL2-Linux-Kernel/drivers/mtd
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
..
chips Fairly unexciting MTD merge for 3.9: 2013-03-02 16:33:54 -08:00
devices Fairly unexciting MTD merge for 3.9: 2013-03-02 16:33:54 -08:00
lpddr
maps Fairly unexciting MTD merge for 3.9: 2013-03-02 16:33:54 -08:00
nand Fairly unexciting MTD merge for 3.9: 2013-03-02 16:33:54 -08:00
onenand mtd: omap-onenand: pass device_node in platform data 2013-02-01 14:10:11 -08:00
tests Fairly unexciting MTD merge for 3.9: 2013-03-02 16:33:54 -08:00
ubi Fairly unexciting MTD merge for 3.9: 2013-03-02 16:33:54 -08:00
Kconfig Fairly unexciting MTD merge for 3.9: 2013-03-02 16:33:54 -08:00
Makefile mtd: bcm47part driver for BCM47XX chipsets 2012-09-29 15:32:31 +01:00
afs.c
ar7part.c mtd: Allow removal of partitioning modules 2013-02-04 09:27:33 +02:00
bcm47xxpart.c Fairly unexciting MTD merge for 3.9: 2013-03-02 16:33:54 -08:00
bcm63xxpart.c mtd: bcm63xxpart: use correct printk format for partitions 2012-11-21 17:15:06 +02:00
cmdlinepart.c mtd: Allow removal of partitioning modules 2013-02-04 09:27:33 +02:00
ftl.c
inftlcore.c
inftlmount.c
mtd_blkdevs.c mtd: mtd_blkdevs: Replace request handler kthread with a workqueue 2012-11-21 17:02:23 +02:00
mtdblock.c
mtdblock_ro.c
mtdchar.c fs: Limit sys_mount to only request filesystem modules. 2013-03-03 19:36:31 -08:00
mtdconcat.c
mtdcore.c mtd: convert to idr_alloc() 2013-02-27 19:10:18 -08:00
mtdcore.h
mtdoops.c mtdoops: don't erase flash at each boot 2012-11-15 15:37:51 +02:00
mtdpart.c UAPI Disintegration 2012-10-09 2012-10-09 15:04:25 +01:00
mtdsuper.c VFS: Pass mount flags to sget() 2012-07-14 16:38:34 +04:00
mtdswap.c
nftlcore.c
nftlmount.c
ofpart.c mtd: Allow removal of partitioning modules 2013-02-04 09:27:33 +02:00
redboot.c
rfd_ftl.c
sm_ftl.c mtd: kill MTD_NAND_VERIFY_WRITE 2012-09-29 15:00:46 +01:00
sm_ftl.h
ssfdc.c