Messages in this thread | | | Date | Thu, 4 Sep 2003 10:38:26 -0700 (PDT) | From | Linus Torvalds <> | Subject | Re: [PATCH] Alternate futex non-page-pinning and COW fix |
| |
On Thu, 4 Sep 2003, Jamie Lokier wrote: > > Yes it can. See sys_mprotect(). If that's not intended, it's a bug > in mprotect().
Oh. I see. Yes - it's accessing "vm_flags" with "MAP_SEM". That's really wrong, since it's not even the same _domain_.
"vm_flags" should use the "VM_xxxx" bits. Trying to use "PROT_xxx" bits is totally improper, but it so happens that the low three bits (READ|WRITE|EXEC) are supposed to be the same.
Good catch.
It really should do what mmap() does, and translate from the "PROT_xxx" domain to the "VM_xxx" domain:
flag = _trans(prot, PROT_READ, VM_READ) | _trans(prot, PROT_WRITE, VM_WRITE) | _trans(prot, PROT_EXEC, VM_EXEC);
and the only reason sys_mprotect _looks_ like it is working is that those three bits (but _not_ MAP_SEM) happen to be the same anyway.
I'm inclined to be lazy, and say "we know the low three bits of "prot" and "flags" are the same, and leave it as-is, but remove the MAP_SEM, which clearly is a bug.
But the proper thing is to move that part of calc_vm_flags() to a header file. Does anybody want to take that on?
Linus
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |