aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/scripts/python/sctop.py
diff options
context:
space:
mode:
authorEric Biggers <[email protected]>2020-03-08 02:38:49 +0000
committerGreg Kroah-Hartman <[email protected]>2020-03-24 12:27:16 +0000
commita65cab7d7f05c2061a3e2490257d3086ff3202c6 (patch)
tree897fff31b7feb585234c26ed50745dbc5cba7e69 /tools/perf/scripts/python/sctop.py
parentdriver core: Add device links from fwnode only for the primary device (diff)
downloadkernel-a65cab7d7f05c2061a3e2490257d3086ff3202c6.tar.gz
kernel-a65cab7d7f05c2061a3e2490257d3086ff3202c6.zip
libfs: fix infoleak in simple_attr_read()
Reading from a debugfs file at a nonzero position, without first reading at position 0, leaks uninitialized memory to userspace. It's a bit tricky to do this, since lseek() and pread() aren't allowed on these files, and write() doesn't update the position on them. But writing to them with splice() *does* update the position: #define _GNU_SOURCE 1 #include <fcntl.h> #include <stdio.h> #include <unistd.h> int main() { int pipes[2], fd, n, i; char buf[32]; pipe(pipes); write(pipes[1], "0", 1); fd = open("/sys/kernel/debug/fault_around_bytes", O_RDWR); splice(pipes[0], NULL, fd, NULL, 1, 0); n = read(fd, buf, sizeof(buf)); for (i = 0; i < n; i++) printf("%02x", buf[i]); printf("\n"); } Output: 5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a30 Fix the infoleak by making simple_attr_read() always fill simple_attr::get_buf if it hasn't been filled yet. Reported-by: [email protected] Reported-by: Alexander Potapenko <[email protected]> Fixes: acaefc25d21f ("[PATCH] libfs: add simple attribute files") Cc: [email protected] Signed-off-by: Eric Biggers <[email protected]> Acked-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
Diffstat (limited to 'tools/perf/scripts/python/sctop.py')
0 files changed, 0 insertions, 0 deletions