2002-09-25 22:55:04

by David Mosberger

[permalink] [raw]
Subject: [patch] make mprotect() work again

This patch:

[email protected], 2002-09-17 20:35:47-07:00, [email protected]
[PATCH] consolidate the VMA splitting code

broke mprotect(). The patch below makes it work again.

--david

===== mm/mprotect.c 1.16 vs edited =====
--- 1.16/mm/mprotect.c Tue Sep 17 11:05:14 2002
+++ edited/mm/mprotect.c Wed Sep 25 15:48:39 2002
@@ -186,8 +186,10 @@
/*
* Try to merge with the previous vma.
*/
- if (mprotect_attempt_merge(vma, *pprev, end, newflags))
+ if (mprotect_attempt_merge(vma, *pprev, end, newflags)) {
+ change_protection(vma, start, end, newprot);
return 0;
+ }
} else {
error = split_vma(mm, vma, start, 1);
if (error)


2002-09-25 23:13:59

by Andrew Morton

[permalink] [raw]
Subject: Re: [patch] make mprotect() work again

David Mosberger wrote:
>
> This patch:
>
> [email protected], 2002-09-17 20:35:47-07:00, [email protected]
> [PATCH] consolidate the VMA splitting code
>
> broke mprotect(). The patch below makes it work again.
>

Thanks. Yet another victim of the return-from-the-middle-of-a-function
disease.

I'll send this:


--- 2.5.38/mm/mprotect.c~mprotect-fix Wed Sep 25 16:16:14 2002
+++ 2.5.38-akpm/mm/mprotect.c Wed Sep 25 16:16:35 2002
@@ -187,7 +187,7 @@ mprotect_fixup(struct vm_area_struct *vm
* Try to merge with the previous vma.
*/
if (mprotect_attempt_merge(vma, *pprev, end, newflags))
- return 0;
+ goto success;
} else {
error = split_vma(mm, vma, start, 1);
if (error)
@@ -209,7 +209,7 @@ mprotect_fixup(struct vm_area_struct *vm
vma->vm_flags = newflags;
vma->vm_page_prot = newprot;
spin_unlock(&mm->page_table_lock);
-
+success:
change_protection(vma, start, end, newprot);
return 0;


.