Skip to content

Commit

Permalink
Merge branch 'for-5.18/selftests-fixes' into for-linus
Browse files Browse the repository at this point in the history
  • Loading branch information
pmladek committed Mar 28, 2022
2 parents 2957308 + 5e6ded2 commit e7dbd4d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion samples/livepatch/livepatch-shadow-fix1.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ static void livepatch_fix1_dummy_leak_dtor(void *obj, void *shadow_data)
void *d = obj;
int **shadow_leak = shadow_data;

kfree(*shadow_leak);
pr_info("%s: dummy @ %p, prevented leak @ %p\n",
__func__, d, *shadow_leak);
kfree(*shadow_leak);
}

static void livepatch_fix1_dummy_free(struct dummy *d)
Expand Down
2 changes: 1 addition & 1 deletion samples/livepatch/livepatch-shadow-fix2.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ static void livepatch_fix2_dummy_leak_dtor(void *obj, void *shadow_data)
void *d = obj;
int **shadow_leak = shadow_data;

kfree(*shadow_leak);
pr_info("%s: dummy @ %p, prevented leak @ %p\n",
__func__, d, *shadow_leak);
kfree(*shadow_leak);
}

static void livepatch_fix2_dummy_free(struct dummy *d)
Expand Down
22 changes: 19 additions & 3 deletions tools/testing/selftests/livepatch/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,25 @@ function set_dynamic_debug() {
}

function set_ftrace_enabled() {
result=$(sysctl -q kernel.ftrace_enabled="$1" 2>&1 && \
sysctl kernel.ftrace_enabled 2>&1)
echo "livepatch: $result" > /dev/kmsg
local can_fail=0
if [[ "$1" == "--fail" ]] ; then
can_fail=1
shift
fi

local err=$(sysctl -q kernel.ftrace_enabled="$1" 2>&1)
local result=$(sysctl --values kernel.ftrace_enabled)

if [[ "$result" != "$1" ]] ; then
if [[ $can_fail -eq 1 ]] ; then
echo "livepatch: $err" > /dev/kmsg
return
fi

skip "failed to set kernel.ftrace_enabled = $1"
fi

echo "livepatch: kernel.ftrace_enabled = $result" > /dev/kmsg
}

function cleanup() {
Expand Down
3 changes: 2 additions & 1 deletion tools/testing/selftests/livepatch/test-ftrace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ if [[ "$(cat /proc/cmdline)" != "$MOD_LIVEPATCH: this has been live patched" ]]
die "livepatch kselftest(s) failed"
fi

set_ftrace_enabled 0
# Check that ftrace could not get disabled when a livepatch is enabled
set_ftrace_enabled --fail 0
if [[ "$(cat /proc/cmdline)" != "$MOD_LIVEPATCH: this has been live patched" ]] ; then
echo -e "FAIL\n\n"
die "livepatch kselftest(s) failed"
Expand Down

0 comments on commit e7dbd4d

Please sign in to comment.