Yang Jihong eb81a2ed4f perf/core: Fix perf_output_begin parameter is incorrectly invoked in perf_event_bpf_output
syzkaller reportes a KASAN issue with stack-out-of-bounds.
The call trace is as follows:
  dump_stack+0x9c/0xd3
  print_address_description.constprop.0+0x19/0x170
  __kasan_report.cold+0x6c/0x84
  kasan_report+0x3a/0x50
  __perf_event_header__init_id+0x34/0x290
  perf_event_header__init_id+0x48/0x60
  perf_output_begin+0x4a4/0x560
  perf_event_bpf_output+0x161/0x1e0
  perf_iterate_sb_cpu+0x29e/0x340
  perf_iterate_sb+0x4c/0xc0
  perf_event_bpf_event+0x194/0x2c0
  __bpf_prog_put.constprop.0+0x55/0xf0
  __cls_bpf_delete_prog+0xea/0x120 [cls_bpf]
  cls_bpf_delete_prog_work+0x1c/0x30 [cls_bpf]
  process_one_work+0x3c2/0x730
  worker_thread+0x93/0x650
  kthread+0x1b8/0x210
  ret_from_fork+0x1f/0x30

commit 267fb27352b6 ("perf: Reduce stack usage of perf_output_begin()")
use on-stack struct perf_sample_data of the caller function.

However, perf_event_bpf_output uses incorrect parameter to convert
small-sized data (struct perf_bpf_event) into large-sized data
(struct perf_sample_data), which causes memory overwriting occurs in
__perf_event_header__init_id.

Fixes: 267fb27352b6 ("perf: Reduce stack usage of perf_output_begin()")
Signed-off-by: Yang Jihong <yangjihong1@huawei.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20230314044735.56551-1-yangjihong1@huawei.com
2023-03-15 21:49:46 +01:00
..
2023-03-06 20:28:00 -08:00
2023-02-21 18:24:12 -08:00
2022-12-02 11:25:00 +01:00
2022-12-21 14:31:52 -08:00
2023-02-23 14:00:10 -08:00
2023-02-21 10:45:51 -08:00
2023-02-23 14:05:08 -08:00
2023-02-23 13:49:45 -08:00
2023-03-03 10:21:39 -08:00
2022-08-29 19:47:03 -04:00
2022-01-11 13:08:21 -08:00
2022-09-26 10:13:13 -07:00
2023-02-21 15:27:48 -08:00
2022-11-15 00:42:02 -08:00
2022-12-23 12:00:24 -08:00
2023-02-02 16:26:06 -08:00
2022-12-19 12:33:32 -06:00
2022-06-29 13:07:16 +02:00
2022-12-27 12:52:10 +01:00
2022-10-10 12:49:34 -07:00
2022-02-25 09:36:06 +01:00
2023-02-21 13:34:07 -08:00
2022-08-06 16:38:17 -07:00