Skip to content

Commit

Permalink
check the table is exist
Browse files Browse the repository at this point in the history
  • Loading branch information
linD026 committed Oct 5, 2024
1 parent de60e3c commit 1664786
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .ci/build-n-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ function list_mod()
function run_mod()
{
# insert/remove twice to ensure resource allocations
( sudo insmod "examples/$1.ko" && sudo rmmod "$1" ) || exit 1
( sudo insmod "examples/$1.ko" && sudo rmmod "$1" ) || exit 1
( sudo insmod "examples/$1.ko" && sudo rmmod "$1" ) || ( echo "first $1" && exit 1 )
( sudo insmod "examples/$1.ko" && sudo rmmod "$1" ) || ( echo "second $1" && exit 1 )
#( sudo insmod "examples/$1.ko" && sudo rmmod "$1" ) || exit 1
}

function run_examples()
Expand All @@ -26,5 +27,8 @@ function run_examples()
done
}

sudo cat /proc/kallsyms | grep "__x64_sys_openat"
table=`sudo cat /proc/kallsyms | grep "sys_call_table" | awk '{print $1}'`
build_example
( sudo insmod "example/syscall-steal.ko" && sudo rmmod "syscall-steal" ) || exit 1
run_examples
3 changes: 3 additions & 0 deletions examples/syscall-steal.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ static int __init syscall_steal_start(void)
pr_err("Please check the symbol name from 'syscall_sym' parameter.\n");
return err;
}

return 0;
#else
if (!(sys_call_table_stolen = acquire_sys_call_table()))
return -1;
Expand All @@ -273,6 +275,7 @@ static void __exit syscall_steal_end(void)
{
#if USE_KPROBES_PRE_HANDLER_BEFORE_SYSCALL
unregister_kprobe(&syscall_kprobe);
return;
#else
if (!sys_call_table_stolen)
return;
Expand Down

0 comments on commit 1664786

Please sign in to comment.