Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileManagement: Hide the FEX RootFS fd from /proc/self/fd #4138

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

asahilina
Copy link
Contributor

Chromium/CEF has code that iterates through all open FDs and bails if any are directories (apparently a sandboxing sanity check). To avoid this check, we need to hide the RootFS FD. This requires hooking all the getdents variants to skip that entry.

To keep the runtime cost low, we keep track of the inode of /proc/self/fd/ (note: not the RootFS inode, the inode of the magic symlink in /proc), and first do a quick check on that. If it matches, then we stat the dirfd we are reading and check against the procfs device, to complete the inode equality check.

As an extra benefit, this also fixes code that tries to iterate and close all/extra FDs and ends up closing the RootFS fd.

Chromium/CEF has code that iterates through all open FDs and bails if
any are directories (apparently a sandboxing sanity check). To avoid
this check, we need to hide the RootFS FD. This requires hooking all the
getdents variants to skip that entry.

To keep the runtime cost low, we keep track of the inode of
/proc/self/fd/<rootfs fd> (note: not the RootFS inode, the inode of the
magic symlink in /proc), and first do a quick check on that. If it
matches, then we stat the dirfd we are reading and check against the
procfs device, to complete the inode equality check.

As an extra benefit, this also fixes code that tries to iterate and
close all/extra FDs and ends up closing the RootFS fd.
Copy link
Member

@Sonicadvance1 Sonicadvance1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me.

@Sonicadvance1 Sonicadvance1 merged commit 55b3d67 into FEX-Emu:main Oct 28, 2024
12 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