Repository navigation
Reject --overlay-src that is followed by --args - #829
Open
sarankumar1325 wants to merge 1 commit into
Open
sarankumar1325 wants to merge 1 commit into
sarankumar1325 wants to merge 1 commit into
Conversation
The --overlay, --tmp-overlay and --ro-overlay options read their --overlay-src paths back from argv, counting backwards from their own position. next_overlay_src_count is global, but argv is per argument list, so an --overlay-src on the command line followed by an --overlay inside an --args file made make_setup_overlay_src_ops() index before the start of the file's argument vector and crash with SIGSEGV. Fail with the usual "--overlay-src must be followed by ..." error when --args is reached while --overlay-src options are pending, the same as for any other option in that position. Fixes: containers#828 Signed-off-by: sarankumar1325 <120080287+sarankumar1325@users.noreply.github.com>
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.
Fixes #828.
--overlay,--tmp-overlayand--ro-overlayread their--overlay-srcpaths back fromargv(argv[1 - 2 * i]inmake_setup_overlay_src_ops()).next_overlay_src_countis global, butargvbelongs to one argument list. So when--overlay-srcis on the command line and the--overlaycomes from an--argsfile, the lookup reads before the start of the file's argument vector and bwrap crashes:This PR makes
--argsfail with the existing "--overlay-src must be followed by another --overlay-src or one of --overlay, --tmp-overlay, or --ro-overlay" error while--overlay-srcoptions are pending. That matches the documented rule: the option after--overlay-srchere is--args, not an overlay option. The other direction (--overlay-srcat the end of an--argsfile,--overlayon the command line) already failed with that error once the file was parsed. Putting--overlay-srcand its--overlayin the same file still works.With this change the command above prints the error and exits with status 1.
Test: new case in
tests/test-run.shright after the existing--argstest. It segfaults on main and passes with the fix.meson testlocally: test-run.sh 62 ok, test-sandbox.py 68 ok, test-utils, pidns and userns ok; test-seccomp.py skipped (no python3-seccomp on my box).I used an AI assistant for this change. I reproduced the crash, reviewed the patch and ran the tests myself.