Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/programs/_build_cfi_native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ build cfi_lpad_func_sig_zero.S cfi_lpad_func_sig_zero
build cfi_lpad_func_sig_failed.S cfi_lpad_func_sig_failed
build cfi_ss_only_pop.S cfi_ss_only_pop
build cfi_ss_popchk_failed.S cfi_ss_popchk_failed
build cfi_lpad_align_failed.S cfi_lpad_align_failed

Binary file added tests/programs/cfi_lpad_align_failed
Binary file not shown.
19 changes: 19 additions & 0 deletions tests/programs/cfi_lpad_align_failed.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@


.include "cfi_macro.h"

gnu_property_cfi_ss 1

.text
.global _start
_start:
la t1, func
c.jalr t1

.globl func
.type func,@function
# no alignment
# .balign 4
func:
lpad 0
ret
Binary file modified tests/programs/cfi_lpad_unlabeled
Binary file not shown.
8 changes: 7 additions & 1 deletion tests/programs/cfi_lpad_unlabeled.S
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ _start:

la t1, exit
c.jr t1

exit_imm 1

.globl func
Expand All @@ -29,5 +29,11 @@ func:
# lpad checks alignment with 4
.balign 4
exit:
lpad 0
# dummy lpad == no-op
lpad 0
li t0, 100
lpad 0
li t0, 200
lpad 0
exit_imm 0
Binary file modified tests/programs/cfi_ss_success
Binary file not shown.
6 changes: 6 additions & 0 deletions tests/programs/cfi_ss_success.S
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ _start:
sspush t0
sspopchk t0

c.sspush ra
sspopchk ra

sspush t0
c.sspopchk t0

li t0, 42
beq ra, t0, 1f
exit_imm 2
Expand Down
12 changes: 6 additions & 6 deletions tests/test_cfi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ pub fn test_cfi_ss_not_active() {
#[test]
pub fn test_cfi_ss_stack_downto_zero() {
let ret = run("tests/programs/cfi_ss_stack_downto_zero");
assert!(ret.is_err());
assert!(matches!(ret, Err(Error::CFIShadowStackOutOfStack)));
}

Expand All @@ -64,7 +63,6 @@ pub fn test_cfi_lpad_not_active() {
#[test]
pub fn test_cfi_lpad_unlabeled_failed() {
let ret = run("tests/programs/cfi_lpad_unlabeled_failed");
assert!(ret.is_err());
assert!(matches!(ret, Err(Error::CFILpadNotFound)));
}

Expand All @@ -83,21 +81,23 @@ pub fn test_cfi_lpad_func_sig_zero() {
#[test]
pub fn test_cfi_lpad_func_sig_failed() {
let ret = run("tests/programs/cfi_lpad_func_sig_failed");
assert!(ret.is_err());
assert!(matches!(ret, Err(Error::CFILpadLabelMismatched)));
}

#[test]
pub fn test_cfi_ss_only_pop() {
let ret = run("tests/programs/cfi_ss_only_pop");
print!("err {:?}", ret);
assert!(ret.is_err());
assert!(matches!(ret, Err(Error::CFIShadowStackOutOfStack)));
}

#[test]
pub fn test_cfi_ss_popchk_failed() {
let ret = run("tests/programs/cfi_ss_popchk_failed");
assert!(ret.is_err());
assert!(matches!(ret, Err(Error::CFIShadowStackValueFault)));
}

#[test]
pub fn test_cfi_lpad_align_failed() {
let ret = run("tests/programs/cfi_lpad_align_failed");
assert!(matches!(ret, Err(Error::CFILpadNot4ByteAligned)));
}
Loading