android_kernel_xiaomi_sm8450/fs/incfs
Tadeusz Struk 3e45af8a72 ANDROID: incremental-fs: limit mount stack depth
Syzbot recently found a number of issues related to incremental-fs
(see bug numbers below). All have to do with the fact that incr-fs
allows mounts of the same source and target multiple times.
This is a design decision and the user space component "Data Loader"
expects this to work for app re-install use case.
The mounting depth needs to be controlled, however, and only allowed
to be two levels deep. In case of more than two mount attempts the
driver needs to return an error.
In case of the issues listed below the common pattern is that the
reproducer calls:

mount("./file0", "./file0", "incremental-fs", 0, NULL)

many times and then invokes a file operation like chmod, setxattr,
or open on the ./file0. This causes a recursive call for all the
mounted instances, which eventually causes a stack overflow and
a kernel crash:

BUG: stack guard page was hit at ffffc90000c0fff8
kernel stack overflow (double-fault): 0000 [#1] PREEMPT SMP KASAN

This change also cleans up the mount error path to properly clean
allocated resources and call deactivate_locked_super(), which
causes the incfs_kill_sb() to be called, where the sb is freed.

Bug: 211066171
Bug: 213140206
Bug: 213215835
Bug: 211914587
Bug: 211213635
Bug: 213137376
Bug: 211161296

Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org>
Change-Id: I08d9b545a2715423296bf4beb67bdbbed78d1be1
2022-04-06 17:24:59 +00:00
..
data_mgmt.c ANDROID: incremental-fs: remove spurious kfree() 2022-02-28 20:49:55 +00:00
data_mgmt.h ANDROID: incremental-fs: limit mount stack depth 2022-04-06 17:24:59 +00:00
format.c ANDROID: Incremental fs: fix minor printk format warning 2021-04-15 15:22:01 +00:00
format.h ANDROID: Incremental fs: Build merkle tree when enabling verity 2021-03-01 16:16:01 +00:00
integrity.c ANDROID: Incremental fs: Remove dependency on PKCS7_MESSAGE_PARSER 2020-06-08 17:03:32 +00:00
integrity.h ANDROID: Incremental fs: Remove signature checks from kernel 2020-03-18 16:22:17 +00:00
internal.h ANDROID: Incremental fs: Add FS_IOC_ENABLE_VERITY 2021-03-01 16:15:32 +00:00
Kconfig ANDROID: Incremental fs: Add zstd compression support 2020-11-05 23:00:32 +00:00
main.c ANDROID: GKI: set vfs-only exports into their own namespace 2022-01-11 09:30:47 +01:00
Makefile ANDROID: Incremental fs: Add status to sysfs 2021-04-23 15:16:25 +00:00
pseudo_files.c ANDROID: incremental-fs: fix GPF in pending_reads_dispatch_ioctl 2022-01-26 11:31:08 +00:00
pseudo_files.h ANDROID: Incremental fs: fix .blocks_written 2021-01-14 16:02:38 +00:00
sysfs.c ANDROID: Incremental fs: Make sysfs_name changeable on remount 2021-05-17 20:08:37 +00:00
sysfs.h ANDROID: Incremental fs: Make sysfs_name changeable on remount 2021-05-17 20:08:37 +00:00
verity.c ANDROID: Incremental fs: Add status to sysfs 2021-04-23 15:16:25 +00:00
verity.h ANDROID: Incremental fs: Add FS_IOC_READ_VERITY_METADATA 2021-04-23 15:16:03 +00:00
vfs.c ANDROID: incremental-fs: limit mount stack depth 2022-04-06 17:24:59 +00:00
vfs.h Revert "ANDROID: incremental-fs: fix mount_fs issue" 2022-02-23 06:35:37 +00:00