Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp280812pxx; Wed, 28 Oct 2020 04:55:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlydU+giPLivKAxokenXBHzuxGgMuJhKV3zSupttPvkDawbkBAsMSCLKXahIuGFBZMojX2 X-Received: by 2002:a17:906:1a04:: with SMTP id i4mr7465698ejf.24.1603886146330; Wed, 28 Oct 2020 04:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603886146; cv=none; d=google.com; s=arc-20160816; b=pahwCDrftUpWdEIXHu4w9RiXJTIDUM2sksTwvpmMs+6nEcYtEAsPQjzbn2kPYbEho7 A2HtmsYf574QEjdhAYigtPjfkUmn86k1lF6flzKhs4LV+u98mAfNKxY1xEz+DCk7YiY6 k1VJ9UPvjt+XN0315Xq8yubxC/7ZPgd+cweNRq1Hrf46o4YQGgaEJsjbzbbpAoDGkJeb znYneoP9yRg3PqipWiWFdRJSO3UfziVI7PHrxmZNxvn/np51c29CF+bQwPNzj32dSv7n hEfy9Alc4qX11OZytauMH1QvVHV10lLZW/NFDKBNdG46ONpiVxKuVktNBs1OaLwNulUx JDqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lAu7WDSDLasUM7bOBOXcQUYHROO5HC39u6QrJI51180=; b=Rjifsy013h9BXApyLuSyYHXXLHsH/rK/NaqzE2iDmGkLJ85f5wG+BXRjhsdeJViDHL fOfCDfs562Yx8GE22koZ7LC4eM28lgCWG6awNQ5AojCapNQyO7NOtAEYGv9lT8rGBHcN SEioI/p82B4211uUFJrcm9TsojKEG2fE0RVVP963LAWyEnawYhNLBc5BohmvnyExSCkb 0bCK0llSNDfawyojuaZ3ZRiJ5Ws1ejsTG/g7Xv5mgdcTittqZGLBNkieJ+UITS7pmyu1 sNGW+fBFnDzSdbdpjChxRGCoU1+iOQBMOH0KNDNMo8EUQBBjnMuy2h4SnhIrOlG7gKzH EFYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IO2ThJUT; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs17si3022913ejb.543.2020.10.28.04.55.24; Wed, 28 Oct 2020 04:55:46 -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=pass header.i=@kernel.org header.s=default header.b=IO2ThJUT; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1794830AbgJ0PNu (ORCPT + 99 others); Tue, 27 Oct 2020 11:13:50 -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