bottomup:
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
-@@ -1182,6 +1182,7 @@ void page_cache_async_readahead(struct a
+@@ -1194,6 +1194,7 @@ void page_cache_async_readahead(struct a
unsigned long max_sane_readahead(unsigned long nr);
/* Do stack extension */
extern int expand_upwards(struct vm_area_struct *vma, unsigned long address);
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
-@@ -1209,6 +1209,14 @@ static struct ctl_table vm_table[] = {
+@@ -1207,6 +1207,14 @@ static struct ctl_table vm_table[] = {
.extra2 = &one,
},
#endif
atomic_long_t vm_committed_space = ATOMIC_LONG_INIT(0);
+int heap_stack_gap __read_mostly = 1;
- /*
- * Check that a process has enough memory to allocate a new virtual
-@@ -1290,6 +1291,8 @@ arch_get_unmapped_area(struct file *filp
+ /* amount of vm to protect from userspace access */
+ unsigned long mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
+@@ -1293,6 +1294,8 @@ arch_get_unmapped_area(struct file *filp
full_search:
for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
/* At this point: (!vma || addr < vma->vm_end). */
if (TASK_SIZE - len < addr) {
/*
-@@ -1304,15 +1307,23 @@ full_search:
+@@ -1307,15 +1310,23 @@ full_search:
}
return -ENOMEM;
}
addr = vma->vm_end;
}
}
-@@ -1370,34 +1381,51 @@ arch_get_unmapped_area_topdown(struct fi
+@@ -1373,34 +1384,51 @@ arch_get_unmapped_area_topdown(struct fi
/* make sure it can fit in the remaining address space */
if (addr > len) {
} while (len < vma->vm_start);
bottomup:
-@@ -1620,6 +1648,19 @@ int expand_upwards(struct vm_area_struct
+@@ -1623,6 +1651,19 @@ int expand_upwards(struct vm_area_struct
/* Somebody else might have raced and expanded it already */
if (address > vma->vm_end) {
unsigned long size, grow;
size = address - vma->vm_start;
grow = (address - vma->vm_end) >> PAGE_SHIFT;
-@@ -1628,6 +1669,7 @@ int expand_upwards(struct vm_area_struct
+@@ -1631,6 +1672,7 @@ int expand_upwards(struct vm_area_struct
if (!error)
vma->vm_end = address;
}
anon_vma_unlock(vma);
return error;
}
-@@ -1664,7 +1706,21 @@ static inline int expand_downwards(struc
+@@ -1667,7 +1709,21 @@ static inline int expand_downwards(struc
/* Somebody else might have raced and expanded it already */
if (address < vma->vm_start) {
unsigned long size, grow;
size = vma->vm_end - address;
grow = (vma->vm_start - address) >> PAGE_SHIFT;
-@@ -1674,6 +1730,7 @@ static inline int expand_downwards(struc
+@@ -1677,6 +1733,7 @@ static inline int expand_downwards(struc
vma->vm_pgoff -= grow;
}
}