From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756255AbeAST3P (ORCPT ); Fri, 19 Jan 2018 14:29:15 -0500 Received: from outprodmail02.cc.columbia.edu ([128.59.72.51]:43338 "EHLO outprodmail02.cc.columbia.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756019AbeAST3G (ORCPT ); Fri, 19 Jan 2018 14:29:06 -0500 X-Google-Smtp-Source: ACJfBotkQ/drzmmMhpL6wap0bZTJDWRUu3wrQqyAnZ+V7vyJ0W2OgI1GVrDtO+wSQwzXJoygk3LfxiM60eRyD4vduqc= MIME-Version: 1.0 From: Shankara Pailoor Date: Fri, 19 Jan 2018 11:29:00 -0800 Message-ID: Subject: Possible Memory Leak in KCOV Linux 4.15-rc1 To: Dmitry Vyukov Cc: LKML , syzkaller Content-Type: text/plain; charset="UTF-8" X-No-Spam-Score: Local Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dmitry, I added support for kcov in strace and I have been tracing a fairly large program but after a little while, I notice that when I mmap a new cover buffer, the call fails with ENOMEM. After killing the program, I try and rerun and I notice that there is nearly no memory on the system. When I do a kmemleak scan I get the following reports: I believe the problem occurs when I try and setup the kcov buffer again after an exec. Instead of reusing the old file descriptor I open kcov again within that process. In that case, I don't know what happens to the old kcov struct. I don't see a maintainers list for kcov so I decided to email you directly. Let me know what more information I can provide. unreferenced object 0xffff8800633f6378 (size 96): comm "runltp", pid 1847, jiffies 4294957922 (age 190.320s) hex dump (first 32 bytes): 01 00 00 00 00 00 00 00 00 00 00 00 ad 4e ad de .............N.. ff ff ff ff 00 00 00 00 ff ff ff ff ff ff ff ff ................ backtrace: [] kmem_cache_alloc_trace+0x146/0x2e0 [] kcov_open+0x25/0x80 [] open_proxy_open+0x1e4/0x2b0 [] do_dentry_open+0x682/0xd70 [] vfs_open+0x107/0x230 [] path_openat+0x1157/0x3520 [] do_filp_open+0x25b/0x3b0 [] do_sys_open+0x4fc/0x6c0 [] SyS_open+0x2d/0x40 [] do_syscall_64+0x23b/0x820 [] return_from_SYSCALL_64+0x0/0x75 [] 0xffffffffffffffff unreferenced object 0xffffc90008679000 (size 134217728): comm "runltp", pid 1847, jiffies 4294957981 (age 190.261s) hex dump (first 32 bytes): e0 d2 46 00 00 00 00 00 22 05 73 81 ff ff ff ff ..F.....".s..... 47 16 73 81 ff ff ff ff 11 16 73 81 ff ff ff ff G.s.......s..... backtrace: [] __vmalloc_node_range+0x387/0x6a0 [] vmalloc_user+0x6c/0x140 [] kcov_mmap+0x2e/0x170 [] mmap_region+0xa9c/0x15a0 [] do_mmap+0x6c6/0xe10 [] vm_mmap_pgoff+0x1de/0x270 [] SyS_mmap_pgoff+0x469/0x610 [] SyS_mmap+0x16/0x20 [] do_syscall_64+0x23b/0x820 [] return_from_SYSCALL_64+0x0/0x75 [] 0xffffffffffffffff unreferenced object 0xffff8800633f6a58 (size 96): comm "runltp", pid 1848, jiffies 4294958935 (age 189.307s) hex dump (first 32 bytes): 01 00 00 00 00 00 00 00 00 00 00 00 ad 4e ad de .............N.. ff ff ff ff 00 00 00 00 ff ff ff ff ff ff ff ff ................ backtrace: [] kmem_cache_alloc_trace+0x146/0x2e0 [] kcov_open+0x25/0x80 [] open_proxy_open+0x1e4/0x2b0 [] do_dentry_open+0x682/0xd70 [] vfs_open+0x107/0x230 [] path_openat+0x1157/0x3520 [] do_filp_open+0x25b/0x3b0 [] do_sys_open+0x4fc/0x6c0 [] SyS_open+0x2d/0x40 [] do_syscall_64+0x23b/0x820 [] return_from_SYSCALL_64+0x0/0x75 [] 0xffffffffffffffff unreferenced object 0xffffc9001067a000 (size 134217728): comm "runltp", pid 1848, jiffies 4294958994 (age 189.248s) hex dump (first 32 bytes): 76 db 46 00 00 00 00 00 22 05 73 81 ff ff ff ff v.F.....".s..... 47 16 73 81 ff ff ff ff 11 16 73 81 ff ff ff ff G.s.......s..... backtrace: [] __vmalloc_node_range+0x387/0x6a0 [] vmalloc_user+0x6c/0x140 [] kcov_mmap+0x2e/0x170 [] mmap_region+0xa9c/0x15a0 [] do_mmap+0x6c6/0xe10 [] vm_mmap_pgoff+0x1de/0x270 [] SyS_mmap_pgoff+0x469/0x610 [] SyS_mmap+0x16/0x20 [] do_syscall_64+0x23b/0x820 [] return_from_SYSCALL_64+0x0/0x75 [] 0xffffffffffffffff unreferenced object 0xffff88006516c6e8 (size 96): comm "runltp", pid 1849, jiffies 4294960010 (age 188.242s) hex dump (first 32 bytes): 01 00 00 00 00 00 00 00 00 00 00 00 ad 4e ad de .............N.. ff ff ff ff 00 00 00 00 ff ff ff ff ff ff ff ff ................ backtrace: [] kmem_cache_alloc_trace+0x146/0x2e0 [] kcov_open+0x25/0x80 [] open_proxy_open+0x1e4/0x2b0 [] do_dentry_open+0x682/0xd70 [] vfs_open+0x107/0x230 [] path_openat+0x1157/0x3520 [] do_filp_open+0x25b/0x3b0 [] do_sys_open+0x4fc/0x6c0 [] SyS_open+0x2d/0x40 [] do_syscall_64+0x23b/0x820 [] return_from_SYSCALL_64+0x0/0x75 [] 0xffffffffffffffff unreferenced object 0xffffc9001867b000 (size 134217728): comm "runltp", pid 1849, jiffies 4294960071 (age 188.181s) hex dump (first 32 bytes): 5d ee 46 00 00 00 00 00 22 05 73 81 ff ff ff ff ].F.....".s..... 47 16 73 81 ff ff ff ff 11 16 73 81 ff ff ff ff G.s.......s..... backtrace: [] __vmalloc_node_range+0x387/0x6a0 [] vmalloc_user+0x6c/0x140 [] kcov_mmap+0x2e/0x170 [] mmap_region+0xa9c/0x15a0 [] do_mmap+0x6c6/0xe10 [] vm_mmap_pgoff+0x1de/0x270 [] SyS_mmap_pgoff+0x469/0x610 [] SyS_mmap+0x16/0x20 [] do_syscall_64+0x23b/0x820 [] return_from_SYSCALL_64+0x0/0x75 [] 0xffffffffffffffff unreferenced object 0xffff88003ed519d0 (size 96): comm "runltp", pid 1850, jiffies 4294961128 (age 187.124s) hex dump (first 32 bytes): 01 00 00 00 00 00 00 00 00 00 00 00 ad 4e ad de .............N.. ff ff ff ff 00 00 00 00 ff ff ff ff ff ff ff ff ................ backtrace: [] kmem_cache_alloc_trace+0x146/0x2e0 [] kcov_open+0x25/0x80 [] open_proxy_open+0x1e4/0x2b0 [] do_dentry_open+0x682/0xd70 [] vfs_open+0x107/0x230 [] path_openat+0x1157/0x3520 [] do_filp_open+0x25b/0x3b0 [] do_sys_open+0x4fc/0x6c0 [] SyS_open+0x2d/0x40 [] do_syscall_64+0x23b/0x820 [] return_from_SYSCALL_64+0x0/0x75 [] 0xffffffffffffffff unreferenced object 0xffffc900206bd000 (size 134217728): comm "runltp", pid 1850, jiffies 4294961186 (age 187.066s) hex dump (first 32 bytes): b8 e3 46 00 00 00 00 00 22 05 73 81 ff ff ff ff ..F.....".s..... 47 16 73 81 ff ff ff ff 11 16 73 81 ff ff ff ff G.s.......s..... backtrace: [] __vmalloc_node_range+0x387/0x6a0 [] vmalloc_user+0x6c/0x140 [] kcov_mmap+0x2e/0x170 [] mmap_region+0xa9c/0x15a0 [] do_mmap+0x6c6/0xe10 [] vm_mmap_pgoff+0x1de/0x270 [] SyS_mmap_pgoff+0x469/0x610 [] SyS_mmap+0x16/0x20 [] do_syscall_64+0x23b/0x820 [] return_from_SYSCALL_64+0x0/0x75 [] 0xffffffffffffffff unreferenced object 0xffff88003ed50c10 (size 96): comm "runltp", pid 1851, jiffies 4294962256 (age 186.004s) hex dump (first 32 bytes): 01 00 00 00 00 00 00 00 00 00 00 00 ad 4e ad de .............N.. ff ff ff ff 00 00 00 00 ff ff ff ff ff ff ff ff ................ backtrace: [] kmem_cache_alloc_trace+0x146/0x2e0 [] kcov_open+0x25/0x80 [] open_proxy_open+0x1e4/0x2b0 [] do_dentry_open+0x682/0xd70 [] vfs_open+0x107/0x230 [] path_openat+0x1157/0x3520 [] do_filp_open+0x25b/0x3b0 [] do_sys_open+0x4fc/0x6c0 [] SyS_open+0x2d/0x40 [] do_syscall_64+0x23b/0x820 [] return_from_SYSCALL_64+0x0/0x75 [] 0xffffffffffffffff unreferenced object 0xffffc900286ff000 (size 134217728): comm "runltp", pid 1851, jiffies 4294962315 (age 185.946s) hex dump (first 32 bytes): 15 af 46 00 00 00 00 00 22 05 73 81 ff ff ff ff ..F.....".s..... 47 16 73 81 ff ff ff ff 11 16 73 81 ff ff ff ff G.s.......s..... backtrace: [] __vmalloc_node_range+0x387/0x6a0 [] vmalloc_user+0x6c/0x140 [] kcov_mmap+0x2e/0x170 [] mmap_region+0xa9c/0x15a0 [] do_mmap+0x6c6/0xe10 [] vm_mmap_pgoff+0x1de/0x270 [] SyS_mmap_pgoff+0x469/0x610 [] SyS_mmap+0x16/0x20 [] do_syscall_64+0x23b/0x820 [] return_from_SYSCALL_64+0x0/0x75 [] 0xffffffffffffffff root@syzkaller:~# cat /sys/kernel/debug/kmemleak unreferenced object 0xffff8800633f6378 (size 96): comm "runltp", pid 1847, jiffies 4294957922 (age 362.452s) hex dump (first 32 bytes): 01 00 00 00 00 00 00 00 00 00 00 00 ad 4e ad de .............N.. ff ff ff ff 00 00 00 00 ff ff ff ff ff ff ff ff ................ backtrace: [] kmem_cache_alloc_trace+0x146/0x2e0 [] kcov_open+0x25/0x80 [] open_proxy_open+0x1e4/0x2b0 [] do_dentry_open+0x682/0xd70 [] vfs_open+0x107/0x230 [] path_openat+0x1157/0x3520 [] do_filp_open+0x25b/0x3b0 [] do_sys_open+0x4fc/0x6c0 [] SyS_open+0x2d/0x40 [] do_syscall_64+0x23b/0x820 [] return_from_SYSCALL_64+0x0/0x75 [] 0xffffffffffffffff unreferenced object 0xffffc90008679000 (size 134217728): comm "runltp", pid 1847, jiffies 4294957981 (age 362.393s) hex dump (first 32 bytes): e0 d2 46 00 00 00 00 00 22 05 73 81 ff ff ff ff ..F.....".s..... 47 16 73 81 ff ff ff ff 11 16 73 81 ff ff ff ff G.s.......s..... backtrace: [] __vmalloc_node_range+0x387/0x6a0 [] vmalloc_user+0x6c/0x140 [] kcov_mmap+0x2e/0x170 [] mmap_region+0xa9c/0x15a0 [] do_mmap+0x6c6/0xe10 [] vm_mmap_pgoff+0x1de/0x270 [] SyS_mmap_pgoff+0x469/0x610 [] SyS_mmap+0x16/0x20 [] do_syscall_64+0x23b/0x820 [] return_from_SYSCALL_64+0x0/0x75 [] 0xffffffffffffffff unreferenced object 0xffff8800633f6a58 (size 96): comm "runltp", pid 1848, jiffies 4294958935 (age 361.439s) hex dump (first 32 bytes): 01 00 00 00 00 00 00 00 00 00 00 00 ad 4e ad de .............N.. ff ff ff ff 00 00 00 00 ff ff ff ff ff ff ff ff ................ backtrace: [] kmem_cache_alloc_trace+0x146/0x2e0 [] kcov_open+0x25/0x80 [] open_proxy_open+0x1e4/0x2b0 [] do_dentry_open+0x682/0xd70 [] vfs_open+0x107/0x230 [] path_openat+0x1157/0x3520 [] do_filp_open+0x25b/0x3b0 [] do_sys_open+0x4fc/0x6c0 [] SyS_open+0x2d/0x40 [] do_syscall_64+0x23b/0x820 [] return_from_SYSCALL_64+0x0/0x75 [] 0xffffffffffffffff unreferenced object 0xffffc9001067a000 (size 134217728): comm "runltp", pid 1848, jiffies 4294958994 (age 361.380s) hex dump (first 32 bytes): 76 db 46 00 00 00 00 00 22 05 73 81 ff ff ff ff v.F.....".s..... 47 16 73 81 ff ff ff ff 11 16 73 81 ff ff ff ff G.s.......s..... backtrace: [] __vmalloc_node_range+0x387/0x6a0 [] vmalloc_user+0x6c/0x140 [] kcov_mmap+0x2e/0x170 [] mmap_region+0xa9c/0x15a0 [] do_mmap+0x6c6/0xe10 [] vm_mmap_pgoff+0x1de/0x270 [] SyS_mmap_pgoff+0x469/0x610 [] SyS_mmap+0x16/0x20 [] do_syscall_64+0x23b/0x820 [] return_from_SYSCALL_64+0x0/0x75 [] 0xffffffffffffffff unreferenced object 0xffff88006516c6e8 (size 96): comm "runltp", pid 1849, jiffies 4294960010 (age 360.369s) hex dump (first 32 bytes): 01 00 00 00 00 00 00 00 00 00 00 00 ad 4e ad de .............N.. ff ff ff ff 00 00 00 00 ff ff ff ff ff ff ff ff ................ backtrace: [] kmem_cache_alloc_trace+0x146/0x2e0 [] kcov_open+0x25/0x80 [] open_proxy_open+0x1e4/0x2b0 [] do_dentry_open+0x682/0xd70 [] vfs_open+0x107/0x230 [] path_openat+0x1157/0x3520 [] do_filp_open+0x25b/0x3b0 [] do_sys_open+0x4fc/0x6c0 [] SyS_open+0x2d/0x40 [] do_syscall_64+0x23b/0x820 [] return_from_SYSCALL_64+0x0/0x75 [] 0xffffffffffffffff unreferenced object 0xffffc9001867b000 (size 134217728): comm "runltp", pid 1849, jiffies 4294960071 (age 360.308s) hex dump (first 32 bytes): 5d ee 46 00 00 00 00 00 22 05 73 81 ff ff ff ff ].F.....".s..... 47 16 73 81 ff ff ff ff 11 16 73 81 ff ff ff ff G.s.......s..... backtrace: [] __vmalloc_node_range+0x387/0x6a0 [] vmalloc_user+0x6c/0x140 [] kcov_mmap+0x2e/0x170 [] mmap_region+0xa9c/0x15a0 [] do_mmap+0x6c6/0xe10 [] vm_mmap_pgoff+0x1de/0x270 [] SyS_mmap_pgoff+0x469/0x610 [] SyS_mmap+0x16/0x20 [] do_syscall_64+0x23b/0x820 [] return_from_SYSCALL_64+0x0/0x75 [] 0xffffffffffffffff unreferenced object 0xffff88003ed519d0 (size 96): comm "runltp", pid 1850, jiffies 4294961128 (age 359.251s) hex dump (first 32 bytes): 01 00 00 00 00 00 00 00 00 00 00 00 ad 4e ad de .............N.. ff ff ff ff 00 00 00 00 ff ff ff ff ff ff ff ff ................ backtrace: [] kmem_cache_alloc_trace+0x146/0x2e0 [] kcov_open+0x25/0x80 [] open_proxy_open+0x1e4/0x2b0 [] do_dentry_open+0x682/0xd70 [] vfs_open+0x107/0x230 [] path_openat+0x1157/0x3520 [] do_filp_open+0x25b/0x3b0 [] do_sys_open+0x4fc/0x6c0 [] SyS_open+0x2d/0x40 [] do_syscall_64+0x23b/0x820 [] return_from_SYSCALL_64+0x0/0x75 [] 0xffffffffffffffff unreferenced object 0xffffc900206bd000 (size 134217728): comm "runltp", pid 1850, jiffies 4294961186 (age 359.193s) hex dump (first 32 bytes): b8 e3 46 00 00 00 00 00 22 05 73 81 ff ff ff ff ..F.....".s..... 47 16 73 81 ff ff ff ff 11 16 73 81 ff ff ff ff G.s.......s..... backtrace: [] __vmalloc_node_range+0x387/0x6a0 [] vmalloc_user+0x6c/0x140 [] kcov_mmap+0x2e/0x170 [] mmap_region+0xa9c/0x15a0 [] do_mmap+0x6c6/0xe10 [] vm_mmap_pgoff+0x1de/0x270 [] SyS_mmap_pgoff+0x469/0x610 [] SyS_mmap+0x16/0x20 [] do_syscall_64+0x23b/0x820 [] return_from_SYSCALL_64+0x0/0x75 [] 0xffffffffffffffff unreferenced object 0xffff88003ed50c10 (size 96): comm "runltp", pid 1851, jiffies 4294962256 (age 358.132s) hex dump (first 32 bytes): 01 00 00 00 00 00 00 00 00 00 00 00 ad 4e ad de .............N.. ff ff ff ff 00 00 00 00 ff ff ff ff ff ff ff ff ................ backtrace: [] kmem_cache_alloc_trace+0x146/0x2e0 [] kcov_open+0x25/0x80 [] open_proxy_open+0x1e4/0x2b0 [] do_dentry_open+0x682/0xd70 [] vfs_open+0x107/0x230 [] path_openat+0x1157/0x3520 [] do_filp_open+0x25b/0x3b0 [] do_sys_open+0x4fc/0x6c0 [] SyS_open+0x2d/0x40 [] do_syscall_64+0x23b/0x820 [] return_from_SYSCALL_64+0x0/0x75 [] 0xffffffffffffffff unreferenced object 0xffffc900286ff000 (size 134217728): comm "runltp", pid 1851, jiffies 4294962315 (age 358.073s) hex dump (first 32 bytes): 15 af 46 00 00 00 00 00 22 05 73 81 ff ff ff ff ..F.....".s..... 47 16 73 81 ff ff ff ff 11 16 73 81 ff ff ff ff G.s.......s..... backtrace: [] __vmalloc_node_range+0x387/0x6a0 [] vmalloc_user+0x6c/0x140 [] kcov_mmap+0x2e/0x170 [] mmap_region+0xa9c/0x15a0 [] do_mmap+0x6c6/0xe10 [] vm_mmap_pgoff+0x1de/0x270 [] SyS_mmap_pgoff+0x469/0x610 [] SyS_mmap+0x16/0x20 [] do_syscall_64+0x23b/0x820 [] return_from_SYSCALL_64+0x0/0x75 [] 0xffffffffffffffff