Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2331682pxk; Mon, 14 Sep 2020 10:24:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweza+PTJajl5FJiy3bFELEhigxsJ2kN9h67CwCY4Lbpi0WPGonRB5lCVD5IwoyCoE+Egln X-Received: by 2002:a17:906:2dd:: with SMTP id 29mr4815268ejk.31.1600104285475; Mon, 14 Sep 2020 10:24:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600104285; cv=none; d=google.com; s=arc-20160816; b=Qq80ZHFJBgT1jqEWd58wYvaAZj64lMn1UkeFRuUJJgzZKfmH4+8CiWG1mCFsXgYuDZ 9v/tzfV6AVJPWtFiWQ/TXFHy3vbYr8kw5lFIUMrhCi7VyU0XvtUvLMHbKJJIOPyLmsde 9/JcRPhvIRO/cykdbT2QA4s+7X3/c6LhrltLrnDc9feR5i/913XjjcBJdF4gyHeDX68X 8+dzwN5g4ZhnNwl5QJEgs0JR9vGIQRwMYbTyqIj7oBTG5k5IWOvlQ0HlYy70DvBFb1zH VdhoLv8T8k9GTfBdZDMmlRnqZeTOB8uiUd3E2Li8ePfGT9wvQL7AObFqw4OveDYwUBcl bNBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=sovkMljeHeE8QiqrRubge8NYzTKoGU5H5cGDXKlh4Do=; b=nHXGnAAiEMla74nZ7/NdDm7apJ2J+TJoO+ZCFDdKJv5OLaA3xJxh/LcTd7Qp9InWYr oQ0O1nCaNQxu5LqQOmAILPn8pW7HD9zBAAkY3RdiTfJ/CXwbzW+RTBUp9RKJN+97Y1TJ UcA0B3Cn8YL01QztWhYSvjZRQQssffhTmqKG7xB1YY5sDdtHzyvgLmhV/V7gXM9GhOUY 1iJjl981skeqCB2nqc13+wU2eaYYq5SFa/zTzj7YfXHaI1wGPHpTmzZoIm5WPklaDcle U8/eSBXqkgJAJQ5xTUH8pAlhGV4Zlmyppf+/zcpynu3Jdqp8C8elO+ChkJ+M4cUls3YV bvyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=vUB6uayC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h23si7661044ejd.576.2020.09.14.10.24.22; Mon, 14 Sep 2020 10:24:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=vUB6uayC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726468AbgINM3i (ORCPT + 99 others); Mon, 14 Sep 2020 08:29:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726297AbgINM1y (ORCPT ); Mon, 14 Sep 2020 08:27:54 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 107B6C0612F2; Mon, 14 Sep 2020 04:56:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=sovkMljeHeE8QiqrRubge8NYzTKoGU5H5cGDXKlh4Do=; b=vUB6uayCQphbQuNntBPspugAbh jOnkcmA2i0c1bK3N378QEG6urxYN2R7PkOVb1UBFygrhBxVKmvJMjSakYenuJpOACgtx48gHNx+Og OjV/0iCsw0wHglN8SOZU9DcEQyzQl7SWZIGlWIHGw1wA20VEHpisZSEb6BLPX8fG7L7A+/Cetvyyo hvCQE07SWyK0xzyh330bETJW80DBj35QKQDo5dF7JehFVwCkWjyJWZWIyUfDCpjhryV40uYeeZUag tRBzRfTAjPKaeFXjbX7UurmQrcJmocUWXkD10jTTSuoo42EsMmxfEZeOH34uT3zkVyXpjvEMBB6N5 QVntRK2g==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHn5T-0007T5-Al; Mon, 14 Sep 2020 11:55:59 +0000 Date: Mon, 14 Sep 2020 12:55:59 +0100 From: Matthew Wilcox To: Naresh Kamboju Cc: open list , X86 ML , linux-fsdevel@vger.kernel.org, linux-mm , Linux-Next Mailing List , lkft-triage@lists.linaro.org, Andrew Morton , Hugh Dickins , William Kucharski , gandalf@winds.org, Qian Cai , Mike Kravetz , Michal Hocko , Yang Shi , Shakeel Butt Subject: Re: BUG: kernel NULL pointer dereference, address: RIP: 0010:shmem_getpage_gfp.isra.0+0x470/0x750 Message-ID: <20200914115559.GN6583@casper.infradead.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 14, 2020 at 03:49:43PM +0530, Naresh Kamboju wrote: > While running LTP fs on qemu x86 and qemu_i386 these kernel BUGs noticed. I actually sent the fix for this a couple of days ago [1], but I think Andrew overlooked it while constructing the -mm tree. Here's a fix you can apply to the -mm tree: [1] https://lore.kernel.org/linux-mm/20200912032042.GA6583@casper.infradead.org/ diff --git a/mm/shmem.c b/mm/shmem.c index d2a46ef7df43..58bc9e326d0d 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1793,7 +1793,7 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, struct mm_struct *charge_mm; struct page *page; enum sgp_type sgp_huge = sgp; - pgoff_t hindex; + pgoff_t hindex = index; int error; int once = 0; int alloced = 0; @@ -1822,6 +1822,8 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, return error; } + if (page) + hindex = page->index; if (page && sgp == SGP_WRITE) mark_page_accessed(page); @@ -1832,6 +1834,7 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, unlock_page(page); put_page(page); page = NULL; + hindex = index; } if (page || sgp == SGP_READ) goto out; @@ -1982,7 +1985,7 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, goto unlock; } out: - *pagep = page + index - page->index; + *pagep = page + index - hindex; return 0; /*