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]
Date:   Wed, 12 Apr 2017 17:02:15 +0200
From:   Andrey Konovalov <andreyknvl@...gle.com>
To:     Steffen Klassert <steffen.klassert@...unet.com>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        "David S. Miller" <davem@...emloft.net>,
        netdev <netdev@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>
Cc:     Dmitry Vyukov <dvyukov@...gle.com>,
        Kostya Serebryany <kcc@...gle.com>,
        syzkaller <syzkaller@...glegroups.com>,
        Eric Dumazet <edumazet@...gle.com>
Subject: ney/key: slab-out-of-bounds in parse_ipsecrequests

Hi,

I've got the following error report while fuzzing the kernel with syzkaller.

On commit 39da7c509acff13fc8cb12ec1bb20337c988ed36 (4.11-rc6).

A reproducer and .config are attached.

When subtracting rq->sadb_x_ipsecrequest_len from len it can become
negative and the while loop condition remains true.

==================================================================
BUG: KASAN: slab-out-of-bounds in parse_ipsecrequest
net/key/af_key.c:1897 [inline] at addr ffff88006b1e3d0b
BUG: KASAN: slab-out-of-bounds in parse_ipsecrequests+0xc89/0xdc0
net/key/af_key.c:1949 at addr ffff88006b1e3d0b
Read of size 1 by task syz-executor5/11796
CPU: 2 PID: 11796 Comm: syz-executor5 Not tainted 4.11.0-rc6+ #211
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:16 [inline]
 dump_stack+0x292/0x398 lib/dump_stack.c:52
 kasan_object_err+0x1c/0x70 mm/kasan/report.c:164
 print_address_description mm/kasan/report.c:202 [inline]
 kasan_report_error mm/kasan/report.c:291 [inline]
 kasan_report+0x252/0x510 mm/kasan/report.c:347
 __asan_report_load1_noabort+0x14/0x20 mm/kasan/report.c:365
 parse_ipsecrequest net/key/af_key.c:1897 [inline]
 parse_ipsecrequests+0xc89/0xdc0 net/key/af_key.c:1949
 pfkey_compile_policy+0xa20/0xd40 net/key/af_key.c:3241
 xfrm_user_policy+0x34c/0x560 net/xfrm/xfrm_state.c:1892
 do_ip_setsockopt.isra.12+0x1afa/0x36c0 net/ipv4/ip_sockglue.c:1175
 ip_setsockopt+0x3a/0xb0 net/ipv4/ip_sockglue.c:1264
 tcp_setsockopt+0x82/0xd0 net/ipv4/tcp.c:2731
 sock_common_setsockopt+0x95/0xd0 net/core/sock.c:2750
 SYSC_setsockopt net/socket.c:1798 [inline]
 SyS_setsockopt+0x270/0x3a0 net/socket.c:1777
 entry_SYSCALL_64_fastpath+0x1f/0xc2
RIP: 0033:0x4458d9
RSP: 002b:00007f319fffdb58 EFLAGS: 00000292 ORIG_RAX: 0000000000000036
RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 00000000004458d9
RDX: 0000000000000010 RSI: 0000000000000000 RDI: 0000000000000005
RBP: 00000000006e3560 R08: 00000000000000e8 R09: 0000000000000000
R10: 0000000020002000 R11: 0000000000000292 R12: 0000000000708000
R13: 0000000000000000 R14: 00007f319fffe9c0 R15: 00007f319fffe700
Object at ffff88006b1e3b28, in cache kernfs_node_cache size: 152
Allocated:
PID = 1
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
 save_stack+0x43/0xd0 mm/kasan/kasan.c:513
 set_track mm/kasan/kasan.c:525 [inline]
 kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:616
 kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:555
 slab_post_alloc_hook mm/slab.h:456 [inline]
 slab_alloc_node mm/slub.c:2718 [inline]
 slab_alloc mm/slub.c:2726 [inline]
 kmem_cache_alloc+0x1af/0x250 mm/slub.c:2731
 kmem_cache_zalloc include/linux/slab.h:653 [inline]
 __kernfs_new_node+0xd1/0x3e0 fs/kernfs/dir.c:629
 kernfs_new_node+0x80/0xe0 fs/kernfs/dir.c:661
 __kernfs_create_file+0x4b/0x320 fs/kernfs/file.c:989
 sysfs_add_file_mode_ns+0x220/0x520 fs/sysfs/file.c:307
 create_files fs/sysfs/group.c:64 [inline]
 internal_create_group+0x239/0x8f0 fs/sysfs/group.c:134
 sysfs_create_group+0x1f/0x30 fs/sysfs/group.c:156
 sysfs_slab_add+0x1d0/0x200 mm/slub.c:5659
 __kmem_cache_create+0x428/0x4c0 mm/slub.c:4253
 create_cache mm/slab_common.c:382 [inline]
 kmem_cache_create+0x15d/0x240 mm/slab_common.c:467
 jbd2_journal_init_revoke_caches+0x8a/0xaf fs/jbd2/revoke.c:206
 journal_init_caches fs/jbd2/journal.c:2631 [inline]
 journal_init+0xf/0x14d fs/jbd2/journal.c:2656
 do_one_initcall+0xf3/0x390 init/main.c:792
 do_initcall_level init/main.c:858 [inline]
 do_initcalls init/main.c:866 [inline]
 do_basic_setup init/main.c:884 [inline]
 kernel_init_freeable+0x5d1/0x6a6 init/main.c:1035
 kernel_init+0x13/0x180 init/main.c:959
 ret_from_fork+0x31/0x40 arch/x86/entry/entry_64.S:430
Freed:
PID = 0
(stack is not available)
Memory state around the buggy address:
 ffff88006b1e3c00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88006b1e3c80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88006b1e3d00: fc fc fc 00 00 00 00 00 00 00 00 00 00 00 00 00
                      ^
 ffff88006b1e3d80: 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc
 ffff88006b1e3e00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

View attachment "net-key-ipsecrq-oob-poc.c" of type "text/x-csrc" (14656 bytes)

Download attachment ".config" of type "application/octet-stream" (127239 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ