lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACT4Y+apAff+hNa=q58=Z2TSh_av-GubQPSgFHc=f0gE0kuGGg@mail.gmail.com>
Date:   Mon, 30 Jan 2017 19:41:59 +0100
From:   Dmitry Vyukov <dvyukov@...gle.com>
To:     Al Viro <viro@...iv.linux.org.uk>,
        Thomas Gleixner <tglx@...utronix.de>,
        "linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>
Cc:     syzkaller <syzkaller@...glegroups.com>
Subject: timerfd: use-after-free in timerfd_remove_cancel

Hello,

The following program triggers use-after-free in timerfd_remove_cancel:
https://gist.githubusercontent.com/dvyukov/202576d437c84ffbbe52e9ccd77e1b44/raw/5562bff8626a73627157331ea2b837f59080ac84/gistfile1.txt

BUG: KASAN: use-after-free in __list_del include/linux/list.h:104
[inline] at addr ffff88006bab1410
BUG: KASAN: use-after-free in __list_del_entry
include/linux/list.h:119 [inline] at addr ffff88006bab1410
BUG: KASAN: use-after-free in list_del_rcu include/linux/rculist.h:129
[inline] at addr ffff88006bab1410
BUG: KASAN: use-after-free in timerfd_remove_cancel fs/timerfd.c:120
[inline] at addr ffff88006bab1410
BUG: KASAN: use-after-free in timerfd_release+0x28e/0x310
fs/timerfd.c:209 at addr ffff88006bab1410
Write of size 8 by task a.out/2897
CPU: 3 PID: 2897 Comm: a.out Not tainted 4.10.0-rc5+ #201
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:15 [inline]
 dump_stack+0x2ee/0x3ef lib/dump_stack.c:51
 kasan_object_err+0x1c/0x70 mm/kasan/report.c:165
 print_address_description mm/kasan/report.c:203 [inline]
 kasan_report_error+0x17b/0x430 mm/kasan/report.c:287
 kasan_report mm/kasan/report.c:307 [inline]
 __asan_report_store8_noabort+0x3e/0x40 mm/kasan/report.c:333
 __list_del include/linux/list.h:104 [inline]
 __list_del_entry include/linux/list.h:119 [inline]
 list_del_rcu include/linux/rculist.h:129 [inline]
 timerfd_remove_cancel fs/timerfd.c:120 [inline]
 timerfd_release+0x28e/0x310 fs/timerfd.c:209
 __fput+0x332/0x7f0 fs/file_table.c:208
 ____fput+0x15/0x20 fs/file_table.c:244
 task_work_run+0x18a/0x260 kernel/task_work.c:116
 tracehook_notify_resume include/linux/tracehook.h:191 [inline]
 exit_to_usermode_loop+0x23b/0x2a0 arch/x86/entry/common.c:160
 prepare_exit_to_usermode arch/x86/entry/common.c:190 [inline]
 syscall_return_slowpath+0x4d3/0x570 arch/x86/entry/common.c:259
 entry_SYSCALL_64_fastpath+0xc0/0xc2
RIP: 0033:0x4054e1
RSP: 002b:00007f46e349fd60 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 00000000004054e1
RDX: 0000000000000000 RSI: 0000000000801000 RDI: 0000000000000004
RBP: 00007f46e349fdd0 R08: 0000000000000000 R09: 00007f46a3fe7700
R10: 00007f46a3fe79d0 R11: 0000000000000293 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f46e34a09c0 R15: 00007f46e34a0700
Object at ffff88006bab1300, in cache kmalloc-512 size: 512
Allocated:
PID = 2899
[<ffffffff812b1506>] save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
[<ffffffff81a0cdd3>] save_stack+0x43/0xd0 mm/kasan/kasan.c:502
[<ffffffff81a0d09a>] set_track mm/kasan/kasan.c:514 [inline]
[<ffffffff81a0d09a>] kasan_kmalloc+0xaa/0xd0 mm/kasan/kasan.c:605
[<ffffffff81a098eb>] kmem_cache_alloc_trace+0x10b/0x670 mm/slab.c:3629
[<ffffffff81b8ab2f>] kmalloc include/linux/slab.h:490 [inline]
[<ffffffff81b8ab2f>] kzalloc include/linux/slab.h:636 [inline]
[<ffffffff81b8ab2f>] SYSC_timerfd_create fs/timerfd.c:398 [inline]
[<ffffffff81b8ab2f>] SyS_timerfd_create+0x1df/0x2d0 fs/timerfd.c:376
[<ffffffff841c9c81>] entry_SYSCALL_64_fastpath+0x1f/0xc2
Freed:
PID = 0
[<ffffffff812b1506>] save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
[<ffffffff81a0cdd3>] save_stack+0x43/0xd0 mm/kasan/kasan.c:502
[<ffffffff81a0d70f>] set_track mm/kasan/kasan.c:514 [inline]
[<ffffffff81a0d70f>] kasan_slab_free+0x6f/0xb0 mm/kasan/kasan.c:578
[<ffffffff81a0b5c3>] __cache_free mm/slab.c:3505 [inline]
[<ffffffff81a0b5c3>] kfree+0xd3/0x250 mm/slab.c:3822
[<ffffffff81608502>] __rcu_reclaim kernel/rcu/rcu.h:113 [inline]
[<ffffffff81608502>] rcu_do_batch.isra.70+0x8c2/0xdf0 kernel/rcu/tree.c:2780
[<ffffffff81608ea2>] invoke_rcu_callbacks kernel/rcu/tree.c:3043 [inline]
[<ffffffff81608ea2>] __rcu_process_callbacks kernel/rcu/tree.c:3010 [inline]
[<ffffffff81608ea2>] rcu_process_callbacks+0x472/0xc70 kernel/rcu/tree.c:3027
[<ffffffff841ccfbf>] __do_softirq+0x31f/0xbe7 kernel/softirq.c:284
Memory state around the buggy address:
 ffff88006bab1300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88006bab1380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88006bab1400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                         ^
 ffff88006bab1480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88006bab1500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Seems that ctx->might_cancel is racy.

On commit fd694aaa46c7ed811b72eb47d5eb11ce7ab3f7f1.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ