• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh -efu
2
3# Check decoding of return values injected into a syscall that "never fails".
4
5. "${srcdir=.}/scno_tampering.sh"
6
7case "$STRACE_ARCH" in
8alpha)
9	SYSCALL=getpgrp
10	;;
11*)
12	SYSCALL=getpid
13	;;
14esac
15
16run_prog
17prog="$args"
18fault_args="-a9 -e trace=${SYSCALL} -e inject=${SYSCALL}:retval="
19
20test_rval()
21{
22	local rval
23	rval="$1"; shift
24
25	run_strace $fault_args$rval $prog $rval > "$EXP"
26	match_diff "$LOG" "$EXP"
27}
28
29test_rval 0
30test_rval 1
31test_rval 0x7fffffff
32test_rval 0x80000000
33test_rval 0xfffff000
34test_rval 0xfffffffe
35test_rval 0xffffffff
36
37case "$SIZEOF_KERNEL_LONG_T" in
388)
39	test_rval         0x80000000
40	test_rval         0xfffff000
41	test_rval         0xfffffffe
42	test_rval         0xffffffff
43	test_rval        0x100000000
44	test_rval 0x7fffffffffffffff
45	test_rval 0x8000000000000000
46	test_rval 0xfffffffffffff000
47	test_rval 0xfffffffffffffffe
48	test_rval 0xffffffffffffffff
49	;;
50esac
51