patch-2.1.2 linux/include/linux/mm.h
Next file: linux/include/linux/msg.h
Previous file: linux/include/linux/ipc.h
Back to the patch index
Back to the overall index
- Lines: 55
- Date:
Tue Oct 8 18:58:23 1996
- Orig file:
v2.1.1/linux/include/linux/mm.h
- Orig date:
Mon Sep 30 11:19:00 1996
diff -u --recursive --new-file v2.1.1/linux/include/linux/mm.h linux/include/linux/mm.h
@@ -14,11 +14,26 @@
#include <asm/page.h>
#include <asm/atomic.h>
+#include <asm/segment.h>
#define VERIFY_READ 0
#define VERIFY_WRITE 1
-extern int verify_area(int, const void *, unsigned long);
+extern int __verify_write(const void *, unsigned long);
+
+#define verify_write(type,addr,size) \
+(((type) && !wp_works_ok)?__verify_write((addr),(size)):0)
+
+extern inline int verify_area(int type, const void * addr, unsigned long size)
+{
+ int retval = 0;
+ if (get_fs() != KERNEL_DS) {
+ retval = -EFAULT;
+ if (size <= TASK_SIZE && TASK_SIZE-size >= (unsigned long) addr)
+ retval = verify_write(type,addr,size);
+ }
+ return retval;
+}
/*
* Linux kernel virtual memory manager primitives.
@@ -333,17 +348,18 @@
struct vm_area_struct * result = NULL;
if (mm) {
- struct vm_area_struct * tree = mm->mmap_avl;
+ struct vm_area_struct ** next = &mm->mmap_avl;
for (;;) {
+ struct vm_area_struct *tree = *next;
if (tree == avl_empty)
break;
- if (tree->vm_end > addr) {
- result = tree;
- if (tree->vm_start <= addr)
- break;
- tree = tree->vm_avl_left;
- } else
- tree = tree->vm_avl_right;
+ next = &tree->vm_avl_right;
+ if (tree->vm_end <= addr)
+ continue;
+ next = &tree->vm_avl_left;
+ result = tree;
+ if (tree->vm_start <= addr)
+ break;
}
}
return result;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov