From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:59347 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750848AbbLFFvR (ORCPT ); Sun, 6 Dec 2015 00:51:17 -0500 Subject: Patch "ARM: 8426/1: dma-mapping: add missing range check in dma_mmap()" has been added to the 3.10-stable tree To: m.szyprowski@samsung.com, gregkh@linuxfoundation.org, rmk+kernel@arm.linux.org.uk Cc: , From: Date: Sat, 05 Dec 2015 21:51:17 -0800 Message-ID: <1449381077105108@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled ARM: 8426/1: dma-mapping: add missing range check in dma_mmap() to the 3.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: arm-8426-1-dma-mapping-add-missing-range-check-in-dma_mmap.patch and it can be found in the queue-3.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >>From 371f0f085f629fc0f66695f572373ca4445a67ad Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Fri, 28 Aug 2015 09:41:39 +0100 Subject: ARM: 8426/1: dma-mapping: add missing range check in dma_mmap() From: Marek Szyprowski commit 371f0f085f629fc0f66695f572373ca4445a67ad upstream. dma_mmap() function in IOMMU-based dma-mapping implementation lacked a check for valid range of mmap parameters (offset and buffer size), what might have caused access beyond the allocated buffer. This patch fixes this issue. Signed-off-by: Marek Szyprowski Signed-off-by: Russell King Signed-off-by: Greg Kroah-Hartman --- arch/arm/mm/dma-mapping.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1355,12 +1355,17 @@ static int arm_iommu_mmap_attrs(struct d unsigned long uaddr = vma->vm_start; unsigned long usize = vma->vm_end - vma->vm_start; struct page **pages = __iommu_get_pages(cpu_addr, attrs); + unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT; + unsigned long off = vma->vm_pgoff; vma->vm_page_prot = __get_dma_pgprot(attrs, vma->vm_page_prot); if (!pages) return -ENXIO; + if (off >= nr_pages || (usize >> PAGE_SHIFT) > nr_pages - off) + return -ENXIO; + do { int ret = vm_insert_page(vma, uaddr, *pages++); if (ret) { Patches currently in stable-queue which might be from m.szyprowski@samsung.com are queue-3.10/arm-8427-1-dma-mapping-add-support-for-offset-parameter-in-dma_mmap.patch queue-3.10/arm-8426-1-dma-mapping-add-missing-range-check-in-dma_mmap.patch