linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Bob Liu <lliubbo@gmail.com>
Cc: linux-mm@kvack.org, bhupesh.sharma@st.com,
	laurent.pinchart@ideasonboard.com,
	uclinux-dist-devel@blackfin.uclinux.org,
	linux-media@vger.kernel.org, dhowells@redhat.com,
	geert@linux-m68k.org, gerg@uclinux.org, stable@kernel.org,
	gregkh@linuxfoundation.org, Hugh Dickins <hughd@google.com>
Subject: Re: [PATCH] nommu: remap_pfn_range: fix addr parameter check
Date: Thu, 13 Sep 2012 12:27:38 -0700	[thread overview]
Message-ID: <20120913122738.04eaceb3.akpm@linux-foundation.org> (raw)
In-Reply-To: <1347504057-5612-1-git-send-email-lliubbo@gmail.com>

On Thu, 13 Sep 2012 10:40:57 +0800
Bob Liu <lliubbo@gmail.com> wrote:

> The addr parameter may not page aligned eg. when it's come from
> vfb_mmap():vma->vm_start in video driver.
> 
> This patch fix the check in remap_pfn_range() else some driver like v4l2 will
> fail in this function while calling mmap() on nommu arch like blackfin and st.
> 
> Reported-by: Bhupesh SHARMA <bhupesh.sharma@st.com>
> Reported-by: Scott Jiang <scott.jiang.linux@gmail.com>
> Signed-off-by: Bob Liu <lliubbo@gmail.com>
> ---
>  mm/nommu.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/nommu.c b/mm/nommu.c
> index d4b0c10..5d6068b 100644
> --- a/mm/nommu.c
> +++ b/mm/nommu.c
> @@ -1819,7 +1819,7 @@ struct page *follow_page(struct vm_area_struct *vma, unsigned long address,
>  int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr,
>  		unsigned long pfn, unsigned long size, pgprot_t prot)
>  {
> -	if (addr != (pfn << PAGE_SHIFT))
> +	if ((addr & PAGE_MASK) != (pfn << PAGE_SHIFT))
>  		return -EINVAL;
>  
>  	vma->vm_flags |= VM_IO | VM_RESERVED | VM_PFNMAP;

hm, what is the right thing to do here?

Yes, the MMU version of remap_pfn_range() does permit non-page-aligned
`addr' (at least, if the userspace maaping is a non-COW one).  But I
suspect that was an implementation accident - it is a nonsensical thing
to do, isn't it?  The MMU cannot map a bunch of kernel pages onto a
non-page-aligned userspace address.

So I'm thinking that we should declare ((addr & ~PAGE_MASK) != 0) to be
a caller bug, and fix up this regrettably unidentified v4l driver?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2012-09-13 19:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-13  2:40 [PATCH] nommu: remap_pfn_range: fix addr parameter check Bob Liu
2012-09-13 19:27 ` Andrew Morton [this message]
2012-09-14  9:23   ` Scott Jiang
2012-09-14 10:15     ` Bhupesh SHARMA
2012-09-14 10:39     ` Bhupesh SHARMA
2012-09-17  6:02       ` Scott Jiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120913122738.04eaceb3.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=bhupesh.sharma@st.com \
    --cc=dhowells@redhat.com \
    --cc=geert@linux-m68k.org \
    --cc=gerg@uclinux.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hughd@google.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lliubbo@gmail.com \
    --cc=stable@kernel.org \
    --cc=uclinux-dist-devel@blackfin.uclinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).