Skip to content

Allow MediaProvider to use daemon FDs during FUSE passthrough - #130

Merged
chenxiaolong merged 1 commit into
chenxiaolong:masterfrom
HiFiPhile:pr/fuse-passthrough-fd
Sep 25, 2026
Merged

chenxiaolong merged 1 commit into
chenxiaolong:masterfrom
HiFiPhile:pr/fuse-passthrough-fd

Conversation

@HiFiPhile

Copy link
Copy Markdown
Contributor

Issue

Exporting /storage/emulated/0/disk.img successfully configured the USB LUN, but the host showed an empty/unreadable disk. MSD received a valid 64,000,000-byte FUSE file descriptor; host access then triggered this SELinux denial:

avc: denied { use } for comm="file-storage"
scontext=u:r:mediaprovider_app:s0:c213,c256,c512,c768
tcontext=u:r:msd_daemon:s0 tclass=fd permissive=0

Fix

The policy already allows msd_daemon to use MediaProvider descriptors. Add the reverse permission, allow mediaprovider_app msd_daemon fd use, when mediaprovider_app exists. This permits the observed access by the mass-storage worker using MediaProvider credentials. It is consistent with Android's FUSE passthrough implementation, which overrides credentials for backing-file I/O.

Test environment

  • Device model: OnePlus CPH2747
  • Android version: 16
  • KernelSU Next userspace version: 3.4.0
  • MSD version: 2.5, with local authentication changes
  • SELinux: enforcing
  • SELinux Hide: enabled

Validation

  • Applying only this additional rule to the existing enforcing policy made the expected disk contents visible on the host when the same image was exported again.
  • No new matching file-storage denials appeared during subsequent exports.
  • The updated arm64 policy patcher compiled and successfully patched both a saved policy and the live policy. Rust formatting and patch whitespace checks passed.

CI

  • Android build and module packaging: passed (./gradlew --no-daemon build zipDebug -x assembleRelease).
  • Native builds: arm64-v8a, armeabi-v7a, and x86_64 passed.
  • Android lint: passed. The Gradle unit-test task reported NO-SOURCE; CI did not execute device tests or the native authentication tests.
  • cargo-deny: passed.

CI ran on ci/fuse-passthrough-fd at c04b327. Its source matches pr/fuse-passthrough-fd at 7bd728f; only the two workflow push triggers differ. Release builds are excluded by the existing workflow.

Validation scope

The live comparison used a local build with separate authentication changes; this PR contains only the seven-line policy change and applies independently to current upstream. The boot-time patcher was updated, but persistence has not yet been retested across a reboot. No namespace, image-path, or descriptor-passing changes are included.

@chenxiaolong chenxiaolong self-assigned this Sep 25, 2026
@chenxiaolong

Copy link
Copy Markdown
Owner

Thanks for the PR!

MSD version: 2.5, with local authentication changes

Does this also happen with regular v2.5 (or the master branch)? My device also use FUSE passthrough for MediaProvider, but I don't encounter this AVC denial.

@HiFiPhile

Copy link
Copy Markdown
Contributor Author

Does this also happen with regular v2.5 (or the master branch)? My device also use FUSE passthrough for MediaProvider, but I don't encounter this AVC denial.

Yes it happens on master branch, also happens on https://github.com/Enginex0/UsbMassStorage

chenxiaolong added a commit that referenced this pull request Sep 25, 2026
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
@chenxiaolong
chenxiaolong merged commit 7bd728f into chenxiaolong:master Sep 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants