Discussion:
KASAN: use-after-free Read in selinux_netlbl_sk_security_free (2)
syzbot
2017-12-04 18:43:01 UTC
Permalink
Hello,

syzkaller hit 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.

Unfortunately, I don't have any reproducer for this bug yet.


binder: undelivered TRANSACTION_ERROR: 29189
binder: undelivered TRANSACTION_ERROR: 29189
binder: undelivered TRANSACTION_ERROR: 29189
dccp_close: ABORT with 1 bytes unread
==================================================================
BUG: KASAN: use-after-free in netlbl_secattr_destroy
include/net/netlabel.h:377 [inline]
BUG: KASAN: use-after-free in netlbl_secattr_free
include/net/netlabel.h:409 [inline]
BUG: KASAN: use-after-free in selinux_netlbl_sk_security_free+0x28b/0x2f0
security/selinux/netlabel.c:171
Read of size 4 at addr ffff8801cbaa2780 by task swapper/1/0

CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.15.0-rc1+ #205
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Call Trace:
<IRQ>
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x194/0x257 lib/dump_stack.c:53
print_address_description+0x73/0x250 mm/kasan/report.c:252
kasan_report_error mm/kasan/report.c:351 [inline]
kasan_report+0x25b/0x340 mm/kasan/report.c:409
__asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:429
netlbl_secattr_destroy include/net/netlabel.h:377 [inline]
netlbl_secattr_free include/net/netlabel.h:409 [inline]
selinux_netlbl_sk_security_free+0x28b/0x2f0 security/selinux/netlabel.c:171
selinux_sk_free_security+0x47/0x60 security/selinux/hooks.c:4907
security_sk_free+0x48/0x80 security/security.c:1431
sk_prot_free net/core/sock.c:1502 [inline]
__sk_destruct+0x609/0x910 net/core/sock.c:1585
__rcu_reclaim kernel/rcu/rcu.h:195 [inline]
rcu_do_batch kernel/rcu/tree.c:2758 [inline]
invoke_rcu_callbacks kernel/rcu/tree.c:3012 [inline]
__rcu_process_callbacks kernel/rcu/tree.c:2979 [inline]
rcu_process_callbacks+0xd74/0x17d0 kernel/rcu/tree.c:2996
__do_softirq+0x29d/0xbb2 kernel/softirq.c:285
invoke_softirq kernel/softirq.c:365 [inline]
irq_exit+0x1d3/0x210 kernel/softirq.c:405
exiting_irq arch/x86/include/asm/apic.h:540 [inline]
smp_apic_timer_interrupt+0x16b/0x700 arch/x86/kernel/apic/apic.c:1052
apic_timer_interrupt+0x9d/0xb0 arch/x86/entry/entry_64.S:795
</IRQ>
RIP: 0010:native_safe_halt+0x6/0x10 arch/x86/include/asm/irqflags.h:54
RSP: 0018:ffff8801da38fda8 EFLAGS: 00000282 ORIG_RAX: ffffffffffffff11
RAX: dffffc0000000000 RBX: 1ffff1003b471fb8 RCX: 0000000000000000
RDX: 1ffffffff0bd968c RSI: 0000000000000001 RDI: ffffffff85ecb460
RBP: ffff8801da38fda8 R08: ffffffff8163b0f0 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000001
R13: ffff8801da38fe60 R14: ffffffff865ea860 R15: 0000000000000000
arch_safe_halt arch/x86/include/asm/paravirt.h:93 [inline]
default_idle+0xbf/0x460 arch/x86/kernel/process.c:348
arch_cpu_idle+0xa/0x10 arch/x86/kernel/process.c:339
default_idle_call+0x36/0x90 kernel/sched/idle.c:98
cpuidle_idle_call kernel/sched/idle.c:156 [inline]
do_idle+0x24a/0x3b0 kernel/sched/idle.c:246
cpu_startup_entry+0x18/0x20 kernel/sched/idle.c:351
start_secondary+0x2dd/0x3e0 arch/x86/kernel/smpboot.c:277
secondary_startup_64+0xa5/0xb0 arch/x86/kernel/head_64.S:237

Allocated by task 29487:
save_stack+0x43/0xd0 mm/kasan/kasan.c:447
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:551
kmem_cache_alloc_trace+0x136/0x750 mm/slab.c:3613
kmalloc include/linux/slab.h:499 [inline]
allocate_probes kernel/tracepoint.c:65 [inline]
func_add kernel/tracepoint.c:120 [inline]
tracepoint_add_func kernel/tracepoint.c:208 [inline]
tracepoint_probe_register_prio+0x6f9/0x9a0 kernel/tracepoint.c:283
tracepoint_probe_register+0x2a/0x40 kernel/tracepoint.c:304
trace_event_reg+0x167/0x320 kernel/trace/trace_events.c:305
perf_trace_event_reg kernel/trace/trace_event_perf.c:122 [inline]
perf_trace_event_init kernel/trace/trace_event_perf.c:197 [inline]
perf_trace_init+0x4ef/0xab0 kernel/trace/trace_event_perf.c:221
perf_tp_event_init+0x7d/0xf0 kernel/events/core.c:7953
perf_try_init_event+0xc9/0x1f0 kernel/events/core.c:9179
perf_init_event kernel/events/core.c:9217 [inline]
perf_event_alloc+0x1cc6/0x2b00 kernel/events/core.c:9481
SYSC_perf_event_open+0x842/0x2f10 kernel/events/core.c:9936
SyS_perf_event_open+0x39/0x50 kernel/events/core.c:9822
entry_SYSCALL_64_fastpath+0x1f/0x96

Freed by task 29502:
save_stack+0x43/0xd0 mm/kasan/kasan.c:447
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0x71/0xc0 mm/kasan/kasan.c:524
__cache_free mm/slab.c:3491 [inline]
kfree+0xca/0x250 mm/slab.c:3806
rcu_free_old_probes+0x15/0x20 kernel/tracepoint.c:72
__rcu_reclaim kernel/rcu/rcu.h:195 [inline]
rcu_do_batch kernel/rcu/tree.c:2758 [inline]
invoke_rcu_callbacks kernel/rcu/tree.c:3012 [inline]
__rcu_process_callbacks kernel/rcu/tree.c:2979 [inline]
rcu_process_callbacks+0xd74/0x17d0 kernel/rcu/tree.c:2996
__do_softirq+0x29d/0xbb2 kernel/softirq.c:285

The buggy address belongs to the object at ffff8801cbaa2780
which belongs to the cache kmalloc-64 of size 64
The buggy address is located 0 bytes inside of
64-byte region [ffff8801cbaa2780, ffff8801cbaa27c0)
The buggy address belongs to the page:
page:000000005cd87cdd count:1 mapcount:0 mapping:00000000ca9f4b66 index:0x0
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffff8801cbaa2000 0000000000000000 0000000100000020
raw: ffffea0007144820 ffffea0006560ea0 ffff8801db000340 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8801cbaa2680: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff8801cbaa2700: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff8801cbaa2780: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
^
ffff8801cbaa2800: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff8801cbaa2880: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================


---
This bug is generated by a dumb bot. It may contain errors.
See https://goo.gl/tpsmEJ for details.
Direct all questions to ***@googlegroups.com.
Please credit me with: Reported-by: syzbot <***@googlegroups.com>

syzbot will keep track of this bug report.
Once a fix for this bug is committed, please reply to this email with:
#syz fix: exact-commit-title
To mark this as a duplicate of another syzbot report, please reply with:
#syz dup: exact-subject-of-another-report
If it's a one-off invalid bug report, please reply with:
#syz invalid
Note: if the crash happens again, it will cause creation of a new bug
report.
Note: all commands must start from beginning of the line in the email body.
Loading...