Received: by 10.223.176.46 with SMTP id f43csp1285938wra; Fri, 26 Jan 2018 15:29:19 -0800 (PST) X-Google-Smtp-Source: AH8x2264EgXUBpVpz1IH7qA3WR0xGtCLvOfh0foVUKrAhq54e+N6cic7/iMrRWQzNIxj161nBkNM X-Received: by 2002:a17:902:6882:: with SMTP id i2-v6mr6213677plk.5.1517009359562; Fri, 26 Jan 2018 15:29:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517009359; cv=none; d=google.com; s=arc-20160816; b=CTxyIgypUm9tg3MSNiIVpFtKROcEu/HPYIDDvWGgjL/iNZnLKrmiChJz/mwBCngoOK K/J97nRxnucxhNUo7EylwBvhcS9qkfL5m/N3BBtCPh21RxpndEdA+J/Guqdmi9zdOQm9 r1anamh4rq7n8KotOIOIOU4qX/RQXGzcgUiLqkjAz+R1o9FIkELtVLJOxXHr1/B3IjoI 687sBopBj0krESbrT1bjuKgCKL21Y0qH8z6U5G+Yuar8Ebl+iBYJ8v4PhiOCtbLeRohQ Z5jZv0lhydIcnyhtlKeIl9FL+o897oUBSDI263yBvBj4wHDGUUQAwuN3vUvc/6IdDh3Q i8Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=rKUXdrPbvLDdq9cUb90sG4yfJPqHNkaWBg0hxKeGE20=; b=K8LpBwF1qKkKDBkR7xY1qE2VTCxdpq/PQzX4bLyJVD7tQpQ52h/Xa1fHBKUkV5SpiR b2np5sKl8mJhDP43zKcPz6uE43E3Myp4xW/n6utOM50RoZXXBCnV0n/e9ioz7w7RDKpy WoCTlnek7lbWmi/DRufQEM8OInHme4St7PuYCdTA/mttywG2J8EyM2kmUQnPbmVAokE8 IZ0kD+6LebpZ6PVqwR3f7mLQyrHxPKQC08PCZ7fgtSnlTYbIOqMuUI+Dq+mTXwJaYEL0 Se2bjtZ7mGfiGrAfNRpjlADASwuHTbr7nlZCTaaYJ5z6QTvYGODaJFVmBBD6E2qYkqKj gdaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HINVkLee; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o2-v6si3551778pls.324.2018.01.26.15.29.05; Fri, 26 Jan 2018 15:29:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HINVkLee; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752574AbeAZX2B (ORCPT + 99 others); Fri, 26 Jan 2018 18:28:01 -0500 Received: from mail-io0-f193.google.com ([209.85.223.193]:37506 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752523AbeAZX17 (ORCPT ); Fri, 26 Jan 2018 18:27:59 -0500 Received: by mail-io0-f193.google.com with SMTP id f89so2104033ioj.4; Fri, 26 Jan 2018 15:27:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=rKUXdrPbvLDdq9cUb90sG4yfJPqHNkaWBg0hxKeGE20=; b=HINVkLeeFy/6UhIPKXijIdCymgc8mHxuF4W8P2RiXkiE0KpO4G8wBkY+PtKce5ZLvG RiHz9F9P1viaPiINsd+KFAlYyJP/JB/WNIYEKUW0iU0YXgFMvsTDz+qbxQeM6nGDRuoA SFMEAzD2ydvnH9kCYK3givwWAJb4RZK3PsqmkPixGI/tZj2uytLoZpFq7Mm17+5lSZmx L8NPxapVv8p+CVJZRqOpyBOGne0pVY6F/8Ag5xhgaug6wttymmeH3VQDr0S0Hd2HJ9Ve mnVcTdFH6se8s7nNx2nNtdi7rhUYS1yBvcV26rEgD0nwCPxT+l5jKvN0n5GKxmGISsoG X0Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=rKUXdrPbvLDdq9cUb90sG4yfJPqHNkaWBg0hxKeGE20=; b=V9PXAFwHAvrP40MDv8JLWzVm4A9yb3wNKlsUEGFbeSC0F5TLHmFh0HliJe/sdD+Qpj 6CHkHe2RrxGa3x4Sa6tGFJj+gMoyyGVFrK6L1b+hA9Zppzssem2/5lsz0OFjjjha5W1C caxaT9O5oIUDdhvdJooMg/jqJI9+RkQLPBD/ARPtwen+CGMp4Q6Hi+L2zXvHzqIiKG5r wjAPQhakYJVxXrvyHpOktFjr6kboJmqg25G4rn5RazN6sMcgsRwqw+PrH7/k/StYrAbf nqccAwdNwcnFmjAVFpGaUEr7t53vJhOXcRVySvnqq3CDaMgYtWAbIcH58iXg+nJLiHwI dYHw== X-Gm-Message-State: AKwxytdb3LtTR2JlFT0H+Tn7odX9nD9c6TFET+kErWQuX/jyXc9VhPRK 6FHcdPS2EO6l/JhEda+qprQ= X-Received: by 10.107.203.5 with SMTP id b5mr16230425iog.144.1517009278461; Fri, 26 Jan 2018 15:27:58 -0800 (PST) Received: from gmail.com ([2620:15c:17:3:dc28:5c82:b905:e8a8]) by smtp.gmail.com with ESMTPSA id 68sm1121008iok.37.2018.01.26.15.27.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Jan 2018 15:27:57 -0800 (PST) Date: Fri, 26 Jan 2018 15:27:55 -0800 From: Eric Biggers To: "Lan, Tianyu" Cc: syzbot , Tianyu Lan , borntraeger@de.ibm.com, cornelia.huck@de.ibm.com, david@redhat.com, Dmitry Vyukov , "H. Peter Anvin" , jschoenh@amazon.de, kvm , "linux-kernel@vger kernel org" , Ingo Molnar , Paolo Bonzini , Radim Krcmar , syzkaller-bugs@googlegroups.com, Thomas Gleixner , the arch/x86 maintainers Subject: Re: Re: KASAN: use-after-free Write in irq_bypass_register_consumer Message-ID: <20180126232755.z3gtqrm2oz6sp2t6@gmail.com> References: <001a1143e716efd3a9055cc8696b@google.com> <001a1146f1146fe0b505605e42c1@google.com> <91a32ec1-64e7-8b6b-9464-6599dd6735ad@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <91a32ec1-64e7-8b6b-9464-6599dd6735ad@intel.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Dec 16, 2017 at 04:37:02PM +0800, Lan, Tianyu wrote: > The root cause is that kvm_irqfd_assign() and kvm_irqfd_deassign() can't > be run in parallel. Some data structure(e.g, irqfd->consumer) will be > crashed because irqfd may be freed in deassign path before they are used > in assign path. The other data maybe used in deassign path before > initialization. Syzbot test hit such case. Add mutx between > kvm_irqfd_assign() and kvm_irqfd_deassign() can fix such issue. Will > send patch to fix it. > > On 12/16/2017 12:53 PM, Tianyu Lan wrote: > > I reproduced the issue. Will have a look. > > > > -- Best regards Tianyu Lan 2017-12-15 18:14 GMT+08:00 syzbot > > : > > > syzkaller has found reproducer for the following crash on > > > 82bcf1def3b5f1251177ad47c44f7e17af039b4b > > > git://git.cmpxchg.org/linux-mmots.git/master > > > compiler: gcc (GCC) 7.1.1 20170620 > > > .config is attached > > > Raw console output is attached. > > > C reproducer is attached > > > syzkaller reproducer is attached. Seehttps://goo.gl/kgGztJ > > > for information about syzkaller reproducers > > > > > > > > > ================================================================== > > > BUG: KASAN: use-after-free in __list_add include/linux/list.h:64 [inline] > > > BUG: KASAN: use-after-free in list_add include/linux/list.h:79 [inline] > > > BUG: KASAN: use-after-free in irq_bypass_register_consumer+0x4b4/0x500 > > > virt/lib/irqbypass.c:217 > > > Write of size 8 at addr ffff8801cdf51180 by task syzkaller436086/15031 > > > > > > CPU: 1 PID: 15031 Comm: syzkaller436086 Not tainted 4.15.0-rc2-mm1+ #39 > > > 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_store8_noabort+0x17/0x20 mm/kasan/report.c:435 > > > __list_add include/linux/list.h:64 [inline] > > > list_add include/linux/list.h:79 [inline] > > > irq_bypass_register_consumer+0x4b4/0x500 virt/lib/irqbypass.c:217 > > > kvm_irqfd_assign arch/x86/kvm/../../../virt/kvm/eventfd.c:417 [inline] > > > kvm_irqfd+0x137f/0x1d50 arch/x86/kvm/../../../virt/kvm/eventfd.c:572 > > > kvm_vm_ioctl+0x1079/0x1c40 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2992 > > > vfs_ioctl fs/ioctl.c:46 [inline] > > > do_vfs_ioctl+0x1b1/0x1530 fs/ioctl.c:686 > > > SYSC_ioctl fs/ioctl.c:701 [inline] > > > SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692 > > > entry_SYSCALL_64_fastpath+0x1f/0x96 > > > RIP: 0033:0x44d379 > > > RSP: 002b:00007fc5ff9a9d08 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 > > > RAX: ffffffffffffffda RBX: 00007fc5ff9aa700 RCX: 000000000044d379 > > > RDX: 0000000020080fe0 RSI: 000000004020ae76 RDI: 0000000000000005 > > > RBP: 00000000007ff900 R08: 00007fc5ff9aa700 R09: 00007fc5ff9aa700 > > > R10: 00007fc5ff9aa700 R11: 0000000000000246 R12: 0000000000000000 > > > R13: 00000000007ff8ff R14: 00007fc5ff9aa9c0 R15: 0000000000000000 > > > > > > Allocated by task 15031: > > > 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:516 [inline] > > > kzalloc include/linux/slab.h:705 [inline] > > > kvm_irqfd_assign arch/x86/kvm/../../../virt/kvm/eventfd.c:296 [inline] > > > kvm_irqfd+0x16c/0x1d50 arch/x86/kvm/../../../virt/kvm/eventfd.c:572 > > > kvm_vm_ioctl+0x1079/0x1c40 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2992 > > > vfs_ioctl fs/ioctl.c:46 [inline] > > > do_vfs_ioctl+0x1b1/0x1530 fs/ioctl.c:686 > > > SYSC_ioctl fs/ioctl.c:701 [inline] > > > SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692 > > > entry_SYSCALL_64_fastpath+0x1f/0x96 > > > > > > Freed by task 1402: > > > 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 > > > irqfd_shutdown+0x13c/0x1a0 arch/x86/kvm/../../../virt/kvm/eventfd.c:148 > > > process_one_work+0xbfd/0x1bc0 kernel/workqueue.c:2113 > > > worker_thread+0x223/0x1990 kernel/workqueue.c:2247 > > > kthread+0x37a/0x440 kernel/kthread.c:238 > > > ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:524 > > > > > > The buggy address belongs to the object at ffff8801cdf51000 > > > which belongs to the cache kmalloc-512 of size 512 > > > The buggy address is located 384 bytes inside of > > > 512-byte region [ffff8801cdf51000, ffff8801cdf51200) > > > The buggy address belongs to the page: > > > page:00000000d08a0d63 count:1 mapcount:0 mapping:00000000d54c7be6 index:0x0 > > > flags: 0x2fffc0000000100(slab) > > > raw: 02fffc0000000100 ffff8801cdf51000 0000000000000000 0000000100000006 > > > raw: ffffea00073a7660 ffffea000737f3a0 ffff8801dac00940 0000000000000000 > > > page dumped because: kasan: bad access detected > > > > > > Memory state around the buggy address: > > > ffff8801cdf51080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > > > ffff8801cdf51100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > > > > ffff8801cdf51180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > > > ^ > > > ffff8801cdf51200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc > > > ffff8801cdf51280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb > > > ================================================================== > > > Tianyu, are you still planning to send a patch for this? This is still happening. - Eric