memory leak in mpihelp_mul_karatsuba_case

From: syzbot
Date: Mon Jun 24 2019 - 03:27:24 EST


Hello,

syzbot found the following crash on:

HEAD commit: abf02e29 Merge tag 'pm-5.2-rc6' of git://git.kernel.org/pu..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=17a8bfeaa00000
kernel config: https://syzkaller.appspot.com/x/.config?x=56f1da14935c3cce
dashboard link: https://syzkaller.appspot.com/bug?extid=f7baccc38dcc1e094e77
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=171aa7e6a00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=153306cea00000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+f7baccc38dcc1e094e77@xxxxxxxxxxxxxxxxxxxxxxxxx

ffffffffda RBX: 0000000000000000 RCX: 0000000000441ac9
BUG: memory leak
unreferenced object 0xffff88811f4da200 (size 512):
comm "syz-executor301", pid 7045, jiffies 4294955450 (age 7.850s)
hex dump (first 32 bytes):
ad dc f4 43 66 b0 1a 88 8f 0c 17 d5 86 34 3a 85 ...Cf........4:.
e3 63 c8 bf 2e 3b f5 0d 1c ab 63 30 15 fe a1 e9 .c...;....c0....
backtrace:
[<00000000d5589961>] kmemleak_alloc_recursive include/linux/kmemleak.h:43 [inline]
[<00000000d5589961>] slab_post_alloc_hook mm/slab.h:439 [inline]
[<00000000d5589961>] slab_alloc mm/slab.c:3326 [inline]
[<00000000d5589961>] __do_kmalloc mm/slab.c:3658 [inline]
[<00000000d5589961>] __kmalloc+0x161/0x2c0 mm/slab.c:3669
[<00000000022eaa00>] kmalloc include/linux/slab.h:552 [inline]
[<00000000022eaa00>] mpi_alloc_limb_space+0x29/0x50 lib/mpi/mpiutil.c:64
[<00000000d637c699>] mpihelp_mul_karatsuba_case+0x67/0x460 lib/mpi/mpih-mul.c:331
[<00000000401dc6f9>] mpi_powm+0x7b0/0xdd0 lib/mpi/mpi-pow.c:225
[<00000000be8dcb84>] _compute_val crypto/dh.c:39 [inline]
[<00000000be8dcb84>] dh_compute_value+0x160/0x220 crypto/dh.c:178
[<00000000471846ad>] crypto_kpp_generate_public_key include/crypto/kpp.h:315 [inline]
[<00000000471846ad>] __keyctl_dh_compute+0x447/0x970 security/keys/dh.c:367
[<000000002f6d650d>] keyctl_dh_compute+0x67/0xa6 security/keys/dh.c:422
[<00000000b798bc7f>] __do_sys_keyctl security/keys/keyctl.c:1737 [inline]
[<00000000b798bc7f>] __se_sys_keyctl security/keys/keyctl.c:1633 [inline]
[<00000000b798bc7f>] __x64_sys_keyctl+0xa5/0x330 security/keys/keyctl.c:1633
[<000000007a6f9515>] do_syscall_64+0x76/0x1a0 arch/x86/entry/common.c:301
[<00000000057f2768>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

BUG: memory leak
unreferenced object 0xffff88811f4dac00 (size 512):
comm "syz-executor301", pid 7045, jiffies 4294955450 (age 7.850s)
hex dump (first 32 bytes):
62 72 c4 ae ac af a3 ba e5 24 da a5 30 5e cb c4 br.......$..0^..
a6 46 44 39 76 2e 42 f6 85 6a 5b ad ae 97 4e 83 .FD9v.B..j[...N.
backtrace:
[<00000000d5589961>] kmemleak_alloc_recursive include/linux/kmemleak.h:43 [inline]
[<00000000d5589961>] slab_post_alloc_hook mm/slab.h:439 [inline]
[<00000000d5589961>] slab_alloc mm/slab.c:3326 [inline]
[<00000000d5589961>] __do_kmalloc mm/slab.c:3658 [inline]
[<00000000d5589961>] __kmalloc+0x161/0x2c0 mm/slab.c:3669
[<00000000022eaa00>] kmalloc include/linux/slab.h:552 [inline]
[<00000000022eaa00>] mpi_alloc_limb_space+0x29/0x50 lib/mpi/mpiutil.c:64
[<0000000025804541>] mpihelp_mul_karatsuba_case+0x394/0x460 lib/mpi/mpih-mul.c:346
[<00000000401dc6f9>] mpi_powm+0x7b0/0xdd0 lib/mpi/mpi-pow.c:225
[<00000000be8dcb84>] _compute_val crypto/dh.c:39 [inline]
[<00000000be8dcb84>] dh_compute_value+0x160/0x220 crypto/dh.c:178
[<00000000471846ad>] crypto_kpp_generate_public_key include/crypto/kpp.h:315 [inline]
[<00000000471846ad>] __keyctl_dh_compute+0x447/0x970 security/keys/dh.c:367
[<000000002f6d650d>] keyctl_dh_compute+0x67/0xa6 security/keys/dh.c:422
[<00000000b798bc7f>] __do_sys_keyctl security/keys/keyctl.c:1737 [inline]
[<00000000b798bc7f>] __se_sys_keyctl security/keys/keyctl.c:1633 [inline]
[<00000000b798bc7f>] __x64_sys_keyctl+0xa5/0x330 security/keys/keyctl.c:1633
[<000000007a6f9515>] do_syscall_64+0x76/0x1a0 arch/x86/entry/common.c:301
[<00000000057f2768>] entry_SYSCALL_64_after_hwframe+0x44/0xa9



---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@xxxxxxxxxxxxxxxxx

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches