Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cet: add 11 CET user space SHSTK with SHSTK Glibc supported cases #106

Merged
merged 1 commit into from
Aug 18, 2023
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 cet/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cet_app
glibc_supported_shstk_test
quick_test
shstk_alloc
shstk_cp
Expand Down
5 changes: 4 additions & 1 deletion cet/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ IS_KER_SRC = $(shell [ -d $(KER_SRC) ] && echo true)

ifeq ($(GCC_GE_8),true)
BIN := shstk_alloc test_shadow_stack quick_test wrss shstk_huge_page \
shstk_unlock_test shstk_cp cet_app
shstk_unlock_test shstk_cp cet_app glibc_shstk_test

$(info GCC major version: ${GCC_VER_MAJOR})
else
Expand Down Expand Up @@ -54,6 +54,9 @@ shstk_cp: shstk_cp.c
cet_app:
gcc cet_driver/cet_app.c -I cet_driver -o $@

glibc_shstk_test: glibc_shstk_test.c
gcc $(CETFLAGS) $^ -o $@

cet_ioctl:
$(MAKE) -C $(KER_SRC) M=$(DRIVER_PATH) modules

Expand Down
61 changes: 61 additions & 0 deletions cet/cet_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,60 @@ load_cet_driver() {
fi
}

cet_shstk_check() {
local bin_name=$1
local bin_parm=$2
local name=$3
local ssp=""
local bp_add=""
local sp=""
local obj_log="/tmp/${bin_name}.txt"

bin=$(which "$bin_name")
if [[ -e "$bin" ]]; then
test_print_trc "Find bin:$bin"
else
die "bin:$bin does not exist"
fi

bin_output_dmesg "$bin" "$bin_parm"
sleep 1
case $name in
cet_ssp)
ssp=$(echo "$BIN_OUTPUT" \
| grep "ssp" \
| tail -1 \
| awk -F "*ssp=0x" '{print $2}' \
| cut -d ' ' -f 1)
bp_add=$(echo "$BIN_OUTPUT" \
| grep "ssp" \
| tail -1 \
| awk -F ":0x" '{print $2}' \
| cut -d ' ' -f 1)
[[ -n "$ssp" ]] || na_test "platform not support cet ssp check"
do_cmd "objdump -d $bin > $obj_log"
sp=$(grep -A1 "<shadow_stack_check>$" "$obj_log" \
| tail -n 1 \
| awk '{print $1}' \
| cut -d ':' -f 1)
if [[ "$ssp" == *"$sp"* ]]; then
test_print_trc "sp:$sp is same as ssp:$ssp, pass"
else
test_print_wrg "sp:$sp is not same as ssp:$ssp"
test_print_trc "clear linux compiler changed sp"
fi
if [[ "$bp_add" == "$ssp" ]] ; then
test_print_trc "bp+1:$bp_add is same as ssp:$ssp, pass"
else
die "bp+1:$bp_add is not same as ssp:$ssp"
fi
;;
*)
block_test "Invalid name:$name in cet_shstk_check"
;;
esac
}

cet_dmesg_check() {
local bin_name=$1
local bin_parm=$2
Expand All @@ -65,6 +119,7 @@ cet_dmesg_check() {
local verify_key=""

bin_output_dmesg "$bin_name" "$bin_parm"
sleep 1
verify_key=$(echo "$BIN_DMESG" | grep -i "$key")
case $key_parm in
"$CONTAIN")
Expand Down Expand Up @@ -105,6 +160,12 @@ cet_tests() {
load_cet_driver
cet_dmesg_check "$bin_file" "$PARM" "$KEYWORD" "$NULL"
;;
no_cp)
cet_dmesg_check "$bin_file" "$PARM" "$KEYWORD" "$NULL"
;;
cet_ssp)
cet_shstk_check "$bin_file" "$PARM" "$TYPE"
;;
*)
usage
block_test "Invalid TYPE:$TYPE"
Expand Down
Loading