perf trace-event: Fix overflow, loop and cleanup bugs
Status from this message: Applied to perf-tools-next, thanks!
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest5 patches 1 replyApplied
- v35 patches 5 repliesSuperseded
- v22 patches 3 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 | 1 patch | 1 reply | Superseded |
Changes in v4 from the cover letter
- Fixed a leak in trace_event__init(): repeated calls overwrite t->pevent/t->plugin_list without releasing the existing handle.
- Fixed the same size + 1 overflow in read_saved_cmdline() as read_ftrace_printk() (size == ULLONG_MAX wraps to 0 in malloc()).
- Added <limits.h> for the UINT_MAX/ULLONG_MAX checks.
Patches in v4 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/5 | perf trace-event: Fix buffer overflow in read_string()tools/ | +5 | 0 replies | |
| 2/5 | perf trace-event: Fix integer truncation in do_read() and skip()tools/ | +14 | 0 replies | |
| 3/5 | perf trace-event: Avoid double free and leak in trace_event__cleanup()/trace_event__init()tools/ | +10 | 0 replies | |
| 4/5 | perf trace-event: Fix heap overflows in read_ftrace_printk()/read_saved_cmdline()tools/ | +11 | 0 replies | |
| 5/5 | perf trace-event: Fix infinite loop in skip()tools/ | +8 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.
Cover letter [PATCH v4 0/5] perf trace-event: Fix overflow, loop and cleanup bugs
This series fixes five security issues in trace-event-read.c and trace-event.c:
1. Stack buffer overflow in read_string() when a string exceeds BUFSIZ, due to a missing bounds check.
2. Integer truncation when passing 64-bit sizes into do_read() and skip(), which use 'int' parameters, causing uninitialized memory to be dumped and parsers to read out of bounds.
3. Double free / use-after-free in trace_event__cleanup(): it frees t->pevent but never clears the pointer, so calling it twice on the same trace_event touches already-freed memory. Also fixes a related leak in trace_event__init(), which overwrites t->pevent/t->plugin_list without releasing any existing handle if called more than once on the same struct.
4. Heap buffer overflow in read_ftrace_printk() and read_saved_cmdline(): size + 1 can overflow to 0 in malloc(), allocating a tiny buffer while a huge read is still attempted into it.
5. Infinite loop in skip(): it does not check do_read()'s return value, so a crafted size can spin the loop indefinitely.
Patches 4 and 5 are latent bugs that patch 2's type fix exposes by removing accidental truncation that had been masking them.
Tanushree Shah (5):
perf trace-event: Fix buffer overflow in read_string() perf trace-event: Fix integer truncation in do_read() and skip() perf trace-event: Avoid double free and leak in
trace_event__cleanup()/trace_event__init()
perf trace-event: Fix heap overflows in
read_ftrace_printk()/read_saved_cmdline()
perf trace-event: Fix infinite loop in skip()
tools/perf/util/trace-event-read.c | 54 ++++++++++++++++++++---------- tools/perf/util/trace-event.c | 11 +++++- 2 files changed, 47 insertions(+), 18 deletions(-)
---
Changes in v4:
- Fixed a leak in trace_event__init(): repeated calls overwrite t->pevent/t->plugin_list without releasing the existing handle.
- Fixed the same size + 1 overflow in read_saved_cmdline() as read_ftrace_printk() (size == ULLONG_MAX wraps to 0 in malloc()).
- Added <limits.h> for the UINT_MAX/ULLONG_MAX checks.
Changes in v3:
- Added new patch to fix double free in trace_event__cleanup().
- Added new patch to fix heap buffer overflow in read_ftrace_printk().
- Added new patch to fix infinite loop in skip().
Changes in v2:
- Added new patch to fix integer truncation in do_read() and skip().
- Organized as patch series to separate the two security fixes.
v1: https://lore.kernel.org/linux-perf-users/[email protected]/
Signature · 1 line
2.47.3