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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 4F6E5C388F9 for ; Tue, 27 Oct 2020 15:13:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E68E32224A for ; Tue, 27 Oct 2020 15:13:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811633; bh=VL6ylCSbZaXJwcapvIXH6TYP8HJ5sfg/4QUgunIUebQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=NGFW072TQ+1Ynbuk5YwlVpRzLS1rz+jKzk5h4jqJRwKru0jk7+7KUCIykVnYsBGFs PBiCltUzg8o4BshVFTaam0tzPpOlobXtoF4iP3WoyW4xV648PdOcICpfHXY6HduvpJ qvJyA2XdA348iaGuqMz/g9I14XucZ6gtwrO2NxVc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1794835AbgJ0PNv (ORCPT ); Tue, 27 Oct 2020 11:13:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:41394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1793577AbgJ0PHQ (ORCPT ); Tue, 27 Oct 2020 11:07:16 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 BF787223AB; Tue, 27 Oct 2020 15:07:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811232; bh=VL6ylCSbZaXJwcapvIXH6TYP8HJ5sfg/4QUgunIUebQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IO2ThJUTq/rIukiPFvCw8q/FURw6GQsy5msC8bhUfk+hQamNOABEEBzKQw5JV/IwH oVFkFalYCrfK9U6o3XlgHY6UQlg0ZEtwBvzxAMP2UUnNwFwqyiIQl7Njep9HWIDVBB wcnv6yJTQe1/NmJKu6b2/ghEj4cKSWp3hKpty6Lo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Matthew Wilcox (Oracle)" , Andrew Morton , David Howells , Linus Torvalds , Sasha Levin Subject: [PATCH 5.8 421/633] ramfs: fix nommu mmap with gaps in the page cache Date: Tue, 27 Oct 2020 14:52:44 +0100 Message-Id: <20201027135542.472763772@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Wilcox (Oracle) [ Upstream commit 50b7d85680086126d7bd91dae81d57d4cb1ab6b7 ] ramfs needs to check that pages are both physically contiguous and contiguous in the file. If the page cache happens to have, eg, page A for index 0 of the file, no page for index 1, and page A+1 for index 2, then an mmap of the first two pages of the file will succeed when it should fail. Fixes: 642fb4d1f1dd ("[PATCH] NOMMU: Provide shared-writable mmap support on ramfs") Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Andrew Morton Cc: David Howells Link: https://lkml.kernel.org/r/20200914122239.GO6583@casper.infradead.org Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/ramfs/file-nommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c index 4146954549560..355523f4a4bf3 100644 --- a/fs/ramfs/file-nommu.c +++ b/fs/ramfs/file-nommu.c @@ -224,7 +224,7 @@ static unsigned long ramfs_nommu_get_unmapped_area(struct file *file, if (!pages) goto out_free; - nr = find_get_pages(inode->i_mapping, &pgoff, lpages, pages); + nr = find_get_pages_contig(inode->i_mapping, pgoff, lpages, pages); if (nr != lpages) goto out_free_pages; /* leave if some pages were missing */ -- 2.25.1