All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers3@gmail.com>
To: syzbot
	<bot+f7b85b77fd8042059586165494cd708475e87fc3@syzkaller.appspotmail.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	syzkaller-bugs@googlegroups.com, viro@zeniv.linux.org.uk,
	tglx@linutronix.de
Subject: Re: general protection fault in string
Date: Mon, 11 Dec 2017 15:03:05 -0800	[thread overview]
Message-ID: <20171211230305.GA48753@gmail.com> (raw)
In-Reply-To: <001a1143fb3e24a4e4055f689d15@google.com>

[+Cc tglx@linutronix.de ]

On Sat, Dec 02, 2017 at 09:10:01PM -0800, syzbot wrote:
> syzkaller has found reproducer for the following crash on
> 2db767d9889cef087149a5eaa35c1497671fa40f
> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/master
> compiler: gcc (GCC) 7.1.1 20170620
> .config is attached
> Raw console output is attached.
> C reproducer is attached
> syzkaller reproducer is attached. See https://goo.gl/kgGztJ
> for information about syzkaller reproducers
> 
> 
> kasan: CONFIG_KASAN_INLINE enabled
> kasan: GPF could be caused by NULL-ptr deref or user memory access
> general protection fault: 0000 [#1] SMP KASAN
> Dumping ftrace buffer:
>    (ftrace buffer empty)
> Modules linked in:
> CPU: 0 PID: 3075 Comm: syzkaller531375 Not tainted 4.15.0-rc1+ #205
> Hardware name: Google Google Compute Engine/Google Compute Engine,
> BIOS Google 01/01/2011
> task: 00000000523f1e90 task.stack: 00000000c2d38485
> RIP: 0010:string+0xb4/0x200 lib/vsprintf.c:595
> RSP: 0018:ffff8801cc637868 EFLAGS: 00010006
> RAX: dffffc0000000000 RBX: fffffffffffffffe RCX: ffffffff85135fbf
> RDX: 06c7240eabebe406 RSI: 1ffff100398c6f01 RDI: ffff8801cc637888
> RBP: ffff8801cc6378b8 R08: ffffed00398a5566 R09: ffffed00398a5566
> R10: 0000000000000002 R11: ffffed00398a5565 R12: 363920755f5f2034
> R13: 363920755f5f2033 R14: ffffffffffffffff R15: ffff8801cc52ab2a
> FS:  0000000001a75880(0000) GS:ffff8801db400000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00000000205e2ff0 CR3: 00000001cc470000 CR4: 00000000001406f0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> Call Trace:
>  vsnprintf+0x863/0x1900 lib/vsprintf.c:2282
>  seq_vprintf+0xe3/0x1a0 fs/seq_file.c:397
>  seq_printf+0xb3/0xe0 fs/seq_file.c:412
>  show_timer+0x1ee/0x2b0 fs/proc/base.c:2274
>  seq_read+0x385/0x13d0 fs/seq_file.c:234
>  do_loop_readv_writev fs/read_write.c:673 [inline]
>  do_iter_read+0x3db/0x5b0 fs/read_write.c:897
>  vfs_readv+0x121/0x1c0 fs/read_write.c:959
>  do_preadv+0x11b/0x1a0 fs/read_write.c:1043
>  SYSC_preadv fs/read_write.c:1093 [inline]
>  SyS_preadv+0x30/0x40 fs/read_write.c:1088
>  entry_SYSCALL_64_fastpath+0x1f/0x96
> RIP: 0033:0x440149
> RSP: 002b:00007fff96d72b08 EFLAGS: 00000213 ORIG_RAX: 0000000000000127
> RAX: ffffffffffffffda RBX: 00007fff96d72b10 RCX: 0000000000440149
> RDX: 0000000000000001 RSI: 00000000205e2ff0 RDI: 0000000000000003
> RBP: 0000000000000000 R08: 0000000000000011 R09: 65732f636f72702f
> R10: 0000000000000000 R11: 0000000000000213 R12: 0000000000401a10
> R13: 0000000000401aa0 R14: 0000000000000000 R15: 0000000000000000
> Code: 01 00 00 e8 7f 98 5c fc 4d 85 f6 0f 84 10 01 00 00 e8 71 98 5c
> fc 4c 89 ea 48 b8 00 00 00 00 00 fc ff df 4d 8d 65 01 48 c1 ea 03
> <0f> b6 04 02 4c 89 ea 83 e2 07 38 d0 7f 08 84 c0 0f 85 ec 00 00
> RIP: string+0xb4/0x200 lib/vsprintf.c:595 RSP: ffff8801cc637868
> ---[ end trace 3570c98033660e3f ]---

The bug is that sys_timer_create() allows setting ->it_sigev_notify to almost
any value, but show_timer() assumes that it has one of a specific set of values.
Here's a simplified reproducer:

	#include <fcntl.h>
	#include <signal.h>
	#include <time.h>
	#include <unistd.h>

	int main()
	{
		struct sigevent e = {
			.sigev_signo = 0x1c,
			.sigev_notify = 0x100000,
		};
		timer_t t;
		int fd;
		char buf[64];

		timer_create(CLOCK_MONOTONIC, &e, &t);

		fd = open("/proc/self/timers", O_RDONLY);

		read(fd, buf, sizeof(buf));
	}

I wonder if anything would break if we made sys_timer_create() return -EINVAL
for unrecognized values of sigev_notify?  That's what it *should* do, but it
seems to be the classic "unchecked flags" bug, yet again...

Eric

  reply	other threads:[~2017-12-11 23:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <001a1143e6ccdb8581055f499952@google.com>
2017-12-03  5:10 ` general protection fault in string syzbot
2017-12-11 23:03   ` Eric Biggers [this message]
2017-12-11 23:11     ` Eric Biggers
2017-12-12 17:11     ` Thomas Gleixner
2017-12-12 17:58       ` Eric Biggers

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=20171211230305.GA48753@gmail.com \
    --to=ebiggers3@gmail.com \
    --cc=bot+f7b85b77fd8042059586165494cd708475e87fc3@syzkaller.appspotmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    /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.