fix test segfaults caused by uninitialized memory#739
Merged
vathpela merged 2 commits intorhboot:mainfrom Apr 2, 2025
Merged
Conversation
8 tasks
In test-mock-variables.c, we create a list of names to filter against, but we skip entries that have MOK_VARIABLE_CONFIG_ONLY set. This leaves the list with uninitialized strings, which segfaults (depending on compiler versions) when mock_load_variables() tries to compare the names later. This patch changes the consumers of mock_load_variables() to initialize the filter name to an empty (but terminated) string instead. Since mock_load_variables() is strictly called down the call stack from any case doing this, we can assign them to an empty string on the stack safely, and that will cause the comparison to correctly behave. Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
efdf69c to
5ee76f1
Compare
Member
|
I've moved some of the info from this PR into the commit message so it's easier to understand later, but otherwise this looks good to me, thanks! |
8 tasks
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.
while preparing shim 16.0 for our Debian Bookworm based Debian derivative, I noticed the
test_get_variable_0andtest_gnvn_0tests failing (depending on SHIM_DEBUG value).taking a closer look with gdb breaking at
test-mock-variables.c:310for thetest_get_variable_0case:with Debian Trixie the test case passes, because there is no random memory contents at that location (slightly newer GCC 12, but might be some other cofounding factor affecting the memory layout or initialization):
in case there won't be any non-CONFIG_ONLY vars added later in the array, simple setting the first skipped entry to
NULLand breaking the loop should also work.