* [PATCH 1/5] revoke: special mmap handling
@ 2007-03-11 11:30 Pekka J Enberg
0 siblings, 0 replies; only message in thread
From: Pekka J Enberg @ 2007-03-11 11:30 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, hch, alan
From: Pekka Enberg <penberg@cs.helsinki.fi>
This adds special handling for revoked memory mappings. We want to
raise SIGBUS when accessing revoked mappings and return ENODEV when
trying to remap with mmap(2).
Acked-by: Alan Cox <alan@redhat.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---
include/linux/mm.h | 1 +
mm/memory.c | 3 +++
mm/mmap.c | 12 ++++++++----
3 files changed, 12 insertions(+), 4 deletions(-)
Index: uml-2.6/include/linux/mm.h
===================================================================
--- uml-2.6.orig/include/linux/mm.h 2007-03-11 13:07:57.000000000 +0200
+++ uml-2.6/include/linux/mm.h 2007-03-11 13:09:19.000000000 +0200
@@ -169,6 +169,7 @@ #define VM_NONLINEAR 0x00800000 /* Is no
#define VM_MAPPED_COPY 0x01000000 /* T if mapped copy of data (nommu mmap) */
#define VM_INSERTPAGE 0x02000000 /* The vma has had "vm_insert_page()" done on it */
#define VM_ALWAYSDUMP 0x04000000 /* Always include in core dumps */
+#define VM_REVOKED 0x08000000 /* Mapping has been revoked */
#ifndef VM_STACK_DEFAULT_FLAGS /* arch can override this */
#define VM_STACK_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS
Index: uml-2.6/mm/memory.c
===================================================================
--- uml-2.6.orig/mm/memory.c 2007-03-11 13:07:57.000000000 +0200
+++ uml-2.6/mm/memory.c 2007-03-11 13:09:19.000000000 +0200
@@ -2504,6 +2504,9 @@ int __handle_mm_fault(struct mm_struct *
if (unlikely(is_vm_hugetlb_page(vma)))
return hugetlb_fault(mm, vma, address, write_access);
+ if (unlikely(vma->vm_flags & VM_REVOKED))
+ return VM_FAULT_SIGBUS;
+
pgd = pgd_offset(mm, address);
pud = pud_alloc(mm, pgd, address);
if (!pud)
Index: uml-2.6/mm/mmap.c
===================================================================
--- uml-2.6.orig/mm/mmap.c 2007-03-11 13:07:57.000000000 +0200
+++ uml-2.6/mm/mmap.c 2007-03-11 13:09:19.000000000 +0200
@@ -1030,10 +1030,14 @@ accountable = 0;
error = -ENOMEM;
munmap_back:
vma = find_vma_prepare(mm, addr, &prev, &rb_link, &rb_parent);
- if (vma && vma->vm_start < addr + len) {
- if (do_munmap(mm, addr, len))
- return -ENOMEM;
- goto munmap_back;
+ if (vma) {
+ if (unlikely(vma->vm_flags & VM_REVOKED))
+ return -ENODEV;
+ if (vma->vm_start < addr + len) {
+ if (do_munmap(mm, addr, len))
+ return -ENOMEM;
+ goto munmap_back;
+ }
}
/* Check against address space limit. */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-03-11 11:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-11 11:30 [PATCH 1/5] revoke: special mmap handling Pekka J Enberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).