android_kernel_xiaomi_sm7250/fs/incfs
Tadeusz Struk 2c142e4e2f 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-08 12:58:18 -07:00
..
data_mgmt.c ANDROID: Incremental fs: Set credentials before reading/writing 2021-04-15 22:18:07 +00:00
data_mgmt.h ANDROID: incremental-fs: limit mount stack depth 2022-04-08 12:58:18 -07:00
format.c ANDROID: Incremental fs: Set credentials before reading/writing 2021-04-15 22:18:07 +00:00
format.h ANDROID: Incremental fs: Set credentials before reading/writing 2021-04-15 22:18:07 +00:00
integrity.c ANDROID: Incremental fs: Remove dependency on PKCS7_MESSAGE_PARSER 2020-06-09 15:27:23 +00:00
integrity.h ANDROID: Incremental fs: Remove signature checks from kernel 2020-03-18 09:57:55 -07:00
internal.h ANDROID: Initial commit of Incremental FS 2020-01-30 11:25:11 -08:00
Kconfig Revert "ANDROID: Incremental fs: Remove unnecessary dependencies" 2021-01-26 13:31:16 -08:00
main.c ANDROID: Incremental fs: Set credentials before reading/writing 2021-04-15 22:18:07 +00:00
Makefile Revert "ANDROID: Incremental fs: Separate pseudo-file code" 2021-01-26 13:31:11 -08:00
OWNERS ANDROID: Add OWNERS files referring to the respective android-mainline OWNERS 2021-04-03 14:09:44 +00:00
vfs.c ANDROID: incremental-fs: limit mount stack depth 2022-04-08 12:58:18 -07:00
vfs.h Revert "ANDROID: Incremental fs: Separate pseudo-file code" 2021-01-26 13:31:11 -08:00