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.
p7zip handles a lot of archive formats, each bringing complexity and extending
its attack surface. Landlock is a Linux security sandboxing mechanism which
helps limit the impact of bug exploitation. These modifications enable to use
Landlock following a best-effort appoach: if Landlock is available on the
running system, then it will be used to sandbox p7zip, otherwise nothing will
change.
By default, all console commands (7z, 7za and 7zr) reading archives will create
a sandbox which denies basic file-system accesses (e.g. read, create or write
to files). All other commands (b, h, i, t) are untouched.
The sandbox is enforced when calling COpenCallbackConsole::Open_setTotal(),
which seems to be the more generic place for this purpose.
When extracting an archive, a new helper called GetOutputBaseDir() is used to
add security exception to the sandbox so that it will be allowed to create
files in the output directory.
See https://docs.kernel.org/userspace-api/landlock.html for the kernel UAPI
documentation.