Handle wrapping in expand_upwards()
Subsystems (3)
From: Helge Deller <[email protected]>
Function expand_upwards() did not guarded against wrapping around to address 0. This fixes the adjtimex02 testcase from the Linux Test Project on a 32bit PARISC kernel.
[expand_upwards is only used on parisc and ia64; it looks like it does
the right thing on both. --kyle]
---
mm/mmap.c +7 -2
@@ -1536,9 +1536,14 @@* vma->vm_start/vm_end cannot change under us because the caller * is required to hold the mmap_sem in read mode. We need the * anon_vma lock to serialize against concurrent expand_stacks. +* Also guard against wrapping around to address 0. */ - address +=4 +PAGE_SIZE -1 ; - address &=PAGE_MASK ; +if (address <PAGE_ALIGN (address+4 )) + address =PAGE_ALIGN (address+4 ); +else { +anon_vma_unlock (vma); +return -ENOMEM ; + } error =0 ;/* Somebody else might have raced and expanded it already */
Andrew Morton
maintainerQuoted 25 lines · On Thu, 21 Jun 2007 05:11:04 -0400 Kyle McMartin <[email protected]> wrote:
From: Helge Deller <[email protected]>
Function
expand_upwards()did not guarded against wrapping around to address 0. This fixes the adjtimex02 testcase from the Linux Test Project on a 32bit PARISC kernel.[
expand_upwardsis only used on parisc and ia64; it looks like it does
the right thing on both. --kyle]Signed-off-by Helge Deller <[email protected]>Cc Tony Luck <[email protected]>Signed-off-by Kyle McMartin <[email protected]>---
Index:
linux-2.6/mm/mmap.c
===================================================================mm/mmap.c +1
-0@@ -1536,9 +1536,14 @@* vma->vm_start/vm_end cannot change under us because the caller * is required to hold the mmap_sem in read mode. We need the * anon_vma lock to serialize against concurrent expand_stacks. +* Also guard against wrapping around to address 0. */
mm/mmap.c line 1548
Quoted 10 lines
mm/mmap.c +6
-2- address +=4 +PAGE_SIZE -1 ; - address &=PAGE_MASK ; +if (address <PAGE_ALIGN (address+4 )) + address =PAGE_ALIGN (address+4 ); +else { +anon_vma_unlock (vma); +return -ENOMEM ; + } error =0 ;
You did't really provide enough information for us to be able to decide whether this change is needed in 2.6.22, let alone 2.6.21.
I will magically infer from your To: line that you consider it 2.6.22 material, but if so I think that we'll need suitable reviewing, testing and acking from Tony, please. If he's offline (ols, perhaps?) then we might have a problem. Perhaps find a suitable ia64-enabled alternate?
As for 2.6.21: I'll assume it's needed there as well. Please advise if otherwise.
Quoted 8 lines · Andrew Morton
You did't really provide enough information for us to be able to decide whether this change is needed in 2.6.22, let alone 2.6.21.
I will magically infer from your To: line that you consider it 2.6.22 material, but if so I think that we'll need suitable reviewing, testing and acking from Tony, please. If he's offline (ols, perhaps?) then we might have a problem. Perhaps find a suitable ia64-enabled alternate?
Yes. It's not an issue on ia64 afaict since it isn't used for the stack, just the register stack engine backing store.
On parisc, the symptom is basically that dereferencing 0xffffffff would oops the kernel.
Quoted 4 lines
As for 2.6.21: I'll assume it's needed there as well. Please advise if otherwise.
I'm not horribly worried about parisc in 2.6-stable...
Cheers,
Kyle M.
Quoted 4 lines
I will magically infer from your To: line that you consider it 2.6.22 material, but if so I think that we'll need suitable reviewing, testing and acking from Tony, please. If he's offline (ols, perhaps?) then we might have a problem. Perhaps find a suitable ia64-enabled alternate?
Wrap-around to zero for the ia64 RSE stack isn't possible (it must be in a user region (0-4), so it is far, far away from the top of the address space.
-Tony
Quoted 9 lines · Tony
Quoted 4 lines
I will magically infer from your To: line that you consider it 2.6.22 material, but if so I think that we'll need suitable reviewing, testing and acking from Tony, please. If he's offline (ols, perhaps?) then we might have a problem. Perhaps find a suitable ia64-enabled alternate?
Wrap-around to zero for the ia64 RSE stack isn't possible (it must be in a user region (0-4), so it is far, far away from the top of the address space.
Thanks, this is what I had suspected from reading the code.
Cheers,
Kyle M.
Quoted 6 lines
(quoted diff) +0
-2-Tony -To unsubscribe from this list: send the line "unsubscribe linux-arch" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html