Kernel Tree For Xiaomi 11 Lite NE 5G
Go to file
Al Viro a29e2ba970 exfat: fix memory leak in exfat_parse_param()
butt3rflyh4ck reported memory leak found by syzkaller.

A param->string held by exfat_mount_options.

BUG: memory leak

unreferenced object 0xffff88801972e090 (size 8):
  comm "syz-executor.2", pid 16298, jiffies 4295172466 (age 14.060s)
  hex dump (first 8 bytes):
    6b 6f 69 38 2d 75 00 00                          koi8-u..
  backtrace:
    [<000000005bfe35d6>] kstrdup+0x36/0x70 mm/util.c:60
    [<0000000018ed3277>] exfat_parse_param+0x160/0x5e0
fs/exfat/super.c:276
    [<000000007680462b>] vfs_parse_fs_param+0x2b4/0x610
fs/fs_context.c:147
    [<0000000097c027f2>] vfs_parse_fs_string+0xe6/0x150
fs/fs_context.c:191
    [<00000000371bf78f>] generic_parse_monolithic+0x16f/0x1f0
fs/fs_context.c:231
    [<000000005ce5eb1b>] do_new_mount fs/namespace.c:2812 [inline]
    [<000000005ce5eb1b>] do_mount+0x12bb/0x1b30 fs/namespace.c:3141
    [<00000000b642040c>] __do_sys_mount fs/namespace.c:3350 [inline]
    [<00000000b642040c>] __se_sys_mount fs/namespace.c:3327 [inline]
    [<00000000b642040c>] __x64_sys_mount+0x18f/0x230 fs/namespace.c:3327
    [<000000003b024e98>] do_syscall_64+0xf6/0x7d0
arch/x86/entry/common.c:295
    [<00000000ce2b698c>] entry_SYSCALL_64_after_hwframe+0x49/0xb3

exfat_free() should call exfat_free_iocharset(), to prevent a leak
in case we fail after parsing iocharset= but before calling
get_tree_bdev().

Additionally, there's no point copying param->string in
exfat_parse_param() - just steal it, leaving NULL in param->string.
That's independent from the leak or fix thereof - it's simply
avoiding an extra copy.

Fixes: 719c1e182916 ("exfat: add super block operations")
Cc: stable@vger.kernel.org # v5.7
Reported-by: butt3rflyh4ck <butterflyhuangxx@gmail.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
2020-06-17 22:28:41 +09:00
.travis_cmd_wrapper.pl exfat: add travis-CI build and test support 2020-02-03 22:43:47 +09:00
.travis_get_mainline_kernel exfat: add travis-CI build and test support 2020-02-03 22:43:47 +09:00
.travis.yml exfat: enable generic/452 test 2020-06-17 22:08:38 +09:00
balloc.c exfat: remove EXFAT_SB_DIRTY flag 2020-06-17 22:08:32 +09:00
cache.c exfat: initial commit 2020-02-03 21:47:19 +09:00
dir.c exfat: remove EXFAT_SB_DIRTY flag 2020-06-17 22:08:32 +09:00
exfat_fs.h exfat: remove EXFAT_SB_DIRTY flag 2020-06-17 22:08:32 +09:00
exfat_raw.h exfat: separate the boot sector analysis 2020-06-04 15:42:41 +09:00
fatent.c exfat: remove EXFAT_SB_DIRTY flag 2020-06-17 22:08:32 +09:00
file.c exfat: fix incorrect update of stream entry in __exfat_truncate() 2020-06-04 15:42:57 +09:00
inode.c fs: convert mpage_readpages to mpage_readahead 2020-06-17 22:08:28 +09:00
Kconfig exfat: initial commit 2020-02-03 21:47:19 +09:00
Makefile exfat: linux 4.16 kernel build support 2020-02-04 09:18:10 +09:00
misc.c exfat: remove EXFAT_SB_DIRTY flag 2020-06-17 22:08:32 +09:00
namei.c exfat: move setting VOL_DIRTY over exfat_remove_entries() 2020-06-17 22:08:41 +09:00
nls.c exfat: Fix pontential use after free in exfat_load_upcase_table() 2020-06-09 08:45:56 +09:00
README.md exfat: fix typo 2020-02-10 21:35:58 +09:00
super.c exfat: fix memory leak in exfat_parse_param() 2020-06-17 22:28:41 +09:00

exFAT filesystem

This is the exfat filesystem for support from the linux 4.1 kernel to the latest kernel.

Installing as a stand-alone module

Install prerequisite package for Fedora, RHEL:

	yum install kernel-devel-$(uname -r)

Build step:

	make
	sudo make install

To load the driver manually, run this as root:

	modprobe exfat

Installing as a part of the kernel

  1. Let's take [linux] as the path to your kernel source dir.
	cd [linux]
	cp -ar exfat [linux]/fs/
  1. edit [linux]/fs/Kconfig
	source "fs/fat/Kconfig"
	+source "fs/exfat/Kconfig"
	source "fs/ntfs/Kconfig"
  1. edit [linux]/fs/Makefile
	obj-$(CONFIG_FAT_FS)          += fat/
	+obj-$(CONFIG_EXFAT_FS)       += exfat/
	obj-$(CONFIG_BFS_FS)          += bfs/
  1. make menuconfig and set exfat
	File systems  --->
		DOS/FAT/NT Filesystems  --->
			<M> exFAT filesystem support
			(utf8) Default iocharset for exFAT

build your kernel