Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libnux
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
EBRAINS RI
Tech Hub
Apps
BrainScaleS
libnux
Commits
59d451e3
Commit
59d451e3
authored
5 years ago
by
Philipp Spilger
Committed by
Yannik Stradmann
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix stack_redzone test to exit before actual program corruption
Change-Id: I644511ecec8626fe3bdb833bf6bae930fd0fced9
parent
4d78a050
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/helpers/hwtest_common.py
+1
-2
1 addition, 2 deletions
test/helpers/hwtest_common.py
test/test_stack_redzone.cpp
+25
-5
25 additions, 5 deletions
test/test_stack_redzone.cpp
with
26 additions
and
7 deletions
test/helpers/hwtest_common.py
+
1
−
2
View file @
59d451e3
...
...
@@ -101,6 +101,5 @@ def get_special_binaries(dls_version: str) -> Set[PpuHwTest]:
expected_exit_code
=
stack_protection
*
-
559038737
),
PpuHwTest
(
join
(
TEST_BINARY_PATH
,
f
"
test_stack_redzone_
{
dls_version
}
.binary
"
),
expected_exit_code
=
stack_redzone
*
12
,
expect_timeout
=
not
stack_redzone
)
expected_exit_code
=
12
if
stack_redzone
else
2
)
}
This diff is collapsed.
Click to expand it.
test/test_stack_redzone.cpp
+
25
−
5
View file @
59d451e3
#include
<stdint.h>
#include
"libnux/helper.h"
extern
uint8_t
stack_redzone
;
/*
The stack grows infinitely. With '-fstack-limit-symbol=stack_redzone',
the program exits with error code 12 (= ENOMEM), whereas without this option,
it doesn't finish, since the program memory region gets partially overwritten.
it wouldn't finish, since the program memory region would get partially overwritten, which
is however detected beforehand and a dedicated return value 2 is generated.
*/
int
start
(
void
)
int
32_t
start
(
void
)
{
__attribute__
((
unused
))
int
volatile
i
=
5
;
start
();
return
0
;
uintptr_t
stack_ptr
;
// return 2 if stack redzone does not work, which is defined here as the stack pointer is
// smaller equal than the stack_redzone symbol location.
// clang-format off
asm
volatile
(
// load stack pointer
"mr %[stack_ptr], 1
\n
"
:
[
stack_ptr
]
"=r"
(
stack_ptr
)
::
);
// clang-format on
if
(
stack_ptr
<
uintptr_t
(
&
stack_redzone
))
{
return
2
;
}
int
x
=
5
;
do_not_optimize_away
(
x
);
return
start
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
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