Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1309880 > unrolled thread

[PATCH] mm: make apply_to_page_range more robust

Started byMika Penttilä <mika.penttila@nextfour.com>
First post2016-01-15 06:50 +0100
Last post2016-01-19 23:30 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] mm: make apply_to_page_range more robust Mika Penttilä <mika.penttila@nextfour.com> - 2016-01-15 06:50 +0100
    Re: [PATCH] mm: make apply_to_page_range more robust Pekka Enberg <penberg@kernel.org> - 2016-01-17 11:10 +0100
    Re: [PATCH] mm: make apply_to_page_range more robust David Rientjes <rientjes@google.com> - 2016-01-19 23:30 +0100

#1309880 — [PATCH] mm: make apply_to_page_range more robust

FromMika Penttilä <mika.penttila@nextfour.com>
Date2016-01-15 06:50 +0100
Subject[PATCH] mm: make apply_to_page_range more robust
Message-ID<qR5qO-1xR-3@gated-at.bofh.it>
Recent changes (4.4.0+) in module loader triggered oops on ARM. While
loading a module, size in :

apply_to_page_range(struct mm_struct *mm, unsigned long addr,   unsigned
long size, pte_fn_t fn, void *data);

can be 0 triggering the bug  BUG_ON(addr >= end);.

Fix by letting call with zero size succeed.

--Mika

Signed-off-by: mika.penttila@nextfour.com
---

diff --git a/mm/memory.c b/mm/memory.c
index c387430..c3d1a2e 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1884,6 +1884,9 @@ int apply_to_page_range(struct mm_struct *mm,
unsigned long addr,
        unsigned long end = addr + size;
        int err;

+       if (!size)
+               return 0;
+
        BUG_ON(addr >= end);
        pgd = pgd_offset(mm, addr);
        do {

[toc] | [next] | [standalone]


#1311123

FromPekka Enberg <penberg@kernel.org>
Date2016-01-17 11:10 +0100
Message-ID<qRSrx-14s-7@gated-at.bofh.it>
In reply to#1309880
On Fri, Jan 15, 2016 at 7:41 AM, Mika Penttilä
<mika.penttila@nextfour.com> wrote:
> Recent changes (4.4.0+) in module loader triggered oops on ARM. While
> loading a module, size in :
>
> apply_to_page_range(struct mm_struct *mm, unsigned long addr,   unsigned
> long size, pte_fn_t fn, void *data);
>
> can be 0 triggering the bug  BUG_ON(addr >= end);.
>
> Fix by letting call with zero size succeed.
>
> --Mika
>
> Signed-off-by: mika.penttila@nextfour.com

Reviewed-by: Pekka Enberg <penberg@kernel.org>

We could also replace that BUG_ON() with a WARN_ON() and return -EINVAL.

> ---
>
> diff --git a/mm/memory.c b/mm/memory.c
> index c387430..c3d1a2e 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -1884,6 +1884,9 @@ int apply_to_page_range(struct mm_struct *mm,
> unsigned long addr,
>         unsigned long end = addr + size;
>         int err;
>
> +       if (!size)
> +               return 0;
> +
>         BUG_ON(addr >= end);
>         pgd = pgd_offset(mm, addr);
>         do {
>
> --
> 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>

[toc] | [prev] | [next] | [standalone]


#1312556

FromDavid Rientjes <rientjes@google.com>
Date2016-01-19 23:30 +0100
Message-ID<qSMWK-5DX-3@gated-at.bofh.it>
In reply to#1309880

[Multipart message — attachments visible in raw view] — view raw

On Fri, 15 Jan 2016, Mika Penttilä wrote:

> Recent changes (4.4.0+) in module loader triggered oops on ARM. While
> loading a module, size in :
> 
> apply_to_page_range(struct mm_struct *mm, unsigned long addr,   unsigned
> long size, pte_fn_t fn, void *data);
> 
> can be 0 triggering the bug  BUG_ON(addr >= end);.
> 
> Fix by letting call with zero size succeed.
> 
> --Mika
> 
> Signed-off-by: mika.penttila@nextfour.com
> ---
> 
> diff --git a/mm/memory.c b/mm/memory.c
> index c387430..c3d1a2e 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -1884,6 +1884,9 @@ int apply_to_page_range(struct mm_struct *mm,
> unsigned long addr,
>         unsigned long end = addr + size;
>         int err;
> 
> +       if (!size)
> +               return 0;
> +
>         BUG_ON(addr >= end);
>         pgd = pgd_offset(mm, addr);
>         do {

What is calling apply_to_page_range() with size == 0?  I'm not sure we 
should be adding "robust"ness here and that size == 0 is actually an 
indication of a bug somewhere else that we want to know about.

Btw, your patch is line-wrapped and your sign-off-line doesn't include 
your full name.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web