From patchwork Mon Jul 21 21:21:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Mostafa X-Patchwork-Id: 372259 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id A19E2140092; Tue, 22 Jul 2014 07:25:21 +1000 (EST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1X9L5C-00027I-My; Mon, 21 Jul 2014 21:25:18 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1X9L1d-0000N1-4C for kernel-team@lists.ubuntu.com; Mon, 21 Jul 2014 21:21:37 +0000 Received: from c-67-160-228-185.hsd1.ca.comcast.net ([67.160.228.185] helo=fourier) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1X9L1c-0007Ip-Gu; Mon, 21 Jul 2014 21:21:36 +0000 Received: from kamal by fourier with local (Exim 4.82) (envelope-from ) id 1X9L1a-0000HB-It; Mon, 21 Jul 2014 14:21:34 -0700 From: Kamal Mostafa To: Linus Torvalds Subject: [3.8.y.z extended stable] Patch "uio: we cannot mmap unaligned page contents" has been added to staging queue Date: Mon, 21 Jul 2014 14:21:34 -0700 Message-Id: <1405977694-1030-1-git-send-email-kamal@canonical.com> X-Mailer: git-send-email 1.9.1 X-Extended-Stable: 3.8 Cc: Greg KH , Kamal Mostafa , Holger Brunck , kernel-team@lists.ubuntu.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com This is a note to let you know that I have just added a patch titled uio: we cannot mmap unaligned page contents to the linux-3.8.y-queue branch of the 3.8.y.z extended stable tree which can be found at: http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.8.y-queue This patch is scheduled to be released in version 3.8.13.27. If you, or anyone else, feels it should not be added to this tree, please reply to this email. For more information about the 3.8.y.z tree, see https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable Thanks. -Kamal ------ From 3bd1259a3aca0eb2077329ce190f3c6e8ae4c9d0 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 2 Dec 2013 11:50:37 -0800 Subject: uio: we cannot mmap unaligned page contents commit b65502879556d041b45104c6a35abbbba28c8f2d upstream. In commit 7314e613d5ff ("Fix a few incorrectly checked [io_]remap_pfn_range() calls") the uio driver started more properly checking the passed-in user mapping arguments against the size of the actual uio driver data. That in turn exposed that some driver authors apparently didn't realize that mmap can only work on a page granularity, and had tried to use it with smaller mappings, with the new size check catching that out. So since it's not just the user mmap() arguments that can be confused, make the uio mmap code also verify that the uio driver has the memory allocated at page boundaries in order for mmap to work. If the device memory isn't properly aligned, we return [ENODEV] The fildes argument refers to a file whose type is not supported by mmap(). as per the open group documentation on mmap. Reported-by: Holger Brunck Acked-by: Greg KH Signed-off-by: Linus Torvalds Signed-off-by: Kamal Mostafa --- drivers/uio/uio.c | 2 ++ 1 file changed, 2 insertions(+) -- 1.9.1 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 96f1359..9981b9b 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -655,6 +655,8 @@ static int uio_mmap_physical(struct vm_area_struct *vma) return -EINVAL; mem = idev->info->mem + mi; + if (mem->addr & ~PAGE_MASK) + return -ENODEV; if (vma->vm_end - vma->vm_start > mem->size) return -EINVAL;