linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mm: make apply_to_page_range more robust
@ 2016-01-20  5:17 Mika Penttilä
  2016-01-20 23:37 ` David Rientjes
  0 siblings, 1 reply; 3+ messages in thread
From: Mika Penttilä @ 2016-01-20  5:17 UTC (permalink / raw)
  To: LKML; +Cc: linux-mm, David Rientjes, Pekka Enberg, Rusty Russell

Recent changes (4.4.0+) in module loader triggered oops on ARM. 
    
can be 0 triggering the bug  BUG_ON(addr >= end);.

The call path is SyS_init_module()->set_memory_xx()->apply_to_page_range(),
and apply_to_page_range gets zero length resulting in triggering :
   
  BUG_ON(addr >= end)

This is a consequence of changes in module section handling (Rusty CC:ed).
This may be triggable only with certain modules and/or gcc versions. 

Plus, I think the spirit of the BUG_ON is to catch overflows,
not to bug on zero length legitimate callers. So whatever the
reason for this triggering, some day we have another caller with
zero length. 

Fix by letting call with zero size succeed. 

v2: add more explanation

Signed-off-by: Mika PenttilA? mika.penttila@nextfour.com
Reviewed-by: Pekka Enberg <penberg@kernel.org>
---

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 related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mm: make apply_to_page_range more robust
  2016-01-20  5:17 [PATCH v2] mm: make apply_to_page_range more robust Mika Penttilä
@ 2016-01-20 23:37 ` David Rientjes
  2016-01-21  4:58   ` Rusty Russell
  0 siblings, 1 reply; 3+ messages in thread
From: David Rientjes @ 2016-01-20 23:37 UTC (permalink / raw)
  To: Mika Penttilä; +Cc: LKML, linux-mm, Pekka Enberg, Rusty Russell

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

On Wed, 20 Jan 2016, Mika PenttilA? wrote:

> Recent changes (4.4.0+) in module loader triggered oops on ARM. 
>     
> can be 0 triggering the bug  BUG_ON(addr >= end);.
> 
> The call path is SyS_init_module()->set_memory_xx()->apply_to_page_range(),
> and apply_to_page_range gets zero length resulting in triggering :
>    
>   BUG_ON(addr >= end)
> 
> This is a consequence of changes in module section handling (Rusty CC:ed).
> This may be triggable only with certain modules and/or gcc versions. 
> 

Well, what module are you loading to cause this crash?  Why would it be 
passing size == 0 to apply_to_page_range()?  Again, that sounds like a 
problem that we _want_ to know about since it is probably the result of 
buggy code and this patch would be covering it up.

Please elaborate on the problem that you are seeing, preferably with a 
stack trace of the BUG so we can fix the problem instead of papering over 
it.

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

* Re: [PATCH v2] mm: make apply_to_page_range more robust
  2016-01-20 23:37 ` David Rientjes
@ 2016-01-21  4:58   ` Rusty Russell
  0 siblings, 0 replies; 3+ messages in thread
From: Rusty Russell @ 2016-01-21  4:58 UTC (permalink / raw)
  To: David Rientjes, Mika Penttilä; +Cc: LKML, linux-mm, Pekka Enberg

David Rientjes <rientjes@google.com> writes:
> On Wed, 20 Jan 2016, Mika Penttilä wrote:
>
>> Recent changes (4.4.0+) in module loader triggered oops on ARM. 
>>     
>> can be 0 triggering the bug  BUG_ON(addr >= end);.
>> 
>> The call path is SyS_init_module()->set_memory_xx()->apply_to_page_range(),
>> and apply_to_page_range gets zero length resulting in triggering :
>>    
>>   BUG_ON(addr >= end)
>> 
>> This is a consequence of changes in module section handling (Rusty CC:ed).
>> This may be triggable only with certain modules and/or gcc versions. 
>> 
>
> Well, what module are you loading to cause this crash?  Why would it be 
> passing size == 0 to apply_to_page_range()?  Again, that sounds like a 
> problem that we _want_ to know about since it is probably the result of 
> buggy code and this patch would be covering it up.

Yes, I'm curious too.  It's certainly possible, since I expected a
zero-length range to do nothing, but let's make sure we're not papering
over some other screwup of mine.

Thanks,
Rusty.

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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-20  5:17 [PATCH v2] mm: make apply_to_page_range more robust Mika Penttilä
2016-01-20 23:37 ` David Rientjes
2016-01-21  4:58   ` Rusty Russell

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