• Masami Hiramatsu's avatar
    perf/core: Fix perf_kprobe_init() · 5da13ab8
    Masami Hiramatsu authored
    Fix error handling in perf_kprobe_init():
    
    	==================================================================
    	BUG: KASAN: slab-out-of-bounds in strlen+0x8e/0xa0 lib/string.c:482
    	Read of size 1 at addr ffff88003f9cc5c0 by task syz-executor2/23095
    
    	CPU: 0 PID: 23095 Comm: syz-executor2 Not tainted 4.16.0+ #24
    	Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
    	Call Trace:
    	 __dump_stack lib/dump_stack.c:77 [inline]
    	 dump_stack+0xca/0x13e lib/dump_stack.c:113
    	 print_address_description+0x6e/0x2c0 mm/kasan/report.c:256
    	 kasan_report_error mm/kasan/report.c:354 [inline]
    	 kasan_report+0x256/0x380 mm/kasan/report.c:412
    	 strlen+0x8e/0xa0 lib/string.c:482
    	 kstrdup+0x21/0x70 mm/util.c:55
    	 alloc_trace_kprobe+0xc8/0x930 kernel/trace/trace_kprobe.c:325
    	 create_local_trace_kprobe+0x4f/0x3a0 kernel/trace/trace_kprobe.c:1438
    	 perf_kprobe_init+0x149/0x1f0 kernel/trace/trace_event_perf.c:264
    	 perf_kprobe_event_init+0xa8/0x120 kernel/events/core.c:8407
    	 perf_try_init_event+0xcb/0x2a0 kernel/events/core.c:9719
    	 perf_init_event kernel/events/core.c:9750 [inline]
    	 perf_event_alloc+0x1367/0x1e20 kernel/events/core.c:10022
    	 SYSC_perf_event_open+0x242/0x2330 kernel/events/core.c:10477
    	 do_syscall_64+0x198/0x640 arch/x86/entry/common.c:287
    	 entry_SYSCALL_64_after_hwframe+0x42/0xb7
    Reported-by: default avatar范龙飞 <long7573@126.com>
    Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Song Liu <songliubraving@fb.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Fixes: e12f03d7 ("perf/core: Implement the 'perf_kprobe' PMU")
    Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    5da13ab8
trace_event_perf.c 11.8 KB