Some fixes to mounting path validation (fix #3733) #3908
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.
Fixes for #3733 and Additional Issues Found During Inspection
This PR addresses the problems outlined in #3733, along with some related issues discovered during review. Details below.
Issues Fixed
Relative Paths Incorrectly Resolving to
/home/ubuntu
The issue occurs when relative paths unintentionally resolve to
/home/ubuntu
, allowing unexpected mounts. Here’s how to reproduce it (same steps as in the issue, repeated for clarity):Relative Paths Allowing Mounts to Restricted Directories
Similar path resolution issues allowed mounting to restricted locations such as
/dev/
,/
:Issues with Non-Normalized Paths Causing Duplicate Entries
Paths should be normalized before being stored in vm_mounts to prevent different representations of the same path from being treated as separate entries. Without normalization, paths like
/home/foo
and../foo
are considered distinct, leading to inconsistencies.Fix Implementation
A new function, make_abspath, has been added to src/utils/utils.cpp.
Validation & Tests After Fixes