audit: type=1326 audit(1510965124.561:3328): auid=4294967295 uid=0 gid=0 ses=4294967295 subj=kernel pid=32742 comm="syz-executor0" exe="/root/syz-executor0" sig=0 arch=c000003e syscall=16 compat=0 ip=0x452879 code=0x7ffc0000 MPI: mpi too large (32768 bits) ================================================================== BUG: KASAN: use-after-free in mpi_free+0x117/0x150 lib/mpi/mpiutil.c:114 Read of size 4 at addr ffff8801d53e8610 by task syz-executor6/32764 CPU: 1 PID: 32764 Comm: syz-executor6 Not tainted 4.14.0-rc8-mm1+ #21 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __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 mpi_free+0x117/0x150 lib/mpi/mpiutil.c:114 dh_clear_params crypto/dh.c:26 [inline] dh_free_ctx crypto/dh.c:34 [inline] dh_exit_tfm+0x3d/0x140 crypto/dh.c:161 crypto_kpp_exit_tfm+0x52/0x70 crypto/kpp.c:63 crypto_exit_ops crypto/api.c:315 [inline] crypto_destroy_tfm+0xb9/0x2e0 crypto/api.c:579 crypto_free_kpp include/crypto/kpp.h:165 [inline] __keyctl_dh_compute+0x1087/0x1a00 security/keys/dh.c:412 keyctl_dh_compute+0xac/0xf3 security/keys/dh.c:434 SYSC_keyctl security/keys/keyctl.c:1745 [inline] SyS_keyctl+0x72/0x2c0 security/keys/keyctl.c:1641 entry_SYSCALL_64_fastpath+0x1f/0x96 RIP: 0033:0x452879 RSP: 002b:00007fc14b949be8 EFLAGS: 00000212 ORIG_RAX: 00000000000000fa RAX: ffffffffffffffda RBX: 0000000000758020 RCX: 0000000000452879 RDX: 000000002001cf83 RSI: 0000000020ec8000 RDI: 0000000000000017 RBP: 0000000000000086 R08: 0000000020849fc8 R09: 0000000000000000 R10: 0000000000000001 R11: 0000000000000212 R12: 00000000004bd2f8 R13: 00007fc14b949698 R14: 00000000004bd2fb R15: 0000000000000000 Allocated by task 32764: 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:3614 kmalloc include/linux/slab.h:514 [inline] mpi_alloc+0x4b/0x230 lib/mpi/mpiutil.c:34 mpi_read_raw_data+0x1e5/0x440 lib/mpi/mpicoder.c:57 dh_set_params crypto/dh.c:69 [inline] dh_set_secret+0x257/0x600 crypto/dh.c:94 crypto_kpp_set_secret include/crypto/kpp.h:291 [inline] __keyctl_dh_compute+0x9cf/0x1a00 security/keys/dh.c:333 keyctl_dh_compute+0xac/0xf3 security/keys/dh.c:434 SYSC_keyctl security/keys/keyctl.c:1745 [inline] SyS_keyctl+0x72/0x2c0 security/keys/keyctl.c:1641 entry_SYSCALL_64_fastpath+0x1f/0x96 Freed by task 32764: 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:3492 [inline] kfree+0xca/0x250 mm/slab.c:3807 mpi_free+0xcb/0x150 lib/mpi/mpiutil.c:121 dh_set_params crypto/dh.c:75 [inline] dh_set_secret+0x3e5/0x600 crypto/dh.c:94 crypto_kpp_set_secret include/crypto/kpp.h:291 [inline] __keyctl_dh_compute+0x9cf/0x1a00 security/keys/dh.c:333 keyctl_dh_compute+0xac/0xf3 security/keys/dh.c:434 SYSC_keyctl security/keys/keyctl.c:1745 [inline] SyS_keyctl+0x72/0x2c0 security/keys/keyctl.c:1641 entry_SYSCALL_64_fastpath+0x1f/0x96 The buggy address belongs to the object at ffff8801d53e8600 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 16 bytes inside of 32-byte region [ffff8801d53e8600, ffff8801d53e8620) The buggy address belongs to the page: page:ffffea000754fa00 count:1 mapcount:0 mapping:ffff8801d53e8000 index:0xffff8801d53e8fc1 flags: 0x2fffc0000000100(slab) raw: 02fffc0000000100 ffff8801d53e8000 ffff8801d53e8fc1 000000010000003b raw: ffffea000767b1e0 ffffea000760fbe0 ffff8801db0001c0 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8801d53e8500: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc ffff8801d53e8580: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc >ffff8801d53e8600: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc ^ ffff8801d53e8680: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc ffff8801d53e8700: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc ==================================================================