aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2013-03-02 22:39:14 -0500
committerEric W. Biederman <ebiederm@xmission.com>2013-03-03 22:36:31 -0500
commit7f78e0351394052e1a6293e175825eb5c7869507 (patch)
tree76493af33d02bd3f411e69f95b0bcdfff50412b4 /fs/ext4
parentba0e3427b03c3d1550239779eca5c1c5a53a2152 (diff)
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>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/super.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 5e6c87836193..34e855219231 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -90,6 +90,7 @@ static struct file_system_type ext2_fs_type = {
90 .kill_sb = kill_block_super, 90 .kill_sb = kill_block_super,
91 .fs_flags = FS_REQUIRES_DEV, 91 .fs_flags = FS_REQUIRES_DEV,
92}; 92};
93MODULE_ALIAS_FS("ext2");
93#define IS_EXT2_SB(sb) ((sb)->s_bdev->bd_holder == &ext2_fs_type) 94#define IS_EXT2_SB(sb) ((sb)->s_bdev->bd_holder == &ext2_fs_type)
94#else 95#else
95#define IS_EXT2_SB(sb) (0) 96#define IS_EXT2_SB(sb) (0)
@@ -104,6 +105,7 @@ static struct file_system_type ext3_fs_type = {
104 .kill_sb = kill_block_super, 105 .kill_sb = kill_block_super,
105 .fs_flags = FS_REQUIRES_DEV, 106 .fs_flags = FS_REQUIRES_DEV,
106}; 107};
108MODULE_ALIAS_FS("ext3");
107#define IS_EXT3_SB(sb) ((sb)->s_bdev->bd_holder == &ext3_fs_type) 109#define IS_EXT3_SB(sb) ((sb)->s_bdev->bd_holder == &ext3_fs_type)
108#else 110#else
109#define IS_EXT3_SB(sb) (0) 111#define IS_EXT3_SB(sb) (0)
@@ -5152,7 +5154,6 @@ static inline int ext2_feature_set_ok(struct super_block *sb)
5152 return 0; 5154 return 0;
5153 return 1; 5155 return 1;
5154} 5156}
5155MODULE_ALIAS("ext2");
5156#else 5157#else
5157static inline void register_as_ext2(void) { } 5158static inline void register_as_ext2(void) { }
5158static inline void unregister_as_ext2(void) { } 5159static inline void unregister_as_ext2(void) { }
@@ -5185,7 +5186,6 @@ static inline int ext3_feature_set_ok(struct super_block *sb)
5185 return 0; 5186 return 0;
5186 return 1; 5187 return 1;
5187} 5188}
5188MODULE_ALIAS("ext3");
5189#else 5189#else
5190static inline void register_as_ext3(void) { } 5190static inline void register_as_ext3(void) { }
5191static inline void unregister_as_ext3(void) { } 5191static inline void unregister_as_ext3(void) { }
@@ -5199,6 +5199,7 @@ static struct file_system_type ext4_fs_type = {
5199 .kill_sb = kill_block_super, 5199 .kill_sb = kill_block_super,
5200 .fs_flags = FS_REQUIRES_DEV, 5200 .fs_flags = FS_REQUIRES_DEV,
5201}; 5201};
5202MODULE_ALIAS_FS("ext4");
5202 5203
5203static int __init ext4_init_feat_adverts(void) 5204static int __init ext4_init_feat_adverts(void)
5204{ 5205{