Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp961167img; Mon, 18 Mar 2019 19:26:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZGvpMdwqQQvjRiM4jPtFXpHUcvVs2IKVwxjWTdCvgICCA8KANNesdbT8oqSzGftouQZ/B X-Received: by 2002:a63:204c:: with SMTP id r12mr6672768pgm.414.1552962394283; Mon, 18 Mar 2019 19:26:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552962394; cv=none; d=google.com; s=arc-20160816; b=NTd/WGrxlzO+XeqS9DfplV9XI10WMDvCI75gLQg5Out0lJpeHFiYjRsOllc3Hd5RK/ RKqJaEnhUgmdbphHYZTuNYHiLkKKqt+cXxLje1hdgeraLCbA/jw8WXmg8dRb4nDjXAj8 U5yzwCZO/2Axqd+DnK72qyisX5Ic3egTpa2HfLrEnUITkNUcMjr3qGn74mbMi3EudQwJ piU4pH5//ubwm7ynfLWJHFEDVR/2HwfD0fIkA5/xSjpvgYe48zJoShCkRNrSUEoTTFNQ 7/Gi0UWRPzfg7wKfbyXj59lul/kZDmDPzPGkoTVSsanCnqmh6aws0oP0RE+2e+xN7fX3 f1rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=n/NDS47nz9uuNytg4LeJJ+li959uQqsTwzm1mhrxiWA=; b=phPhEuc6rSL1kUa1xZmiurpxMxPTgkWV9lOR85Me/TlhO0MtTYU7cb//s8B3RTmcFj fXgSkb0At/i9xNBWHevVchyPchLWfVK1PpguY2JLPN1mkWGCpvZRotJYQjtiaFvuhLBz DLDmPCn0GsQGorx/aCnPqAv5MUDUY9TEjyMG+tyh+xMKpbAOPHQZsmcBxPARH2vfKLAz RhJpE3++/rVflLyqWCCXnFJnJvCXORqS/uVBZdHsT9AjibKwbZo07NvMLaAeINiRKl/Q Ko8Sc8amAOkyHI+dSbc4B044ZCucV6SdCmH54HJJUpjKitlprlkPly/Ryjy0mRJr22kO vvdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jiBtkKML; 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 h11si11556778plb.38.2019.03.18.19.26.19; Mon, 18 Mar 2019 19:26:34 -0700 (PDT) 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=jiBtkKML; 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 S1727617AbfCSCZe (ORCPT + 99 others); Mon, 18 Mar 2019 22:25:34 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:46680 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726884AbfCSCZd (ORCPT ); Mon, 18 Mar 2019 22:25:33 -0400 Received: by mail-pf1-f193.google.com with SMTP id s23so12582870pfe.13 for ; Mon, 18 Mar 2019 19:25:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=n/NDS47nz9uuNytg4LeJJ+li959uQqsTwzm1mhrxiWA=; b=jiBtkKMLnhknyJBqO0pykSJ1rbddZqUTZxiCQSo/SQdWsCg6rLr0Cy1/XcNb01JLUe arpg6kvnCyN5mQVoBrYIXH3jjsPbg038amLqb/8cOmOdXYXMUoJGico4viaD0NRc4vzS tqNZi/bzEiId0TsLouzvEpgHrIloi0yxX3b5HKTc68Ot8AOc22832Bwi6kZpXbWljicc Z6NmfIIGCh7KJixA06QsQBncUA/fr0iFgC3sIQ2960zrQ/E63Zzk79r1DAeIZ/RVs56o Z92k7Ksf6tDBHwMo12HW/o2rx8yQUNX35Sfm4tjZIIcRXJ2dzt3xtZBPd9C4QamrFLr+ ZhPw== 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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=n/NDS47nz9uuNytg4LeJJ+li959uQqsTwzm1mhrxiWA=; b=UlTDhVEMuOX8O/Qb5u2+/61ItnumDTQBLIkWxcGNzgQ95RBLuNO3QVs6O/PAhLGknr QXlUHZkeutdtDa0byuJ3uzkjgJ6d9Zkw0EUXyybmYVp++7vFO59ALkC9TuLZwAHnaanm +4WiZnKjgCA6VV5f6CYHAAL2Yls1Wz1N9FlmT3SQXcbM49zOoTzTxCIKL3Y5k/1SaeYa ofF2amWisLxOIWmx6SmyvtC0QPLvwGI99x42bSQH2IJXm1SORRPwR0CmDGDCNAnL/6qp ErP2drPB8wVCYFXPeilFrINVXpdQhOCJZFZP98MglYpN6HNSiTfqgyYBTdkW+wTC0mYU qmsg== X-Gm-Message-State: APjAAAXmhEnA96tfxMh33t601aRsQq2yfDI1zRWLC3L+UIhzS7+UiiRG zt0feq6fg86ycpxcblRZzp0= X-Received: by 2002:a63:ff0f:: with SMTP id k15mr7714pgi.301.1552962332881; Mon, 18 Mar 2019 19:25:32 -0700 (PDT) Received: from jordon-HP-15-Notebook-PC ([106.51.22.39]) by smtp.gmail.com with ESMTPSA id b17sm3327180pgj.79.2019.03.18.19.25.31 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Mar 2019 19:25:32 -0700 (PDT) Date: Tue, 19 Mar 2019 08:00:07 +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: [RESEND PATCH v4 8/9] xen/gntdev.c: Convert to use vm_map_pages() Message-ID: <88e56e82d2db98705c2d842e9c9806c00b366d67.1552921225.git.jrdr.linux@gmail.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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