Skip to content

Commit

Permalink
Stack zeroization for ARM: add tests
Browse files Browse the repository at this point in the history
Co-authored-by: Santiago Arranz Olmos <santiago.arranz1@gmail.com>
  • Loading branch information
eponier and sarranz committed Nov 20, 2023
1 parent 68414c9 commit cf4c897
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
4 changes: 3 additions & 1 deletion compiler/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ CHECKCATS ?= \
arm-m4 \
arm-m4-print \
x86-64-stack-zero-loop \
x86-64-stack-zero-unrolled
x86-64-stack-zero-unrolled \
arm-m4-stack-zero-loop \
arm-m4-stack-zero-unrolled

# --------------------------------------------------------------------
DESTDIR ?=
Expand Down
12 changes: 12 additions & 0 deletions compiler/config/tests.config
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,15 @@ args = -stack-zero=unrolled
okdirs = examples/**/x86-64 tests/success/**/x86-64
kodirs = tests/fail/**/x86-64
exclude = !tests/fail/warning

[test-arm-m4-stack-zero-loop]
bin = ./scripts/check-arm-m4
args = -stack-zero=loop
okdirs = examples/**/arm-m4 tests/success/**/arm-m4
kodirs = tests/fail/**/arm-m4

[test-arm-m4-stack-zero-unrolled]
bin = ./scripts/check-arm-m4
args = -stack-zero=unrolled
okdirs = examples/**/arm-m4 tests/success/**/arm-m4
kodirs = tests/fail/**/arm-m4
9 changes: 4 additions & 5 deletions compiler/src/pretyping.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1850,11 +1850,10 @@ let process_f_annot loc funname f_cc annot =
match strategy, size with
| None, None -> None
| None, Some _ ->
hierror
~loc:(Lone loc)
~funname
~kind:"unexpected annotation"
"\"stackzerosize\" cannot be used alone, you need to specify a strategy with attribute \"stackzero\""
warning Always
(L.i_loc0 loc)
"\"stackzerosize\" is ignored, since you did not specify a strategy with attribute \"stackzero\"";
None
| Some szs, _ -> Some (szs, size)
in

Expand Down
6 changes: 6 additions & 0 deletions compiler/tests/success/arm-m4/rand.jazz
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/* stack zeroization uses the alignment of the function as the default clear
step size. Due to the system call, the function is aligned on u128, but stack
zeroization is not implemented for u128 on ARM. Thus we introduce this
annotation to use u32 for the clear step size instead.
*/
#[stackzerosize=u32]
export
fn random32() -> reg u32 {
stack u8[4] s;
Expand Down

0 comments on commit cf4c897

Please sign in to comment.