From patchwork Mon Jul 9 22:07:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A. Shutemov" X-Patchwork-Id: 10515809 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 82805603D7 for ; Mon, 9 Jul 2018 22:07:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E8E628DE3 for ; Mon, 9 Jul 2018 22:07:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F8E828DE7; Mon, 9 Jul 2018 22:07:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C604428DE3 for ; Mon, 9 Jul 2018 22:07:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ABE4F6B0003; Mon, 9 Jul 2018 18:07:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A93936B0005; Mon, 9 Jul 2018 18:07:22 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 983876B0006; Mon, 9 Jul 2018 18:07:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 55B896B0003 for ; Mon, 9 Jul 2018 18:07:22 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id t5-v6so639930pgt.18 for ; Mon, 09 Jul 2018 15:07:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:references:mime-version:content-disposition:in-reply-to :user-agent; bh=251MKHFIg8gvnGzNL1OWN9Vz36YYRLhQHV5ECZsbPHg=; b=gVcmIp6sMDZ3aSaBPrYch6yTQ1Zr37jWS1t8zuwBsIivJ7W70NAbbs22CU3z/DBMFL gfGnR5fYBPZ8QRb4vncdOFMmAGHBVx16S0mXNmOqcvs7b7oHeizgjwNePQbtCWYyQin/ ymWBG2LFhAkNtW1XQgju79JUyJfxYKjdWXrxtU5pz42WYs9UkcAXVbkWUiPcQoSXq4f/ rW72NhqKq0ppZRO/qDfK0pEJBgisOnPHVVvOJfyUpClmKiWqygUn3cDVOg6kCR2AFy5R tg+aAE7C7sc8qcJes68j3dKvD4Uj40Aq3TPLkY0v54O85L7ZU++RbvFPsi94tV6oBq8M Kq1A== X-Gm-Message-State: APt69E0Ex2vfGHuiedhgYBSutvUInGx+fHH8zcGbq/hKo57dspPX4TPq I3SDPWQT+kinkPrTcx1WSrOFh7D5f3WkhJPHmq7Wpi2ImJrzzkkf3YZdD5XajPTiYScQ4xId5A4 XYP4k+IKjnuicj2tejXgY3m5qBfQZ0AFqCBiSTmdV4iantzZwa9eskIWpfPbs1DSPw4kSAKTfr4 kI5gUckQV+or138uhoH5n/nuQOMsKNRIr+QUlO2wsX92mSSJBHha2iE1DkI56KTWKUhN7w3i7+p PvL8UgWljJoNNg82e5J6p4JwgKmwV7e6Hs58jFJ59kyEx4sbofyfwPgrjBtEXr0B8ORJ1IQPF/3 5dSOHCLZedyXHxC9JcIn0348UaOOErmNXftA/XieHOmfOZGBlQFCikdKQtWIAhTcEdtnxnIQHIE u X-Received: by 2002:a62:404e:: with SMTP id n75-v6mr19307754pfa.232.1531174041792; Mon, 09 Jul 2018 15:07:21 -0700 (PDT) X-Received: by 2002:a62:404e:: with SMTP id n75-v6mr19307694pfa.232.1531174040378; Mon, 09 Jul 2018 15:07:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531174040; cv=none; d=google.com; s=arc-20160816; b=Z/4h3EbYrGRwHlKQj5Krs1lhFnkxecVUWtc3yxaVNvKq8hUiXPpXBAPkVZUWqXvb6h xVjnaZMyQKak9HmUxEkh+RGtYylhBlScvcCRNNwFxsQbCzjo1r81dhgfMStqPDIDYAi1 +9rVSaVjvvSjMV9dd8zQh1OTpLDCrzszCGGRzgxQmJRqhHrwMYqP+jBqvIg+WJBYyqHW o+r09nftZsyxHkH2JsTDzdnWJSFAhdDepkHuQusoCtMjM55s+DUjA8e/HivZlkWU3MlP chRclYisJ3k8SkK4z3iDMgqgmDVo0fjL60CqUny4zfVltZJesC2ddCfn5/GxGNXazDTZ tDcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=251MKHFIg8gvnGzNL1OWN9Vz36YYRLhQHV5ECZsbPHg=; b=XnD0TzP/kw9Z9UT/M6IHSPjvL9klKJag54+xZSAbGJ+DyRdeJOveliB0iAXpIfsQHD 71ccZVis7eq88+bzXyhJMW4UhrbH3ea0v/IHlJwOJMdJVcwTfWdq7IV9UbmK7n2eNpof 3zUvowlCIyEubqSnzyqP0OhNnZ8PGCvYh9sQMNBLjEMTQQXiZiESMnauv+qyp9cCA2c1 XeazxQ2qk5/rxsb5yjW7wH8CpNNP6LwNHWRoof7ZKnytE14OCJUcd3SlG33IfJtOhD2i kyEI6yM7CcLqSXACqPe0ANz1TkLb0IoaEQ3NLdMm+iqpXcZ6acUkzIgJb5fZ+Nb+4RK9 rdfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=ivSn4YbZ; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of kirill@shutemov.name) smtp.mailfrom=kirill@shutemov.name Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id s23-v6sor3393124pgk.104.2018.07.09.15.07.20 for (Google Transport Security); Mon, 09 Jul 2018 15:07:20 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of kirill@shutemov.name) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=ivSn4YbZ; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of kirill@shutemov.name) smtp.mailfrom=kirill@shutemov.name DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=251MKHFIg8gvnGzNL1OWN9Vz36YYRLhQHV5ECZsbPHg=; b=ivSn4YbZ7C8cuVl8YKOPC9rfx3q/1V60JmpsQy8kH6Q9YqG6/Ipnn8XImVo8vOqqGw uo23LtrFBRzIx8+2hOaETrfKo6klqwTnDTUfu7/4yrwk7HoCytE4T0+fhMSARM4GgLC2 5rlLDN/gP6daszJnDUlkZ4TI/i2tMJFOJVB1VmdLBBHrk6XBwXdWISGyNyErNA2T0Qu5 LE5pSl/kMmA6oTBJzgXMYNyNjeSYMWDMoKYCR57MeXz+P/lUgasyjEugvH/Y4AbSIfvJ j4eYGD50wU+S4Y3it5v7hSLm1rSYi9fxC05rnbsEtug+zl0HMmu/0dPvUIgGcJf2iOQM iEIQ== X-Google-Smtp-Source: AAOMgpdXHPyxDxwqbsdbv8a3E1LeUhykQII+gr21KgO93h6yVEsUwknKd1l/EUuYscy1Pgtjs88kmg== X-Received: by 2002:a65:5907:: with SMTP id f7-v6mr19833870pgu.83.1531174037093; Mon, 09 Jul 2018 15:07:17 -0700 (PDT) Received: from kshutemo-mobl1.localdomain (fmdmzpr04-ext.fm.intel.com. [192.55.54.39]) by smtp.gmail.com with ESMTPSA id d132-v6sm30194096pga.10.2018.07.09.15.07.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jul 2018 15:07:16 -0700 (PDT) Received: by kshutemo-mobl1.localdomain (Postfix, from userid 1000) id BF4F630003F; Tue, 10 Jul 2018 01:07:11 +0300 (+03) Date: Tue, 10 Jul 2018 01:07:11 +0300 From: "Kirill A. Shutemov" To: Dmitry Vyukov Cc: syzbot , Andrew Morton , Dan Williams , Jerome Glisse , "Kirill A. Shutemov" , ldufour@linux.vnet.ibm.com, LKML , Linux-MM , Michal Hocko , Minchan Kim , Ross Zwisler , syzkaller-bugs , Matthew Wilcox , ying.huang@intel.com Subject: Re: kernel BUG at mm/memory.c:LINE! Message-ID: <20180709220711.2zz75g4mo4p76bbx@kshutemo-mobl1> References: <0000000000004a7da505708a9915@google.com> <20180709101558.63vkwppwcgzcv3dg@kshutemo-mobl1> <20180709142155.jlgytrhdmkyvowzh@kshutemo-mobl1> <20180709152508.smwg252x57pnfkoq@kshutemo-mobl1> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180622 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Jul 09, 2018 at 07:23:15PM +0200, Dmitry Vyukov wrote: > On Mon, Jul 9, 2018 at 5:25 PM, Kirill A. Shutemov wrote: > > On Mon, Jul 09, 2018 at 05:21:55PM +0300, Kirill A. Shutemov wrote: > >> > This also happened only once so far: > >> > https://syzkaller.appspot.com/bug?extid=3f84280d52be9b7083cc > >> > and I can't reproduce it rerunning this program. So it's either a very > >> > subtle race, or fd in the middle of netlink address magically matched > >> > some fd once, or something else... > >> > >> Okay, I've got it reproduced. See below. > >> > >> The problem is that kcov doesn't set vm_ops for the VMA and it makes > >> kernel think that the VMA is anonymous. > >> > >> It's not necessary the way it was triggered by syzkaller. I just found > >> that kcov's ->mmap doesn't set vm_ops. There can more such cases. > >> vma_is_anonymous() is what we need to fix. > >> > >> ( Although, I found logic around mmaping the file second time questinable > >> at best. It seems broken to me. ) > >> > >> It is known that vma_is_anonymous() can produce false-positives. It tried > >> to fix it once[1], but it back-fired[2]. > >> > >> I'll look at this again. > > > > Below is a patch that seems work. But it definately requires more testing. > > > > Dmitry, could you give it a try in syzkaller? > > Trying. > > Not sure what you expect from this. Either way it will be hundreds of > crashes before vs hundreds of crashes after ;) > > But one that started popping up is this, looks like it's somewhere > around the code your patch touches: > > kasan: CONFIG_KASAN_INLINE enabled > kasan: GPF could be caused by NULL-ptr deref or user memory access > general protection fault: 0000 [#1] SMP KASAN > CPU: 0 PID: 6711 Comm: syz-executor3 Not tainted 4.18.0-rc4+ #43 > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014 > RIP: 0010:__get_vma_policy+0x61/0x160 mm/mempolicy.c:1620 Right, my bad. Here's fixup. diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index d508c7844681..12b2b3c7f51e 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -597,6 +597,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset, memset(&pseudo_vma, 0, sizeof(struct vm_area_struct)); pseudo_vma.vm_flags = (VM_HUGETLB | VM_MAYSHARE | VM_SHARED); pseudo_vma.vm_file = file; + pseudo_vma.vm_ops = &anon_vm_ops; for (index = start; index < end; index++) { /*