vsprintf: Don't leak pointers
Get series with b4
b4 am [email protected] change-id 20261015-vsprintf_kallsym-73d5ed6f800eVersions newest first
- v5 Latest2 patches 7 repliesIn review
- v42 patches 7 repliesSuperseded
- v32 patches 0 repliesSuperseded inferred link
Earlier versions · 2
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v2 | 2 patches | 13 replies | Superseded inferred link | |
| v1 | 2 patches | 7 replies | Superseded |
Patches in v5 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | vsprintf: Don't leak pointers for %ps without KALLSYMS enabledlib/ | +1 | 0 replies | |
| 2/2 | kallsyms: Don't leak pointers for unresolved symbolskernel/ | +1 | 5 replies |
Reviews trailers per patch
All 2 patches have a Reviewed-by or Acked-by.
| Patch | Petr Mladek |
|---|---|
| 1/2 | R-b |
| 2/2 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v5 0/2] vsprintf: Don't leak pointers
It is possible to leak pointers via %ps without KALLSYMS enabled. With KALLSYMS pointers can be leaked if they can not be resolved.
The tiny series has two patches, one for each issue.
I do follow the %p format instead of printing "(unknown)" since I care more about getting it out of the way than the actual content (as long as it is not the leaked pointer). Last time the discussion added the h:
prefix to a hashed pointer to identify it as such. I would like to keep this part out of the series since there are few users that expect a certain pointer width and adding two extra characters would break that (we could strip the two 0 on 64bit but again, not related to this problem here).
v4…v5: https://patch.msgid.link/[email protected]
- Use %p instead snprintf_default_pointer(). This might recurse back to vsnprintf() if used by '%ps' but it already did so. Suggested by Petr Mladek.
v3…v4: https://patch.msgid.link/[email protected]
- In symbol_string(), !CONFIG_KALLSYMS case, use the 'value' argument instead 'ptr' to consider the '%pR' case. Noticed by [email protected].
- The kerneldoc for snprintf_default_pointer() must describe the 'len' argument instead the not existing 'size'. Noticed by [email protected].
- sashiko noticed that the string isn't properly terminated if the
input buffer is too small.
v2…v3: https://lore.kernel.org/all/[email protected]/
- Instead of "(unknown)" the hashed pointer is printed. This follows the generic %p flow.
- In v2 I argued that it is better so print the actual pointer instead hiding it for post-mortem analysis. After looking at some backtraces with invalid pointers (not part of the kernel image) I realised the the PC is already part of the register dump. There I changed it back to what %p would do if it can't resolve a pointer. Again, following %p flow so it can be overridden at boot.
v1…v2: https://lore.kernel.org/all/[email protected]/
- For %ps and !KALLSYMS no_hash_pointers is used to decide if the pointer should be written or not. This aligns with the %p policy.
- For %ps and KALLSYMS, unresolved pointer continue to be leaked. It has been pointed out it might be useful to see them in backtraces/ crashes if the return address became invalid.
Cc: Andrew Morton <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Petr Mladek <[email protected]>
Cc: Rasmus Villemoes <[email protected]>
Cc: Sergey Senozhatsky <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Tycho Andersen <[email protected]>
To: [email protected]
Sebastian
---
Sebastian Andrzej Siewior (2):
vsprintf: Don't leak pointers for %ps without KALLSYMS enabled
kallsyms: Don't leak pointers for unresolved symbols
kernel/kallsyms.c | 2 +- lib/vsprintf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
---
base-commit: 091b06388b117fefdcb63336ac09956a4914b961
change-id: 20261015-vsprintf_kallsym-73d5ed6f800e
Best regards,
Signature · 1 line
Sebastian Andrzej Siewior <[email protected]>