Repository navigation
logger: convert: refuse ldc format text that does not match its params - #11331
Open
Shrusti-pk wants to merge 1 commit into
Open
Shrusti-pk wants to merge 1 commit into
Shrusti-pk wants to merge 1 commit into
Conversation
Collaborator
|
Can one of the admins verify this patch?
|
PR 11331: test resultsRun date: 2026-10-23 09:10 UTC Tested commit: e301d06078a22abbf3e5a9eadb5149b1bbf73772 |
Contributor
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
What changed in this PR
Updates sof-logger’s minimal printf-like formatting to reject unsafe/mismatched .ldc format strings (preventing out-of-bounds variadic reads and dangerous specifiers), and fall back to printing the entry text safely when validation fails.
Changes:
- Change
process_params()to return a status code and reject invalid/unsafe format strings with-EINVAL. - Skip
"%%"before parameter-count validation and refuse unsupported/dangerous conversion patterns (e.g.,*,%n,%swith modifiers). - On validation failure, print the entry text without using it as a
printf()format string.
| File | Description |
|---|---|
| tools/logger/convert.c | Adds format-string validation and error propagation to prevent unsafe fprintf() usage with .ldc-provided format text. |
Review effort: Lite
Copilot stopped reviewing on behalf of
lgirdwood due to an error
October 22, 2026 12:28
print_entry_params() hands the log text from the .ldc dictionary to fprintf() as the format string, with params_num trace words as the arguments. process_params() checks the text but only logs on a mismatch: with more conversion specifiers than params_num it prints "Too many % conversion specifiers" and fprintf() still runs with the full format, so every extra %s or %x reads a variadic argument that was never passed. The generic branch also forwards any specifier other than bare %s, %%, %pU and %pQ unchanged, so "%5s" or "%ls" dereferences the raw 32-bit trace word as a string pointer, a '*' width or precision consumes an extra argument and %n writes through a trace value. Return -EINVAL from process_params() for too many specifiers, a trailing '%', and '*', 'n' or modified 's' conversions, and print the entry text as a plain string in that case. Skip "%%" before the parameter count check since it does not consume a parameter. Output for valid formats is unchanged. Signed-off-by: Shrushti P K <shrusthi@labs.digiscrypt.com>
Shrusti-pk
force-pushed
the
logger-format-spec-check
branch
from
October 23, 2026 07:30
2c7cf8b to
e301d06
Compare
lgirdwood
approved these changes
Oct 23, 2026
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.



sof-logger hands the log text from the .ldc file to fprintf() as the format string, and process_params() only logs when that text does not fit the params:
name %5swith params_num = 1, orval %u then %swith params_num = 1, run withsof-logger -l t.ldc -i t.trace -nreproduces both under ASanprocess_params() now returns -EINVAL in those cases and the entry text is printed as a plain string. "%%" is skipped before the param count check. Output for %d %u %x %08x %zu %lx %llu %f %pU %pQ %s %% is unchanged.