Repository navigation
portal: Account for source fds in fd_map_remap_fd max_fd tracking - #6785
Merged
Merged
Conversation
fd_map_remap_fd assigns a temporary fd number (++max_fd) that may later be used as a conflict resolution target. If the source fd passed to fd_map_remap_fd is higher than max_fd, conflict resolution can assign a replacement value that collides with that source fd. In child_setup_func, the dup2 for the conflicting entry then overwrites the source fd before it is remapped, delivering the wrong fd to the child process. In practice this manifests as sandbox-expose-fd-ro passing a random fd (e.g. a socket) instead of the intended O_PATH fd to flatpak run via --ro-bind-fd, producing errors like: error: /proc/self/fd/21 resolves to non-absolute path socket:[423446] Similar error have been observed in Epiphany/WebKit: https://bugs.webkit.org/show_bug.cgi?id=305344
swick
force-pushed
the
wip/portal-fd-remap-fix
branch
from
August 18, 2026 15:54
6126656 to
d443535
Compare
Collaborator
Author
|
Another Epiphany crash has been confirmed to be fixed with this. /cc @smcv |
Collaborator
Specifically, I found this fixes: #6783. I see https://gitlab.gnome.org/GNOME/libglnx/-/merge_requests/79 has already been proposed to fix that issue, but that did not work for me. |
smcv
approved these changes
Aug 19, 2026
Collaborator
I think perhaps there's more than one root cause for the same symptom. Hopefully it's only two: the one fixed by #6787 (which integrates libglnx!79) and the one fixed here. |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fd_map_remap_fd assigns a temporary fd number (++max_fd) that may later be used as a conflict resolution target. If the source fd passed to fd_map_remap_fd is higher than max_fd, conflict resolution can assign a replacement value that collides with that source fd. In child_setup_func, the dup2 for the conflicting entry then overwrites the source fd before it is remapped, delivering the wrong fd to the child process.
In practice this manifests as sandbox-expose-fd-ro passing a random fd (e.g. a socket) instead of the intended O_PATH fd to flatpak run via --ro-bind-fd, producing errors like:
error: /proc/self/fd/21 resolves to non-absolute path socket:[423446]
Similar error have been observed in Epiphany/WebKit:
https://bugs.webkit.org/show_bug.cgi?id=305344
Verified by an LLM, with a test case which is too specific to commit to the repo: