Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1074817imu; Fri, 7 Dec 2018 13:46:19 -0800 (PST) X-Google-Smtp-Source: AFSGD/UBYG56LAijbV03t541cWSqF52iZ8FMYeHniHbqO84jVLlSIjIwlRyM7nPsovWhZeiAq7M0 X-Received: by 2002:a63:8441:: with SMTP id k62mr3408051pgd.392.1544219179098; Fri, 07 Dec 2018 13:46:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544219179; cv=none; d=google.com; s=arc-20160816; b=lWISfrDmuZHaseJDQEy17BHaHwxbfugcqsHxyVdL8od9/TYvEj+lFZML5pkWNWudq4 zp/zkxhfQ3NmioUge7e76tzc1Qxp0XhyRM41Gj34faAFDHd4lZC3iaZwChE4NEcRG2s9 LeH15us7MT/2V0qtPY/feITokTpk1PbSc+e8YMt/rmahofo2FSitCk2mjAYyF7sREH67 vMo6r1lNdT/7VmDaqr2EuYzTHJVMWhaLLZOIW1yySE8STf2rRz8h16ZgnLhrq6i24GnL z0mIZdTzjn5tms4noeO5EL6uHd3umZ6fcb3OfOOi1JwHsaBb9MGgrI101OF7Ou35CsX0 Y5sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=v6KpxNhJmlXUycYQajdCWj2sFrZIkqlDQLw4h1pTRk8=; b=BXy0kKgR8TMXdSAhPOCaaPVNvyDXvI7M2KVijy1amfNm0kwtio7cW04W5YTU7+mMcI Ld9mwl2mitWNmXWynawfJGdkw93NaCTpBbVgXK/WXJ5lpGSm5aMvBF+Z5B6Q+9Q5NiXz WllT22kEGwfn2t7e+7lW05kV1tNNcWPEQFLigBT3LYdUDPmrAPr2PPjFmE66OZd0ELXZ HQBL3rOzCav+9A7OPkyllN4DWXcfJftwWNSRN2ZXi+or35WHjHrztCPQkj65/AWdOIvC GnuxyoNzvOgX5hYTbwvm3YEfTFxPhZEDrXc+QiQYuVPUrvoZ/7+rH9edwg9wO6PmCewB 29Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ipmNs0vN; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d19si4460062pfd.281.2018.12.07.13.46.03; Fri, 07 Dec 2018 13:46:19 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ipmNs0vN; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726090AbeLGVpR (ORCPT + 99 others); Fri, 7 Dec 2018 16:45:17 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:33129 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726008AbeLGVpQ (ORCPT ); Fri, 7 Dec 2018 16:45:16 -0500 Received: by mail-lj1-f195.google.com with SMTP id v1-v6so4824937ljd.0; Fri, 07 Dec 2018 13:45:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=v6KpxNhJmlXUycYQajdCWj2sFrZIkqlDQLw4h1pTRk8=; b=ipmNs0vN037Cl5mH4fVf3ttZCVpQb/9Zld0Lkafz8Hbbo90MYs8acI6L5OpSFJxaW3 NuFIVq89n+RQB95eqVngvZc1bQPEIb77dxGHnJss6F0qQblkGWQKXumuHBQbh8kw+Pfd 3/K0hNQprlIJGICL+7alaFrZ3Z2v2TlTjVc5In/VXdKgMGqVOfy4DcESgBnfEpfSkD8Q CS+/197PnoXgoa+YJq8kvN+LBSGjUpJ0O93FRXM2PTZARwFtFZf8uWXHjIM8xzvXrila K5YT5DJoNt48G/JUUvwx4XDAKl38hLSP20n9jY8+hpjApMF8Sg0qHyrGAn5/iI3/ITQ4 gxAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=v6KpxNhJmlXUycYQajdCWj2sFrZIkqlDQLw4h1pTRk8=; b=UYiJMP3/0OPJe2/gjpyN0lj7waQv7EKvd5vhkqXXpogtnmdM6ImT9Lz7wnFeqwZRo4 ZYEDqHYgmfttEv7Gh59VnW73eWlDLj+lapkxKt9lI0+vV9SscycwleDXu7vYC0dY7RvV x4S+TA3LgUbrxaE59Yip0l6wgGQGkKh6PtGMk2TA8LpV1a0fzVJTD1QBHWTGL1WyN076 UPc3CAJZ+9WMUyAJsDiN1mW8231ok3hEbYvCyfATnl4XHK3vbCCv0mN0Iw6PmSpYeMBi zxeOKqmTkFT2uyRlPP/jSrhR9e6sSUJTjO4vM9lVcfkJSM8FA/yiN1MmsCcuspZ1HsjH uthA== X-Gm-Message-State: AA+aEWayFOQiqECBqRTJbcnm9ZvzZ2sphXFhgkNKjM0N6apUQQMvzAB2 DiOS6WuKy6Ns/oHHq8yYvjw2/0JcXgDIEgc2m3I= X-Received: by 2002:a2e:9f0b:: with SMTP id u11-v6mr2011980ljk.99.1544219113588; Fri, 07 Dec 2018 13:45:13 -0800 (PST) MIME-Version: 1.0 References: <20181206183945.GA20932@jordon-HP-15-Notebook-PC> <53bbc095-c9f5-5d6a-6e50-6e060d17eb68@arm.com> <20181207171116.GA29923@bombadil.infradead.org> <67495f8f-2092-e42d-321e-5216c346513f@arm.com> In-Reply-To: <67495f8f-2092-e42d-321e-5216c346513f@arm.com> From: Souptick Joarder Date: Sat, 8 Dec 2018 03:18:49 +0530 Message-ID: Subject: Re: [PATCH v3 1/9] mm: Introduce new vm_insert_range API To: robin.murphy@arm.com Cc: Matthew Wilcox , 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Dec 8, 2018 at 2:40 AM Robin Murphy wrote: > > 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...) I think some clean up can be done here in a separate patch.