Fix shadow cache path resolution with host_root#42
Merged
Conversation
ensure_path_shadow_cache and reopen_cached_shadow_fd called open() on guest-relative paths (host_root prefix already stripped by kbox_translate_path_for_lkl), resolving against the supervisor's real root instead of host_root. Read-only sandbox escape when host_root is set: guest opens /etc/passwd, supervisor opens the host's /etc/passwd rather than host_root/etc/passwd. Add build_host_open_path() that re-prefixes ctx->host_root before open(). In pure image mode (no host_root) the helper is a passthrough. Change-Id: I9957ce0127bc733b1013fe2ee04e0654635d8ba9
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.
ensure_path_shadow_cache and reopen_cached_shadow_fd called open() on guest-relative paths (host_root prefix already stripped by kbox_translate_path_for_lkl), resolving against the supervisor's real root instead of host_root. Read-only sandbox escape when host_root is set: guest opens /etc/passwd, supervisor opens the host's /etc/passwd rather than host_root/etc/passwd.
Add build_host_open_path() that re-prefixes ctx->host_root before open(). In pure image mode (no host_root) the helper is a passthrough.
Change-Id: I9957ce0127bc733b1013fe2ee04e0654635d8ba9
Summary by cubic
Fixes path resolution when
host_rootis set so shadow cache opens files underhost_rootinstead of the supervisor’s real root. Prevents a read-only sandbox escape (e.g.,/etc/passwdresolving to the host).build_host_open_path()to prefixctx->host_rootbeforeopen().ensure_path_shadow_cacheandreopen_cached_shadow_fdto use it; passthrough when nohost_root.Written for commit 0000933. Summary will update on new commits.