linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: make apply_to_page_range more robust
@ 2016-01-15  5:41 Mika Penttilä
  2016-01-17 10:02 ` Pekka Enberg
  2016-01-19 22:21 ` David Rientjes
  0 siblings, 2 replies; 3+ messages in thread
From: Mika Penttilä @ 2016-01-15  5:41 UTC (permalink / raw)
  To: LKML, linux-mm

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 {

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: make apply_to_page_range more robust
  2016-01-15  5:41 [PATCH] mm: make apply_to_page_range more robust Mika Penttilä
@ 2016-01-17 10:02 ` Pekka Enberg
  2016-01-19 22:21 ` David Rientjes
  1 sibling, 0 replies; 3+ messages in thread
From: Pekka Enberg @ 2016-01-17 10:02 UTC (permalink / raw)
  To: Mika Penttilä; +Cc: LKML, linux-mm, Andrew Morton

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>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: make apply_to_page_range more robust
  2016-01-15  5:41 [PATCH] mm: make apply_to_page_range more robust Mika Penttilä
  2016-01-17 10:02 ` Pekka Enberg
@ 2016-01-19 22:21 ` David Rientjes
  1 sibling, 0 replies; 3+ messages in thread
From: David Rientjes @ 2016-01-19 22:21 UTC (permalink / raw)
  To: Mika Penttilä; +Cc: LKML, linux-mm

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1137 bytes --]

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-01-19 22:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-15  5:41 [PATCH] mm: make apply_to_page_range more robust Mika Penttilä
2016-01-17 10:02 ` Pekka Enberg
2016-01-19 22:21 ` David Rientjes

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).