All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: syzbot <syzbot+30d675e3ca03c1c351e7@syzkaller.appspotmail.com>,
	Masami Hiramatsu <mhiramat@kernel.org>
Cc: bp@suse.de, hpa@zytor.com, linux-kernel@vger.kernel.org,
	mingo@redhat.com, ricardo.neri-calderon@linux.intel.com,
	syzkaller-bugs@googlegroups.com, tglx@linutronix.de,
	x86@kernel.org, yhs@fb.com
Subject: Re: WARNING in arch_uprobe_analyze_insn
Date: Tue, 15 May 2018 15:36:30 +0200	[thread overview]
Message-ID: <20180515133630.GA20619@redhat.com> (raw)
In-Reply-To: <000000000000b759cf056c2b3c12@google.com>

On 05/14, syzbot wrote:
>
> Hello,
>
> syzbot found the following crash on:
>
> HEAD commit:    66e1c94db3cd Merge branch 'x86-pti-for-linus' of git://git..
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=11817107800000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=fcce42b221691ff9
> dashboard link: https://syzkaller.appspot.com/bug?extid=30d675e3ca03c1c351e7
> compiler:       gcc (GCC) 8.0.1 20180413 (experimental)
> syzkaller repro:https://syzkaller.appspot.com/x/repro.syz?x=143d5417800000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=11178e97800000

doesn't work for me...

I guess syscall(__NR_perf_event_open) should trigger perf_uprobe_init() but
the hard-coded attr.type doesn't match perf_uprobe->type on my machine...


Nevermind, it seems that the code is indeed wrong, uprobe_init_insn() does

	insn_init(insn, auprobe->insn, sizeof(auprobe->insn), x86_64);
	/* has the side-effect of processing the entire instruction */
	insn_get_length(insn);
	if (WARN_ON_ONCE(!insn_complete(insn)))
		return -ENOEXEC;

Masami, could your help?

What if insn can't be decoded, say, because it is not valid? Can't
insn_complete() return F in this case?

I think it can... Say, insn_get_immediate() doesn't set immediate.got in
err_out path.

Unfortunately, insn_get_length() returns void, and I do not see any
insn-was-decoded-correctly helper. Perhaps we should simply remove
this WARN_ON() ?

Alternatively, If am right we can move this check down after the "good_insns"
checks, but this doesn't look very clean to me.


> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+30d675e3ca03c1c351e7@syzkaller.appspotmail.com
> 
> random: sshd: uninitialized urandom read (32 bytes read)
> random: sshd: uninitialized urandom read (32 bytes read)
> random: sshd: uninitialized urandom read (32 bytes read)
> random: sshd: uninitialized urandom read (32 bytes read)
> random: sshd: uninitialized urandom read (32 bytes read)
> WARNING: CPU: 0 PID: 4511 at arch/x86/kernel/uprobes.c:296 insn_complete
> arch/x86/include/asm/insn.h:147 [inline]
> WARNING: CPU: 0 PID: 4511 at arch/x86/kernel/uprobes.c:296 uprobe_init_insn
> arch/x86/kernel/uprobes.c:296 [inline]
> WARNING: CPU: 0 PID: 4511 at arch/x86/kernel/uprobes.c:296
> arch_uprobe_analyze_insn+0x13d/0x15f0 arch/x86/kernel/uprobes.c:861
> Kernel panic - not syncing: panic_on_warn set ...
> 
> CPU: 0 PID: 4511 Comm: syz-executor347 Not tainted 4.17.0-rc4+ #46
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> Google 01/01/2011
> Call Trace:
>  __dump_stack lib/dump_stack.c:77 [inline]
>  dump_stack+0x1b9/0x294 lib/dump_stack.c:113
>  panic+0x22f/0x4de kernel/panic.c:184
>  __warn.cold.8+0x163/0x1b3 kernel/panic.c:536
>  report_bug+0x252/0x2d0 lib/bug.c:186
>  fixup_bug arch/x86/kernel/traps.c:178 [inline]
>  do_error_trap+0x1de/0x490 arch/x86/kernel/traps.c:296
>  do_invalid_op+0x1b/0x20 arch/x86/kernel/traps.c:315
>  invalid_op+0x14/0x20 arch/x86/entry/entry_64.S:992
> RIP: 0010:insn_complete arch/x86/include/asm/insn.h:147 [inline]
> RIP: 0010:uprobe_init_insn arch/x86/kernel/uprobes.c:296 [inline]
> RIP: 0010:arch_uprobe_analyze_insn+0x13d/0x15f0
> arch/x86/kernel/uprobes.c:861
> RSP: 0018:ffff8801cf277510 EFLAGS: 00010246
> RAX: 0000000000000000 RBX: ffff8801cf277560 RCX: ffffffff876ccf2a
> RDX: 0000000000000004 RSI: ffffffff876ce6ab RDI: ffff8801cf27759c
> RBP: ffff8801cf277628 R08: ffff8801d8c0a5c0 R09: ffff8801cf277560
> R10: ffff8801d7ad81d0 R11: ffff8801cf2775af R12: 0000000000000000
> R13: dffffc0000000000 R14: ffff8801d7ad8080 R15: ffff8801cf277600
>  prepare_uprobe kernel/events/uprobes.c:610 [inline]
>  install_breakpoint.isra.21+0x710/0x830 kernel/events/uprobes.c:657
>  uprobe_mmap+0x6a0/0xcf0 kernel/events/uprobes.c:1089
>  mmap_region+0x5c8/0x1870 mm/mmap.c:1807
>  do_mmap+0xde2/0x1360 mm/mmap.c:1535
>  do_mmap_pgoff include/linux/mm.h:2237 [inline]
>  vm_mmap_pgoff+0x1fb/0x2a0 mm/util.c:357
>  ksys_mmap_pgoff+0x4c9/0x640 mm/mmap.c:1585
>  __do_sys_mmap arch/x86/kernel/sys_x86_64.c:100 [inline]
>  __se_sys_mmap arch/x86/kernel/sys_x86_64.c:91 [inline]
>  __x64_sys_mmap+0xe9/0x1b0 arch/x86/kernel/sys_x86_64.c:91
>  do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287
>  entry_SYSCALL_64_after_hwframe+0x49/0xbe
> RIP: 0033:0x43ff29
> RSP: 002b:00007ffc922a4898 EFLAGS: 00000212 ORIG_RAX: 0000000000000009
> RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 000000000043ff29
> RDX: 0000000000000000 RSI: 0000000000002000 RDI: 000000002000c000
> RBP: 00000000006ca018 R08: 0000000000000003 R09: 0000000000000000
> R10: 0000000000000012 R11: 0000000000000212 R12: 0000000000401850
> R13: 00000000004018e0 R14: 0000000000000000 R15: 0000000000000000
> Dumping ftrace buffer:
>    (ftrace buffer empty)
> Kernel Offset: disabled
> Rebooting in 86400 seconds..
> 
> 
> ---
> This bug is generated by a bot. It may contain errors.
> See https://goo.gl/tpsmEJ for more information about syzbot.
> syzbot engineers can be reached at syzkaller@googlegroups.com.
> 
> syzbot will keep track of this bug report. See:
> https://goo.gl/tpsmEJ#bug-status-tracking for how to communicate with
> syzbot.
> syzbot can test patches for this bug, for details see:
> https://goo.gl/tpsmEJ#testing-patches

  reply	other threads:[~2018-05-15 13:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-14 14:24 WARNING in arch_uprobe_analyze_insn syzbot
2018-05-15 13:36 ` Oleg Nesterov [this message]
2018-05-15 14:48   ` Masami Hiramatsu
2018-05-15 16:18     ` Oleg Nesterov
2018-05-18 16:27 ` [PATCH] uprobes/x86: remove the wrong WARN_ON() in uprobe_init_insn() Oleg Nesterov
2018-05-18 23:58   ` Masami Hiramatsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180515133630.GA20619@redhat.com \
    --to=oleg@redhat.com \
    --cc=bp@suse.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=ricardo.neri-calderon@linux.intel.com \
    --cc=syzbot+30d675e3ca03c1c351e7@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.