mprotect() resets caching policy
From: Thomas Hellström
Date: Fri Jan 27 2006 - 07:24:41 EST
Hi!
I'm working on an infrastructure to allow drm clients to flip arbitrary
pages in and out of the AGP aperture (or any similar device). In order
to avoid conflicting mappings for those pages, the caching attribute of
both the kernel mapping and all VMA's is changed when binding / unbinding.
However, I noticed that mprotect() will, when run on a non-cached VMA,
reset the caching policy. The line in mm/mprotect.c causing this problem is
newprot = protection_map[newflags & 0xf];
So a user could potentially run mprotect() and create a conflicting
mapping which presumably is bad for stability on some architectures.
Since mprotect() only deals with rwx protection. I figure replacing the
above with something like
newprot = (vm_page_prot & ~MPROT_MASK) | (protection_map[newflags & 0xf]
& MPROT_MASK)
Where MPROT_MASK is a arch-dependent mask identifying the bits available
to mprotect().
Alternatively, is there a way to disable mprotect() for a VMA?
Finally, is there a chance to get protection_map[] exported to modules?
Any comments would be appreciated. Please CC me since I'm not on the list.
Regards,
Thomas Hellström
-
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/