feat(validator): reject null bytes in mount fields during spec validation - #3633
Open
tkshsbcue wants to merge 1 commit into
Open
feat(validator): reject null bytes in mount fields during spec validation#3633tkshsbcue wants to merge 1 commit into
tkshsbcue wants to merge 1 commit into
Conversation
…tion Mount string fields (destination, source, type, options) containing an interior null byte (`\0`) were passed unchanged down to the `mount(2)` syscall, where the kernel rejects them with a generic `EINVAL`, producing a cryptic error that does not indicate which mount or field is at fault. Validate these fields early in `Validator::validate_spec` and return a clear `MountContainsNullByte` error naming the offending field and value. This runs on both the create and exec (tenant) paths. Fixes: youki-dev#3591
Contributor
|
@tkshsbcue |
Member
|
I do not think validation needs to be this strict. If we make any changes here, I feel that improving the error message would be sufficient. There is also a comment like the following, so I think it is reasonable to be cautious about adding more validation: |
Contributor
Author
|
alright i will have a look into this! |
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.
Summary
Fixes #3591.
When a mount string field (
destination,source,type, or an entry inoptions) contains an interior null byte (\0), the value was passed unchanged all the way down to themount(2)syscall. The kernel then rejects it with a genericEINVAL, producing a cryptic error that gives no indication of which mount or field is at fault.Changes
Validator::validate_spec_for_mounts, wired intoValidator::validate_spec, which scans every mount'sdestination,source,type, andoptionsfor an interior null byte and returns a clear error early during spec validation.ErrInvalidSpec::MountContainsNullByte { field, value }so the error names the offending field and value.Because
validate_specruns on both the create and exec (tenant) paths, invalid mounts are now rejected up front with an actionable message instead of failing late at the syscall level.Tests
Added unit tests covering a null byte in each of
destination,source,type, andoptions, plus the happy path (clean mounts) and the no-mounts case.