Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
a50db76f
Commit
a50db76f
authored
May 04, 2022
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Grossly hack the (debug only) persistent stevedore to cope with ASLR
parent
f61474ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
4 deletions
+31
-4
mgt_storage_persistent.c
bin/varnishd/storage/mgt_storage_persistent.c
+31
-4
No files found.
bin/varnishd/storage/mgt_storage_persistent.c
View file @
a50db76f
...
...
@@ -143,7 +143,8 @@ smp_mgt_init(struct stevedore *parent, int ac, char * const *av)
struct
smp_sc
*
sc
;
struct
smp_sign
sgn
;
void
*
target
;
int
i
;
int
i
,
mmap_flags
;
uintptr_t
up
;
ASSERT_MGT
();
...
...
@@ -205,12 +206,38 @@ smp_mgt_init(struct stevedore *parent, int ac, char * const *av)
else
target
=
NULL
;
mmap_flags
=
MAP_NOCORE
|
MAP_NOSYNC
|
MAP_SHARED
;
if
(
target
)
{
mmap_flags
|=
MAP_FIXED
;
#ifdef MAP_EXCL
mmap_flags
|=
MAP_EXCL
;
#endif
}
else
{
/*
* I guess the people who came up with ASLR never learned
* that virtual memory can have benficial uses, because they
* added no facility for realiably and portably allocing
* stable address-space.
* This stevedore is only for testing these days, so we
* can get away with just hacking something up: 16M below
* the break seems to work on FreeBSD.
*/
up
=
(
uintptr_t
)
sbrk
(
0
);
up
-=
1ULL
<<
24
;
up
-=
sc
->
mediasize
;
up
&=
~
(
getpagesize
()
-
1ULL
);
target
=
(
void
*
)
up
;
#ifdef MAP_ALIGNED_SUPER
mmap_flags
|=
MAP_ALIGNED_SUPER
;
#endif
}
sc
->
base
=
(
void
*
)
mmap
(
target
,
sc
->
mediasize
,
PROT_READ
|
PROT_WRITE
,
MAP_NOCORE
|
MAP_NOSYNC
|
MAP_SHARED
,
sc
->
fd
,
0
);
mmap_flags
,
sc
->
fd
,
0
);
if
(
sc
->
base
==
MAP_FAILED
)
ARGV_ERR
(
"(-spersistent) failed to mmap (%s)
\n
"
,
VAS_errtxt
(
errno
));
ARGV_ERR
(
"(-spersistent) failed to mmap (%s)
@%p
\n
"
,
VAS_errtxt
(
errno
)
,
target
);
if
(
target
!=
NULL
&&
sc
->
base
!=
target
)
fprintf
(
stderr
,
"WARNING: Persistent silo lost to ASLR %s
\n
"
,
sc
->
filename
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment