Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1044784imu; Fri, 7 Dec 2018 13:11:40 -0800 (PST) X-Google-Smtp-Source: AFSGD/UPy9qncy8Ww8yqhiXfHlgPnGJb1Gq4bPe9PLcMqxQoWCYkJGN4/EBob6iWfqbphq2NDWik X-Received: by 2002:a63:4b25:: with SMTP id y37mr3418562pga.181.1544217100813; Fri, 07 Dec 2018 13:11:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544217100; cv=none; d=google.com; s=arc-20160816; b=WyWtAAlNcqtFe33dowAx+BW5e+zE1nDiJWXIMooLNsz1BHAw4WkJJ7V7ceqXRCgPZC 6HJHONGso1jo87JylUDBanLqVTIf4n4/vq85OlrTjsp5NXXV0qn5UO3iFRAS/F8uafS1 OgF8EHDag5iypiWQna+DoXVW2C1K4dkjevsI3YpiHmk8NxrCZMx7Oqm06EdiP4K+Sd69 3cj812WEw0RCJxQmFPavuzvv7jE3dK4NviznkdR00YNe1DY93GmzEOVkp8qJv21Aapxk YFMYmRsXAgkNm49IaKDUlHWG33Uz4Z7vZoR+PVjRjvKX/AO/jVqHFGR40IEaCkFG7rWh wwxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=cPcbKdQ8SPYwFrd1ykd99DhKbl3UpsIYetXDqAYtlJk=; b=z72S6oOMn3bMfxtp2rEsdpiiuDVwCcRrngffFVQffA1MwwIpbJ4KVJ9hXG7INHWuAD PiM3jT1w/UJxRQ2kjgUFg6MSncWj7+d04a96vTxuKi+XIguhds2e7XsJ0QlUQUk3GoIC gpLjWhA3hvKddCY05OgxSq2DX4oywuBJuxLV8cHeC7cLU/rODH6HDjAHcES07uRxg1hF laShDjAev14/V10/MHJs8Y3MzIJFRfzjche1telaVXIDtLPZXZRBha9OCosj4FIXRE9i WgdnDD7NscWuJGTgJZEVN8jqxM8Ce8JeWGdyoorsz81EZimt3g7ZESgNAdtbjOa68RgF N2nQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o7si3682819pgg.118.2018.12.07.13.11.25; Fri, 07 Dec 2018 13:11:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726445AbeLGVKR (ORCPT + 99 others); Fri, 7 Dec 2018 16:10:17 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54354 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726401AbeLGVKQ (ORCPT ); Fri, 7 Dec 2018 16:10:16 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8ADFD15AB; Fri, 7 Dec 2018 13:10:15 -0800 (PST) Received: from [192.168.1.123] (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 152E83F614; Fri, 7 Dec 2018 13:10:06 -0800 (PST) Subject: Re: [PATCH v3 1/9] mm: Introduce new vm_insert_range API To: Souptick Joarder , Matthew Wilcox Cc: Andrew Morton , Michal Hocko , "Kirill A. Shutemov" , vbabka@suse.cz, Rik van Riel , Stephen Rothwell , rppt@linux.vnet.ibm.com, Peter Zijlstra , Russell King - ARM Linux , iamjoonsoo.kim@lge.com, treding@nvidia.com, Kees Cook , Marek Szyprowski , stefanr@s5r6.in-berlin.de, hjc@rock-chips.com, Heiko Stuebner , airlied@linux.ie, oleksandr_andrushchenko@epam.com, joro@8bytes.org, pawel@osciak.com, Kyungmin Park , mchehab@kernel.org, Boris Ostrovsky , Juergen Gross , linux-kernel@vger.kernel.org, Linux-MM , linux-arm-kernel@lists.infradead.org, linux1394-devel@lists.sourceforge.net, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, xen-devel@lists.xen.org, iommu@lists.linux-foundation.org, linux-media@vger.kernel.org References: <20181206183945.GA20932@jordon-HP-15-Notebook-PC> <53bbc095-c9f5-5d6a-6e50-6e060d17eb68@arm.com> <20181207171116.GA29923@bombadil.infradead.org> From: Robin Murphy Message-ID: <67495f8f-2092-e42d-321e-5216c346513f@arm.com> Date: Fri, 7 Dec 2018 21:10:00 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:60.0) Gecko/20100101 Thunderbird/60.3.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-12-07 7:28 pm, Souptick Joarder wrote: > On Fri, Dec 7, 2018 at 10:41 PM Matthew Wilcox wrote: >> >> On Fri, Dec 07, 2018 at 03:34:56PM +0000, Robin Murphy wrote: >>>> +int vm_insert_range(struct vm_area_struct *vma, unsigned long addr, >>>> + struct page **pages, unsigned long page_count) >>>> +{ >>>> + unsigned long uaddr = addr; >>>> + int ret = 0, i; >>> >>> Some of the sites being replaced were effectively ensuring that vma and >>> pages were mutually compatible as an initial condition - would it be worth >>> adding something here for robustness, e.g.: >>> >>> + if (page_count != vma_pages(vma)) >>> + return -ENXIO; >> >> I think we want to allow this to be used to populate part of a VMA. >> So perhaps: >> >> if (page_count > vma_pages(vma)) >> return -ENXIO; > > Ok, This can be added. > > I think Patch [2/9] is the only leftover place where this > check could be removed. Right, 9/9 could also have relied on my stricter check here, but since it's really testing whether it actually managed to allocate vma_pages() worth of pages earlier, Matthew's more lenient version won't help for that one. (Why privcmd_buf_mmap() doesn't clean up and return an error as soon as that allocation loop fails, without taking the mutex under which it still does a bunch more pointless work to only undo it again, is a mind-boggling mystery, but that's not our problem here...) Robin.