diff options
| author | Tanushree Shah <tshah@linux.ibm.com> | 2026-07-26 00:19:52 +0530 |
|---|---|---|
| committer | Namhyung Kim <namhyung@kernel.org> | 2026-08-07 09:43:36 -0700 |
| commit | c291f143cc495d7d46ca677a3d4f0a17c363e1a6 (patch) | |
| tree | 8b4fd0f417e687156a019747d602086eee16791c /scripts/stackusage | |
| parent | 6c07d49ef3beb87436475e8489e45d46e8579001 (diff) | |
| download | linux-c291f143cc495d7d46ca677a3d4f0a17c363e1a6.tar.gz linux-c291f143cc495d7d46ca677a3d4f0a17c363e1a6.zip | |
perf trace-event: Fix heap overflows in read_ftrace_printk()/read_saved_cmdline()
Both functions read an attacker-controlled size directly from the
input file and pass size + 1 to malloc() before reading size bytes
into the result:
read_ftrace_printk(): size is an unsigned int from read4(). When
size == UINT_MAX, size + 1 overflows to 0, so malloc(0) returns a
minimal allocation while size itself remains UINT_MAX.
read_saved_cmdline(): size is an unsigned long long from read8().
When size == ULLONG_MAX, size + 1 overflows to 0 the same way.
In both cases, do_read(buf, size) then attempts to read the full,
unwrapped size into the tiny allocated buffer, a heap buffer
overflow.
This was previously masked by do_read()'s size parameter being
'int': passing these values truncated them, which the read()
syscall's own boundary checks rejected before any data was read.
Fixing that truncation (widening do_read() to size_t) is correct
on its own, but it removes this accidental protection and exposes
the pre-existing missing bounds check in both functions.
Reject the one value that causes the overflow before it's used, in
each function.
Signed-off-by: Tanushree Shah <tshah@linux.ibm.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'scripts/stackusage')
0 files changed, 0 insertions, 0 deletions
