ANDROID: fuse-bpf: enforce stacking depth limits on backing files
FUSE-BPF backing file passthrough allows VFS operations to be
forwarded directly to a backing lower-filesystem file. The backing
file is resolved from a daemon-supplied `backing_fd` in FUSE_LOOKUP
replies.
To ensure architectural integrity in stacked filesystem environments
(such as FUSE-BPF overlaid on other filesystems), we must enforce
strict nesting limits and loop prevention. Previously, the FUSE-BPF
backing path did not properly track filesystem stacking depth or
validate backing target types, which could allow the creation of
self-referencing or excessively deep nesting loops.
Enforce standard VFS stacking limits and prevent recursive nesting
loops.
Implement this by:
1. Rejecting any `backing_fd` (in `fuse_dev_do_write`) whose resolved
file resides on a FUSE filesystem (identified by `FUSE_SUPER_MAGIC`)
or whose backing superblock stack depth exceeds
`FILESYSTEM_MAX_STACK_DEPTH`.
2. Propagating the backing superblock's stack depth (+1) to the FUSE-BPF
superblock's `s_stack_depth` in `fuse_fill_super_common` to enable
correct VFS stack depth tracking.
3. Rejecting the `root_dir` mount option (in `fuse_parse_param`) if the
target directory resides on a FUSE filesystem or if its stack depth
exceeds `FILESYSTEM_MAX_STACK_DEPTH`.
Bug: 508703285
Signed-off-by: Sandeep Dhavale <[email protected]>
Change-Id: I4b272548905047673cdc67b78d1638b08a60e979
(cherry picked from commit a52575260f65a2ae33e8da933a8aa054f3c75d74)
Signed-off-by: Lee Jones <[email protected]>
1 file changed