From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33037C43457 for ; Fri, 9 Oct 2020 04:23:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A6FAB22254 for ; Fri, 9 Oct 2020 04:23:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="y5E+tIHg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6FAB22254 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E83AB6B0062; Fri, 9 Oct 2020 00:23:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E324E6B0068; Fri, 9 Oct 2020 00:23:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D48C16B006C; Fri, 9 Oct 2020 00:23:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0163.hostedemail.com [216.40.44.163]) by kanga.kvack.org (Postfix) with ESMTP id A4E036B0062 for ; Fri, 9 Oct 2020 00:23:06 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 402B7180AD806 for ; Fri, 9 Oct 2020 04:23:06 +0000 (UTC) X-FDA: 77351091972.04.badge19_3a18461271dd Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 233148009EA2 for ; Fri, 9 Oct 2020 04:23:06 +0000 (UTC) X-HE-Tag: badge19_3a18461271dd X-Filterd-Recvd-Size: 3187 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Fri, 9 Oct 2020 04:23:05 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 831B422227; Fri, 9 Oct 2020 04:23:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602217384; bh=tXVziVcpOhf6tWJihgW01JnDYKr9Ouw7usaFWe60NHs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=y5E+tIHg/r/GyohVPGzuGmMAibpmcOJe6E2bjXVrdbp3YWQVNnC8rqLgSlc8QTAoQ cg5W4q8g6RbLB/F9grDixegMpJjZFgPJv9guSuf0TODXkv6WhbmSdQJoXqNUoW17T1 oQcZy4DrDFzcoDMBBYpIbLV5jLSugfr0gQMWrbpk= Date: Thu, 8 Oct 2020 21:23:04 -0700 From: Andrew Morton To: linmiaohe Cc: "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] mm: mmap: Fix general protection fault in unlink_file_vma() Message-Id: <20201008212304.e631c002648525a5ce54a102@linux-foundation.org> In-Reply-To: <8d3d451883a44f608173fe651b7e6718@huawei.com> References: <8d3d451883a44f608173fe651b7e6718@huawei.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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: On Thu, 8 Oct 2020 07:17:18 +0000 linmiaohe wrote: > Andrew Morton wrote: > > On Wed, 16 Sep 2020 05:07:33 -0400 Miaohe Lin wrote: > > > >> The syzbot reported the below general protection fault: > >> > >> general protection fault, probably for non-canonical address > >> 0xe00eeaee0000003b: 0000 [#1] PREEMPT SMP KASAN > >> KASAN: maybe wild-memory-access in range > >> [0x00777770000001d8-0x00777770000001df] > >> CPU: 1 PID: 10488 Comm: syz-executor721 Not tainted > >> 5.9.0-rc3-syzkaller #0 > >> Trace: > >> free_pgtables+0x1b3/0x2f0 mm/memory.c:415 > >> exit_mmap+0x2c0/0x530 mm/mmap.c:3184 > >> __mmput+0x122/0x470 kernel/fork.c:1076 > >> > >> It's because the ->mmap() callback can change vma->vm_file and fput > >> the original file. But the commit d70cec898324 ("mm: mmap: merge vma > >> after > >> call_mmap() if possible") failed to catch this case and always fput() > >> the original file, hence add an extra fput(). > >> > > ... > > > > >is this using the correct file? I think it is, but please do check. > > > > Many thanks for your reply. > > Yes, I think so too. We do deny_write_access and mapping_map_writable on @file, so we should undo all of this on @file. > Since @file is unchanged over the second vma_merge() time, we'are using the correct @file to undo our temporary denial count. > > But how should I check this explicitly ? I can't find out a way to do this. Could you please figure it out for me? I meant "please check (review) the code as it now is", not "please add a check" ;)