From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_NEOMUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3065C072B5 for ; Fri, 24 May 2019 09:47:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 95FFD20815 for ; Fri, 24 May 2019 09:47:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390222AbfEXJrx (ORCPT ); Fri, 24 May 2019 05:47:53 -0400 Received: from retiisi.org.uk ([95.216.213.190]:49866 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389841AbfEXJrx (ORCPT ); Fri, 24 May 2019 05:47:53 -0400 Received: from valkosipuli.localdomain (valkosipuli.retiisi.org.uk [IPv6:2a01:4f9:c010:4572::80:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by hillosipuli.retiisi.org.uk (Postfix) with ESMTPS id 82CB3634C7B; Fri, 24 May 2019 12:47:22 +0300 (EEST) Received: from sailus by valkosipuli.localdomain with local (Exim 4.89) (envelope-from ) id 1hU6nK-00018F-C3; Fri, 24 May 2019 12:47:22 +0300 Date: Fri, 24 May 2019 12:47:22 +0300 From: Sakari Ailus To: "Andrew F. Davis" Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] [media] videobuf-dma-contig: Use size of buffer in mmap not vma size Message-ID: <20190524094722.sjzk6hwfgjigxix6@valkosipuli.retiisi.org.uk> References: <20190329173427.18238-1-afd@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190329173427.18238-1-afd@ti.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 29, 2019 at 12:34:27PM -0500, Andrew F. Davis wrote: > The size of the vma can be larger than the size of the backing buffer. > Use the buffer size over vma size to prevent exposing extra memory > to userspace. > > Signed-off-by: Andrew F. Davis Reviewed-by: Sakari Ailus > --- > drivers/media/v4l2-core/videobuf-dma-contig.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/media/v4l2-core/videobuf-dma-contig.c b/drivers/media/v4l2-core/videobuf-dma-contig.c > index e1bf50df4c70..65e2655d22b7 100644 > --- a/drivers/media/v4l2-core/videobuf-dma-contig.c > +++ b/drivers/media/v4l2-core/videobuf-dma-contig.c > @@ -280,7 +280,6 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, > struct videobuf_dma_contig_memory *mem; > struct videobuf_mapping *map; > int retval; > - unsigned long size; > > dev_dbg(q->dev, "%s\n", __func__); > > @@ -303,7 +302,6 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, > goto error; > > /* Try to remap memory */ > - size = vma->vm_end - vma->vm_start; > vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); > > /* the "vm_pgoff" is just used in v4l2 to find the > @@ -314,7 +312,7 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, > */ > vma->vm_pgoff = 0; > > - retval = vm_iomap_memory(vma, mem->dma_handle, size); > + retval = vm_iomap_memory(vma, mem->dma_handle, mem->size); > if (retval) { > dev_err(q->dev, "mmap: remap failed with error %d. ", > retval); > -- > 2.21.0 > -- Sakari Ailus