Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 138491
b: refs/heads/master
c: 9f14c42
h: refs/heads/master
i:
  138489: 3f7ff8d
  138487: 4d12764
v: v3
  • Loading branch information
Anton Blanchard authored and Benjamin Herrenschmidt committed Feb 23, 2009
1 parent 1cd0a98 commit 3e90603
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 13a2cb3694d7237e6cc3e94fcb311b81908ccd06
refs/heads/master: 9f14c42d7582bf33bbe1e133d897a6942ceae08e
17 changes: 16 additions & 1 deletion trunk/arch/powerpc/mm/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <linux/personality.h>
#include <linux/mm.h>
#include <linux/random.h>
#include <linux/sched.h>

/*
Expand All @@ -45,6 +46,20 @@ static inline int mmap_is_legacy(void)
return sysctl_legacy_va_layout;
}

static unsigned long mmap_rnd(void)
{
unsigned long rnd = 0;

if (current->flags & PF_RANDOMIZE) {
/* 8MB for 32bit, 1GB for 64bit */
if (is_32bit_task())
rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
else
rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
}
return rnd << PAGE_SHIFT;
}

static inline unsigned long mmap_base(void)
{
unsigned long gap = current->signal->rlim[RLIMIT_STACK].rlim_cur;
Expand All @@ -54,7 +69,7 @@ static inline unsigned long mmap_base(void)
else if (gap > MAX_GAP)
gap = MAX_GAP;

return TASK_SIZE - (gap & PAGE_MASK);
return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
}

/*
Expand Down

0 comments on commit 3e90603

Please sign in to comment.