Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
X
xcap-capability-linux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xcap
xcap-capability-linux
Commits
05f9ca83
Commit
05f9ca83
authored
Mar 18, 2006
by
David S. Miller
Browse files
Options
Downloads
Patches
Plain Diff
[SPARC64]: Randomize mm->mmap_base when PF_RANDOMIZE is set.
Signed-off-by:
David S. Miller
<
davem@davemloft.net
>
parent
d61e16df
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
arch/sparc64/kernel/sys_sparc.c
+14
-2
14 additions, 2 deletions
arch/sparc64/kernel/sys_sparc.c
with
14 additions
and
2 deletions
arch/sparc64/kernel/sys_sparc.c
+
14
−
2
View file @
05f9ca83
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#include
<linux/syscalls.h>
#include
<linux/syscalls.h>
#include
<linux/ipc.h>
#include
<linux/ipc.h>
#include
<linux/personality.h>
#include
<linux/personality.h>
#include
<linux/random.h>
#include
<asm/uaccess.h>
#include
<asm/uaccess.h>
#include
<asm/ipc.h>
#include
<asm/ipc.h>
...
@@ -358,6 +359,17 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
...
@@ -358,6 +359,17 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
/* Essentially the same as PowerPC... */
/* Essentially the same as PowerPC... */
void
arch_pick_mmap_layout
(
struct
mm_struct
*
mm
)
void
arch_pick_mmap_layout
(
struct
mm_struct
*
mm
)
{
{
unsigned
long
random_factor
=
0UL
;
if
(
current
->
flags
&
PF_RANDOMIZE
)
{
random_factor
=
get_random_int
();
if
(
test_thread_flag
(
TIF_32BIT
))
random_factor
&=
((
1
*
1024
*
1024
)
-
1
);
else
random_factor
=
((
random_factor
<<
PAGE_SHIFT
)
&
0xffffffffUL
);
}
/*
/*
* Fall back to the standard layout if the personality
* Fall back to the standard layout if the personality
* bit is set, or if the expected stack growth is unlimited:
* bit is set, or if the expected stack growth is unlimited:
...
@@ -366,7 +378,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
...
@@ -366,7 +378,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
(
current
->
personality
&
ADDR_COMPAT_LAYOUT
)
||
(
current
->
personality
&
ADDR_COMPAT_LAYOUT
)
||
current
->
signal
->
rlim
[
RLIMIT_STACK
].
rlim_cur
==
RLIM_INFINITY
||
current
->
signal
->
rlim
[
RLIMIT_STACK
].
rlim_cur
==
RLIM_INFINITY
||
sysctl_legacy_va_layout
)
{
sysctl_legacy_va_layout
)
{
mm
->
mmap_base
=
TASK_UNMAPPED_BASE
;
mm
->
mmap_base
=
TASK_UNMAPPED_BASE
+
random_factor
;
mm
->
get_unmapped_area
=
arch_get_unmapped_area
;
mm
->
get_unmapped_area
=
arch_get_unmapped_area
;
mm
->
unmap_area
=
arch_unmap_area
;
mm
->
unmap_area
=
arch_unmap_area
;
}
else
{
}
else
{
...
@@ -380,7 +392,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
...
@@ -380,7 +392,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
if
(
gap
>
(
task_size
/
6
*
5
))
if
(
gap
>
(
task_size
/
6
*
5
))
gap
=
(
task_size
/
6
*
5
);
gap
=
(
task_size
/
6
*
5
);
mm
->
mmap_base
=
task_size
-
(
gap
&
PAGE_MASK
);
mm
->
mmap_base
=
PAGE_ALIGN
(
task_size
-
gap
-
random_factor
);
mm
->
get_unmapped_area
=
arch_get_unmapped_area_topdown
;
mm
->
get_unmapped_area
=
arch_get_unmapped_area_topdown
;
mm
->
unmap_area
=
arch_unmap_area_topdown
;
mm
->
unmap_area
=
arch_unmap_area_topdown
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment