Re: [PATCH] Alternate futex non-page-pinning and COW fix

From: Linus Torvalds
Date: Thu Sep 04 2003 - 13:46:43 EST



[ Oops. Forgot the actual patch. ]

On Thu, 4 Sep 2003, Linus Torvalds wrote:
>
> How about something like this [ ... ]

THIS.

Linus

===== mm/mprotect.c 1.23 vs edited =====
--- 1.23/mm/mprotect.c Wed Jul 2 21:22:38 2003
+++ edited/mm/mprotect.c Thu Sep 4 11:12:09 2003
@@ -224,7 +224,7 @@
asmlinkage long
sys_mprotect(unsigned long start, size_t len, unsigned long prot)
{
- unsigned long nstart, end, tmp;
+ unsigned long flags, nstart, end, tmp;
struct vm_area_struct * vma, * next, * prev;
int error = -EINVAL;

@@ -239,6 +239,12 @@
if (end == start)
return 0;

+ /*
+ * FIXME! This assumes that PROT_xxx == VM_xxxx for READ, WRITE, EXEC
+ * That does happen to be true, but it's ugly.. mmap() gets this right.
+ */
+ flags = prot & (VM_READ | VM_WRITE | VM_EXEC);
+
down_write(&current->mm->mmap_sem);

vma = find_vma_prev(current->mm, start, &prev);
@@ -257,7 +263,7 @@
goto out;
}

- newflags = prot | (vma->vm_flags & ~(PROT_READ | PROT_WRITE | PROT_EXEC));
+ newflags = flags | (vma->vm_flags & ~(VM_READ | VM_WRITE | VM_EXEC));
if ((newflags & ~(newflags >> 4)) & 0xf) {
error = -EACCES;
goto out;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/