4c9ed3f146
Extend the range of injected return value to the maximum, print warnings if negative injection value can be clipped in compat personality or can inadvertently turn into a fault injection. * defs.h (INJECT_F_ERROR): New macro. * filter_qualify.c (parse_inject_token): Revert type of intval local variable back to int, check INJECT_F_ERROR along with INJECT_F_RETVAL, use strtoull to parse retval argument, print warnings in case of retval clipping and inadvertent fault injection. (qualify_inject_common): Set INJECT_F_ERROR instead of INJECT_F_RETVAL. * syscall.c (tamper_with_syscall_exiting): Check inject_data.flags to determine whether a fault injection or retval injection has to be performed. (syscall_exiting_trace) <case RVAL_DECIMAL>: Explicitly print tcp->u_rval as int if current_klongsize < sizeof(tcp->u_rval). * tests/inject-nf.c (main): Update. * tests/inject-nf.test: Test injection of negative return values. * tests/qual_inject-syntax.test: Remove retval=-1 check as it is now allowed, add checks for invalid retval parameters. Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
51 lines
897 B
Bash
Executable File
51 lines
897 B
Bash
Executable File
#!/bin/sh -efu
|
|
|
|
# Check decoding of return values injected into a syscall that "never fails".
|
|
|
|
. "${srcdir=.}/scno_tampering.sh"
|
|
|
|
case "$STRACE_ARCH" in
|
|
alpha)
|
|
SYSCALL=getpgrp
|
|
;;
|
|
*)
|
|
SYSCALL=getpid
|
|
;;
|
|
esac
|
|
|
|
run_prog
|
|
prog="$args"
|
|
fault_args="-a9 -e trace=${SYSCALL} -e inject=${SYSCALL}:retval="
|
|
|
|
test_rval()
|
|
{
|
|
local rval
|
|
rval="$1"; shift
|
|
|
|
run_strace $fault_args$rval $prog $rval > "$EXP"
|
|
match_diff "$LOG" "$EXP"
|
|
}
|
|
|
|
test_rval 0
|
|
test_rval 1
|
|
test_rval 0x7fffffff
|
|
test_rval 0x80000000
|
|
test_rval 0xfffff000
|
|
test_rval 0xfffffffe
|
|
test_rval 0xffffffff
|
|
|
|
case "$SIZEOF_KERNEL_LONG_T" in
|
|
8)
|
|
test_rval 0x80000000
|
|
test_rval 0xfffff000
|
|
test_rval 0xfffffffe
|
|
test_rval 0xffffffff
|
|
test_rval 0x100000000
|
|
test_rval 0x7fffffffffffffff
|
|
test_rval 0x8000000000000000
|
|
test_rval 0xfffffffffffff000
|
|
test_rval 0xfffffffffffffffe
|
|
test_rval 0xffffffffffffffff
|
|
;;
|
|
esac
|