From patchwork Fri Nov 5 20:37:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12605459 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 643FFC433FE for ; Fri, 5 Nov 2021 20:37:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2D02D60E08 for ; Fri, 5 Nov 2021 20:37:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2D02D60E08 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=kvack.org Received: by kanga.kvack.org (Postfix) id B8FCE94002D; Fri, 5 Nov 2021 16:37:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B1798940007; Fri, 5 Nov 2021 16:37:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B91F94002D; Fri, 5 Nov 2021 16:37:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0254.hostedemail.com [216.40.44.254]) by kanga.kvack.org (Postfix) with ESMTP id 8191F940007 for ; Fri, 5 Nov 2021 16:37:12 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 426611856A8D4 for ; Fri, 5 Nov 2021 20:37:12 +0000 (UTC) X-FDA: 78776036388.05.79A86A5 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf11.hostedemail.com (Postfix) with ESMTP id E637DF0000BC for ; Fri, 5 Nov 2021 20:37:11 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 0EB9760E05; Fri, 5 Nov 2021 20:37:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1636144631; bh=tolFhU/6c0H5j6/fvNY0DHTPCF/4Lqm1K9ZS2GAWqOM=; h=Date:From:To:Subject:In-Reply-To:From; b=2s8/x+FiI09Nb4WDj7o+PyiSi7JTvfnaJKlopsruiH7qp7QGi8Fb7qEaAXHHxDtvY KIS1mLIoL7M2G0eCY397vhzaJ50vrqHHOP5ans8sfOJscwwBiXdVSsAzK9xcr1+cP4 dv0hlSHlzlGrd+DAV1Tsy0x1n55dYJYPQzYZGYZw= Date: Fri, 05 Nov 2021 13:37:10 -0700 From: Andrew Morton To: akpm@linux-foundation.org, hughd@google.com, linux-mm@kvack.org, mm-commits@vger.kernel.org, stable@vger.kernel.org, syzbot+c87be4f669d920c76330@syzkaller.appspotmail.com, torvalds@linux-foundation.org, willy@infradead.org Subject: [patch 048/262] mm/filemap.c: remove bogus VM_BUG_ON Message-ID: <20211105203710.7ygSi-fQI%akpm@linux-foundation.org> In-Reply-To: <20211105133408.cccbb98b71a77d5e8430aba1@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: E637DF0000BC X-Stat-Signature: enokr5oriyt9fmqp8nq1pogwoe61imrz Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b="2s8/x+Fi"; dmarc=none; spf=pass (imf11.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-HE-Tag: 1636144631-731485 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: From: "Matthew Wilcox (Oracle)" Subject: mm/filemap.c: remove bogus VM_BUG_ON It is not safe to check page->index without holding the page lock. It can be changed if the page is moved between the swap cache and the page cache for a shmem file, for example. There is a VM_BUG_ON below which checks page->index is correct after taking the page lock. Link: https://lkml.kernel.org/r/20210818144932.940640-1-willy@infradead.org Fixes: 5c211ba29deb ("mm: add and use find_lock_entries") Signed-off-by: Matthew Wilcox (Oracle) Reported-by: Cc: Hugh Dickins Cc: Signed-off-by: Andrew Morton --- mm/filemap.c | 1 - 1 file changed, 1 deletion(-) --- a/mm/filemap.c~mm-remove-bogus-vm_bug_on +++ a/mm/filemap.c @@ -2093,7 +2093,6 @@ unsigned find_lock_entries(struct addres if (!xa_is_value(page)) { if (page->index < start) goto put; - VM_BUG_ON_PAGE(page->index != xas.xa_index, page); if (page->index + thp_nr_pages(page) - 1 > end) goto put; if (!trylock_page(page))