diff options
-rw-r--r-- | include/linux/mm.h | 1 | ||||
-rw-r--r-- | mm/mprotect.c | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index 0d94c94d9d81..097b3a3c693d 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -136,6 +136,7 @@ extern unsigned int kobjsize(const void *objp); | |||
136 | #define VM_EXEC 0x00000004 | 136 | #define VM_EXEC 0x00000004 |
137 | #define VM_SHARED 0x00000008 | 137 | #define VM_SHARED 0x00000008 |
138 | 138 | ||
139 | /* mprotect() hardcodes VM_MAYREAD >> 4 == VM_READ, and so for r/w/x bits. */ | ||
139 | #define VM_MAYREAD 0x00000010 /* limits for mprotect() etc */ | 140 | #define VM_MAYREAD 0x00000010 /* limits for mprotect() etc */ |
140 | #define VM_MAYWRITE 0x00000020 | 141 | #define VM_MAYWRITE 0x00000020 |
141 | #define VM_MAYEXEC 0x00000040 | 142 | #define VM_MAYEXEC 0x00000040 |
diff --git a/mm/mprotect.c b/mm/mprotect.c index e9fbd013ad9a..57577f63b305 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c | |||
@@ -248,7 +248,8 @@ sys_mprotect(unsigned long start, size_t len, unsigned long prot) | |||
248 | 248 | ||
249 | newflags = vm_flags | (vma->vm_flags & ~(VM_READ | VM_WRITE | VM_EXEC)); | 249 | newflags = vm_flags | (vma->vm_flags & ~(VM_READ | VM_WRITE | VM_EXEC)); |
250 | 250 | ||
251 | if ((newflags & ~(newflags >> 4)) & 0xf) { | 251 | /* newflags >> 4 shift VM_MAY% in place of VM_% */ |
252 | if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) { | ||
252 | error = -EACCES; | 253 | error = -EACCES; |
253 | goto out; | 254 | goto out; |
254 | } | 255 | } |