Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp209265imj; Thu, 14 Feb 2019 18:45:12 -0800 (PST) X-Google-Smtp-Source: AHgI3IZvTo89+gfiiraO4wgE8fcmmN90Fqq02r1aXUjcX2E9p8wuDTBVb+oQfuUvZ/aKOQnZhZcJ X-Received: by 2002:aa7:8212:: with SMTP id k18mr7502347pfi.48.1550198712060; Thu, 14 Feb 2019 18:45:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550198712; cv=none; d=google.com; s=arc-20160816; b=pk+YMJB6XJVw6yUt1TnChkT+HcfDWsie8Ei57xt+0EY/lSVCauwKHGazJ1+mBPgh/B fTBnGZ4Gn7UXfs1d1Yt/6vSijyqMGFFFysUKlQuBXkObgJ9ztN4VquVBdfcFk3jngx0c 3uIQce62R24i+uU3wZwaOvbwDCNwpO7MK2aRDalzrajChJeiy1T+f4ojCVvhKAZdHqeF hfqEPT11eJwTp7d0Yg64Mwu89/7B3KRG0+vZFHCSEvbSIbjg12Nx1clqOXhLVhN8pRpF SNF5mdBVlF4BebcDdf6xrjcw42r8rJVfywn/idVrfY5v5Xv6XqWX+0rLyIC30K2SNeDJ +1pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=n/NDS47nz9uuNytg4LeJJ+li959uQqsTwzm1mhrxiWA=; b=te+cBq22wmQy7JMTOmclmSzE1pEzWrnxD9PorIT3fYTVata/EExZ+lgcf319E1AkQQ pqXQ9mRuPUZx2izXODMEKpGtxjzGxELgNG1UjOksvf0O9RpIEN23yuqLZkn+RMhIxCI1 r7/enWEVbPmqGs7IO7NsDuZzxvZwfsJK+2XcIupwbtXdSOHSFNYhy7Q4aiNffi36+Gm4 k836HzBKZCVxJNdjtHqBQLAFcY8TocATGLlc2SbbFd+qZwxCeNiusmZM/qJEj8nXWGHn +9iNG24UohLW5CA16tgZEprA1Vdps537fl22+i1ow31rFVHvZvHo6azQMihXlGBqhnw3 dzIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Vt8nidr0; 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 a81si4137603pfj.195.2019.02.14.18.44.56; Thu, 14 Feb 2019 18:45:12 -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=Vt8nidr0; 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 S1729759AbfBOCoM (ORCPT + 99 others); Thu, 14 Feb 2019 21:44:12 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:43567 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728562AbfBOCoL (ORCPT ); Thu, 14 Feb 2019 21:44:11 -0500 Received: by mail-pf1-f196.google.com with SMTP id q17so4085116pfh.10 for ; Thu, 14 Feb 2019 18:44:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=n/NDS47nz9uuNytg4LeJJ+li959uQqsTwzm1mhrxiWA=; b=Vt8nidr0rK41Os0HWq4+4aF062X7h4v6mHNSGJrNppzhNDwX047qRWP5LTYUmhuLuy Iqtt/oPfQUVesoOPfP5pR37mpT+P5HeBjY/N3FdmN8Wc13V9Ij1VlOFDdTG1KkCD9Y9h LQKENgYLW/iXqE4T1/ZrhykWcCV8gemdxOrir5XOiDFzPc11Wj4/BnVAjWyDbTbpt0ta VbW+K/iPDsPHPWxg6IhMue9P7ETAnU+10BQ5VBAg8a1B0RRapCC5H5wh6eFntrZbvsCk v7WtGBOaFUVs6JL1Q2xUIeJxfF53otn17DmHM7ufjAiDUwRCJGfexUeqg6ur38YrawW0 RvyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=n/NDS47nz9uuNytg4LeJJ+li959uQqsTwzm1mhrxiWA=; b=mOzVepukSoRFN9W4OirTJbo2MzfyFo1I+HF68L/N7+vS3xaa7U/8YcQfFTHvfe4D7E NotZ2S19SpjjWg3302rGoFkYXNLBHOEIgshPuDWLDcgmHfuWV+oArF3jwbUslLcX+rFp wDpg0P83ZLTKWGOPbDNyx1K4Uql9wDtw0a/pJFbzNQRc8vA9xwFJqyZNm1Efekui5iyQ meeZrKZqxrAEai8axwQslwvgIZLaAgwumIKsz1H2mQ2jyEcKpY6lYSZBjvLMEdLAUaRe T8WRmeqpNcFc77sFWOXF8CI4LkBDiRJ+1gxFWSWg6sIBle2je25opS4FZ3i3Bgu+eBf6 mgVw== X-Gm-Message-State: AHQUAuZ669TJInECKUgdPmKcUIw/aKisH3KQ5jCQSXlWhV6+Gsfm7SSq WacbDz9cMrtH5dYRFL+gHdE= X-Received: by 2002:a65:5003:: with SMTP id f3mr3127549pgo.39.1550198650905; Thu, 14 Feb 2019 18:44:10 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.53.51]) by smtp.gmail.com with ESMTPSA id u8sm6577915pfl.16.2019.02.14.18.44.09 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Feb 2019 18:44:10 -0800 (PST) Date: Fri, 15 Feb 2019 08:18:31 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, boris.ostrovsky@oracle.com, jgross@suse.com, linux@armlinux.org.uk, robin.murphy@arm.com Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v4 8/9] xen/gntdev.c: Convert to use vm_map_pages() Message-ID: <20190215024830.GA26477@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Convert to use vm_map_pages() to map range of kernel memory to user vma. map->count is passed to vm_map_pages() and internal API verify map->count against count ( count = vma_pages(vma)) for page array boundary overrun condition. Signed-off-by: Souptick Joarder Reviewed-by: Boris Ostrovsky --- drivers/xen/gntdev.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index 5efc5ee..5d64262 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c @@ -1084,7 +1084,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma) int index = vma->vm_pgoff; int count = vma_pages(vma); struct gntdev_grant_map *map; - int i, err = -EINVAL; + int err = -EINVAL; if ((vma->vm_flags & VM_WRITE) && !(vma->vm_flags & VM_SHARED)) return -EINVAL; @@ -1145,12 +1145,9 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma) goto out_put_map; if (!use_ptemod) { - for (i = 0; i < count; i++) { - err = vm_insert_page(vma, vma->vm_start + i*PAGE_SIZE, - map->pages[i]); - if (err) - goto out_put_map; - } + err = vm_map_pages(vma, map->pages, map->count); + if (err) + goto out_put_map; } else { #ifdef CONFIG_X86 /* -- 1.9.1