Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1822002imu; Thu, 17 Jan 2019 03:57:16 -0800 (PST) X-Google-Smtp-Source: ALg8bN63+8/LLs1cLojvm0QCVaX7cNMW4f8oUT5mUc4p99KypU5LB3tjSlF+XsekPIV8M+gDMkav X-Received: by 2002:a63:194f:: with SMTP id 15mr13323551pgz.192.1547726236262; Thu, 17 Jan 2019 03:57:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547726236; cv=none; d=google.com; s=arc-20160816; b=tUT5G9jSgh5i3CqUiRGew4qzz1AcyDZvoLdVnNkNKHedBjePrcw3MCXHFdY8IkBSxD 1y0iTkIweh0C8nE7i6KsN+CexhBL0pJ15CY9lSQHf4mmZdWKWhzIx/xRKmw0kja16BD8 fRcLRSPJhEziMn2mg8hFw9emP2GyJqXtqaH5r7Jetfs17zvjf7jLG1D85zn1Xx4o518+ inw6RK6BTvOVZoiQ27cM1a2IjDc/QQTwDvv0H3/ROHjQiD5ddjCicS+VybHuYPudbRUU BBibDYfKsojrBAwh5uLHDc5bOEJjMVh7nrGJ50DLMEWlUiXBgdRKyUb9U/QBXJlh5J3T 3g+A== 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=RqoIkotrN3l6oMAC+JrcBK/f6kX7mxLOSugmUX8akyw=; b=PB3PMuizpjWWBPW9kX7pIM5yxZzGM27fXSQv+GUmcdEwq12IBS2N4j5DfK6VXtXbz3 cyPkK5Nm8+uOBi3KhHVsKwuVLfgKgg5SGTlLieU2UBhwNJbqIH4DZ84Dp+i3Y6M2opkL w8LIzJ6NehA2rFiPsALYfgfDyVL2H6bsl18TNaHU0Yvbd5kOBLsNxQQrvxDEzLCh2lpF b3iK4YbywpgEGIIlj8e2rp9X+RbyvtRDoDkiN5Dp3uBYwZ6TLLy80jnAsndLDYkJW30j ueUR10XFp6KADCj3clIxthoGRztUs6o6LlLjzwqAiuGVNHbsl+ZfiGbhC63K9MG2cV8P I16A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DayZQjEB; 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 e11si1432343pfh.147.2019.01.17.03.57.00; Thu, 17 Jan 2019 03:57:16 -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=DayZQjEB; 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 S1728080AbfAQLj6 (ORCPT + 99 others); Thu, 17 Jan 2019 06:39:58 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:37716 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725868AbfAQLj6 (ORCPT ); Thu, 17 Jan 2019 06:39:58 -0500 Received: by mail-lj1-f194.google.com with SMTP id t18-v6so8310953ljd.4; Thu, 17 Jan 2019 03:39:56 -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=RqoIkotrN3l6oMAC+JrcBK/f6kX7mxLOSugmUX8akyw=; b=DayZQjEBT5kOQpoGi2VFE+Lz9tTTebqwjWOtbR16+0ebGzGyTuopZskDO46rrePAbK BFC5JdciMoAWC9h7PJlZzQQ0ky6VS3J8892IWikOgujLnSbBE6TgeASgyluAhMvzn9D2 AYZH+Gl/sQpeZAldKkNZ98b2mgEIDv9JueHq6yx86dBIzzP45DzORgxhjZF4+fiRweno imcNTDVw0ARgn2BvsyYZg+T/7ACPSpZZ8XovYCZ/Du+R1YTGAjk3caOSZqw9uj8li7fm FChxRc6CELYunH8+CjDkMxH72RK/c1lod6sd10VCbMjLbrqxbBpFigRZfKC1GoznVbl6 K85w== 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=RqoIkotrN3l6oMAC+JrcBK/f6kX7mxLOSugmUX8akyw=; b=pSoiHgyPrYHx972x9TXuhmIeGXw3qoXz2D59JhY5mX5GEnXc5bbi770kNnW1BKNzd1 mPk3JC92zlXMatnLrQUIRp4JtcM5HcSXARSGPJd+kg3ziw65jLK3HzQUONsD5V+y3pnO MDEuRDFOoUAJ6+ojkVFoztZaO/5o1zRc6czYaYBVqif+jvQLC+Or+GsjOVOAZqU79N73 IsikI69xLcMWhqF3jT3Qw1o/o/Tzq2Hc9Rs80O/CYeirIU3T3+V3wina34EWcvw2p8bF yd8KDYOHk8TEPu9QMfjPAK5weT3bJzARMN8Dntl2G9vuizuTui0kTlAM9H6XTCcx33B6 3B2Q== X-Gm-Message-State: AJcUukeNpa7iNi3sPQ810ajBtdvRuemSUgeGHaeK2xOHpqPQngtM+tYN 5oPmk8b6yEo/EAgnu9xnjEEps0FgSeDBmWz3QUY= X-Received: by 2002:a2e:4601:: with SMTP id t1-v6mr9974371lja.111.1547725195689; Thu, 17 Jan 2019 03:39:55 -0800 (PST) MIME-Version: 1.0 References: <20190111150541.GA2670@jordon-HP-15-Notebook-PC> In-Reply-To: <20190111150541.GA2670@jordon-HP-15-Notebook-PC> From: Souptick Joarder Date: Thu, 17 Jan 2019 17:09:43 +0530 Message-ID: Subject: Re: [PATCH 0/9] Use vm_insert_range and vm_insert_range_buggy To: Andrew Morton , Matthew Wilcox , Michal Hocko , "Kirill A. Shutemov" , vbabka@suse.cz, Rik van Riel , Stephen Rothwell , rppt@linux.vnet.ibm.com, Peter Zijlstra , Russell King - ARM Linux , robin.murphy@arm.com, 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 Cc: 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 Fri, Jan 11, 2019 at 8:31 PM Souptick Joarder wrote: > > Previouly drivers have their own way of mapping range of > kernel pages/memory into user vma and this was done by > invoking vm_insert_page() within a loop. > > As this pattern is common across different drivers, it can > be generalized by creating new functions and use it across > the drivers. > > vm_insert_range() is the API which could be used to mapped > kernel memory/pages in drivers which has considered vm_pgoff > > vm_insert_range_buggy() is the API which could be used to map > range of kernel memory/pages in drivers which has not considered > vm_pgoff. vm_pgoff is passed default as 0 for those drivers. > > We _could_ then at a later "fix" these drivers which are using > vm_insert_range_buggy() to behave according to the normal vm_pgoff > offsetting simply by removing the _buggy suffix on the function > name and if that causes regressions, it gives us an easy way to revert. > > There is an existing bug in [7/9], where user passed length is not > verified against object_count. For any value of length > object_count > it will end up overrun page array which could lead to a potential bug. > This is fixed as part of these conversion. > > Souptick Joarder (9): > mm: Introduce new vm_insert_range and vm_insert_range_buggy API > arch/arm/mm/dma-mapping.c: Convert to use vm_insert_range > drivers/firewire/core-iso.c: Convert to use vm_insert_range_buggy > drm/rockchip/rockchip_drm_gem.c: Convert to use vm_insert_range > drm/xen/xen_drm_front_gem.c: Convert to use vm_insert_range > iommu/dma-iommu.c: Convert to use vm_insert_range > videobuf2/videobuf2-dma-sg.c: Convert to use vm_insert_range_buggy > xen/gntdev.c: Convert to use vm_insert_range > xen/privcmd-buf.c: Convert to use vm_insert_range_buggy Any further comment on these patches ? > > arch/arm/mm/dma-mapping.c | 22 ++---- > drivers/firewire/core-iso.c | 15 +---- > drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 17 +---- > drivers/gpu/drm/xen/xen_drm_front_gem.c | 18 ++--- > drivers/iommu/dma-iommu.c | 12 +--- > drivers/media/common/videobuf2/videobuf2-dma-sg.c | 22 ++---- > drivers/xen/gntdev.c | 16 ++--- > drivers/xen/privcmd-buf.c | 8 +-- > include/linux/mm.h | 4 ++ > mm/memory.c | 81 +++++++++++++++++++++++ > mm/nommu.c | 14 ++++ > 11 files changed, 129 insertions(+), 100 deletions(-) > > -- > 1.9.1 >