summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Prepare for 5.14 releasev5.14Dmitry V. Levin2021-09-021-1/+1
| | | | * NEWS: Update for 5.14 release.
* ci: use kernel headers from Linux kernel v5.14Dmitry V. Levin2021-09-013-0/+3
| | | | | | | | | | | | When Linux kernel merge window opens, changes of all sorts start to pour down, breaking UAPI in various ways. This does not work for strace, we need a stable UAPI. This change repeats commit v5.8~1. * .github/workflows/ci.yml (env): Add KBRANCH. * .gitlab-ci.yml (variables): Likewise. * .travis.yml (env:global): Likewise.
* Update copyright headersDmitry V. Levin2021-08-314-4/+4
| | | | | Headers updated automatically using maint/update_copyright_years.sh script.
* Fix preprocessor indentationDmitry V. Levin2021-08-303-11/+11
| | | | | | | | | Indent the C preprocessor directives to reflect their nesting using the following script: $ cppi -l $(git grep -El '^[[:space:]]*#[[:space:]]*(if|ifdef|ifndef|elif|else|endif|define|pragma)[[:space:]]' src tests |grep -v '\.sh$') |while read f; do cppi < "$f" > "$f".cppi; mv "$f".cppi "$f" done
* tests: reduce thoroughness of qual_fault's when= checkEugene Syromyatnikov2021-08-301-4/+4
| | | | | | | | | | | | The addition of the third inner loop to qual_fault test has pushed the test's execution time to the hight tens of seconds even on machines with fast fork/exec. Let's reduce its thoroughness a bit by reducing the number of variants of first/last/step values being checked from six down to four; that should decrease the number of check_fault_injection calls from 3040 down to 1200, a circa two-and-a-half-fold reduction. * tests/qual_fault.test: Remove two elements from each of the iteration lists for F, L, and S variables.
* Call get_proc_pid instead of translate_pid where only proc_pid is neededEugene Syromyatnikov2021-08-302-8/+4
| | | | | | | | | That makes the code a bit simpler. * src/pathtrace.c (getfdpath_pid): Assign get_proc_pid result to proc_pid instead of passing the latter to the translate_pid call. * src/secontext.c (selinux_getpidcon, selinux_getfdcon, selinux_getfilecon): Likewise.
* Pass PID instead of TCB pointer to get_proc_pidEugene Syromyatnikov2021-08-305-9/+8
| | | | | | | | | | | | | This allows its use for use cases where we do not have TCB setup for a PID to get /proc name for. * src/defs.h (get_proc_pid): Accept pid instead of tcp. * src/pidns.c (get_proc_pid): Accept pid instead of tcp, pass pid instead of tcp->pid to the translate_pid call. * src/mmap_cache.c (mmap_cache_rebuild_if_invalid): Pass tcp->pid instead of tcp to the get_proc_pid call. * src/strace.c (attach_tcb): Likewise. * src/util.c (getfdproto): Likewise.
* util, pidns: generalise get_id_listEugene Syromyatnikov2021-08-303-57/+88
| | | | | | | | | | | The parsing code implemented in it can be easily utilised for reading other /proc/pid/status fields (Uid/Gid, for example), so let's move it to util.c and make more generic. * src/defs.h (proc_status_get_id_list): New declaration. * src/util.c (proc_status_get_id_list): New function. * src/pidns.c (get_id_list): Implement as a proc_status_get_id_list wrapper.
* strace: make ptrace_attach_cmd localEugene Syromyatnikov2021-08-301-9/+11
| | | | | | | | | | | | Returning information from a function via a global variable is rather distasteful; moreover, wasting a pointer worth of memory for a variable used for error reporting is quite wasteful. * src/strace.c (ptrace_attach_cmd): Remove. (ptrace_attach_or_seize): Add ptrace_attach_cmd argument, assign cmd string literal to a pointer pointed by it. (attach_tcb, startup_child): Add ptrace_attach_cmd local variable, pass it to ptrace_attach_or_seize.
* tests: add prlimit64-success and prlimit64-success--pidns-translationEugene Syromyatnikov2021-08-306-16/+49
| | | | | | | | | | | | | | These may be useful in cases where prlimit64 syscall is not available. * tests/.gitignore: Add prlimit64-success and prlimit64-success--pidns-translation. * tests/Makefile.am (check_PROGRAMS): Likewise. * tests/gen_tests.in (prlimit64-success, prlimit64-success--pidns-translation): New tests. * tests/prlimit64-success--pidns-translation.c: New file. * tests/prlimit64-success.c: Likewise. * tests/prlimit64.c: Update to accomodate output when return value is injected.
* filter_qualify: fix indentation in check_inadvertent_fault_injectionEugene Syromyatnikov2021-08-301-21/+20
| | | | | | * src/filter_qualify.c (check_inadvertent_fault_injection): De-indent. Complements: v5.13-74-gb0dc9a1b3 "filter_qualify: factor out inadvertent fault injection check routine"
* Update ioctl entries from linux v5.14Gleb Fotengauer-Malinovskiy2021-08-255-0/+195
| | | | | | | | | * src/linux/32/ioctls_inc_align16.h: Update from linux v5.14-rc7-11-g6e764bcd1cf7 using ioctls_gen.sh. * src/linux/32/ioctls_inc_align32.h: Likewise. * src/linux/32/ioctls_inc_align64.h: Likewise. * src/linux/64/ioctls_inc.h: Likewise. * src/linux/x32/ioctls_inc0.h: Likewise.
* tests: call setsockopt directly in sockopt-timestampEugene Syromyatnikov2021-08-241-1/+30
| | | | | | | | | | | | | | | While commit v5.13-10-g0211fdc "tests: change sockopt-timestamp test to use syscall(__NR_recvmsg)" has fixed issues with glibc-induced mangling on newer kernels, the combination of an older kernel and new glibc still causes issues, as glibc silently falls back to SO_TIMESTAMP{,NS}_OLD, as implemented in glibc-2.34~294 "linux: Add fallback for 64-bit time_t SO_TIMESTAMP{NS}". Avoid that by calling setsockopt directly as well. * tests/sockopt-timestamp.c (SC_setsockopt): New macro constant. (k_setsockopt): New function. (test_sockopt): Call k_setsockopt instead of setsockopt. Complements: v5.13-10-g0211fdc "tests: change sockopt-timestamp test to use syscall(__NR_recvmsg)"
* filter_qualify: factor out inadvertent fault injection check routineEugene Syromyatnikov2021-08-241-34/+39
| | | | | | | | | | Move out a rather finicky inadvertent fault injection check in an attempt to make the humongous parse_inject_token function a bit more comprehensible. * src/filter_qualify.c (check_inadvertent_fault_injection): New function, factored out from... (parse_inject_token): ...here. Call check_inadvertent_fault_injection.
* src/unwind.c: avoid including libiberty.hEugene Syromyatnikov2021-08-241-2/+5
| | | | | | | | | | libiberty.h header that is pulled in by demangle.h is troublesome: it defines some macros and symbols that are also defined in strace's headers; since the definitions from there are not actually needed by neither unwind.c nor demangle.h, let's try to avoid its inclusion by defining its header guard. * src/unwind.c [USE_DEMANGLE] (LIBIBERTY_H): Define.
* defs.h: fix whitespace alignment for INJECT_F_SIGNAL and INJECT_F_RETVALEugene Syromyatnikov2021-08-241-2/+2
| | | | | | | * src/defs.h (INJECT_F_SIGNAL, INJECT_F_RETVAL): Fix spacing between the name and the value to align with other declarations. Complements: v5.0~98 "Fix preprocessor indentation"
* doc/strace.1.in: rewrite simultaneous signal and retval/error injection partEugene Syromyatnikov2021-08-241-3/+5
| | | | | | | It might as well be a bit clearer this way. * doc/strace.1.in (.SS Tampering): Rewrite description of the behaviour when both signal and retval/error injection are employed.
* src: use xobjdup/xarraydupEugene Syromyatnikov2021-08-245-23/+10
| | | | | | | | | | | * src/mmap_cache.c (mmap_cache_rebuild_if_invalid): Use xobjdup to duplicate mmap cache. * src/sg_io_v3.c (decode_request): Use xobjdup to copy sg_io into entering_sq_io. * src/sg_io_v4.c (decode_request): Likewise. * src/strace.c (copy_trace_wait_data): Use xopbjdup to duplicate wd. * src/syscall.c (tamper_with_syscall_entering): Use xarraydup to duplicate inject_vec.
* xmalloc: add xmemdup and xarraydup utility functionsEugene Syromyatnikov2021-08-242-1/+29
| | | | | | | | | | | There are multiple instances of using pair of x*alloc and memcpy calls to duplicate an entity; sometimes they even utilise xcalloc and perform unnecessary zeroing of the memory. Implement a separate routine that allows more compact code. * src/xmalloc.h (xmemdup, xarraydup): New declarations. (xobjdup): New macro, a wrapper for xmemdup. * src/xmalloc.c (xmemdup, xarraydup): New functions.
* syscall: use xallocarray instead of xcalloc for an array to be copied overEugene Syromyatnikov2021-08-221-1/+1
| | | | | | * src/syscall.c (tamper_with_syscall_entering): Allocate tcp->inject_vec[current_personality] with xallocarray instead of xcalloc, as it is to be overwritten by memcpy.
* doc/strace.1.in: mention poke_enter/poke_exit as valid inject actionsEugene Syromyatnikov2021-08-221-1/+3
| | | | | * doc/strace.1.in (.SS Tampering): Add poke_enter and poke_exit to the list of actions of which at least one hast to be specified.
* trie: optimise fill_value calculationEugene Syromyatnikov2021-08-221-6/+3
| | | | | | | | | | A closer look at the fill_value calculation code revealed that it was not implemented in an expected way: instead of doubling the shift and bitwise-OR'ing with itself, it bitwise-OR's with the original value, which led to 64/item_size iterations instead of 6 - item_size_lg; so, let's prematurely optimise this code further. * src/trie.c (trie_create): Rewrite fill_value field calculation.
* tee: rewrite num_params access in tee_fetch_buf_dataEugene Syromyatnikov2021-08-201-2/+3
| | | | | | | | | | | | | Pointer to num_params field of the fetched structure is passed in a separate function argument which provokes covscan complaints about uninitialised accesses and also tingles my aliasing rules senses. Rewrite to access it via the arg_struct argument which is fetched earlier in the function flow. * src/tee.c (TEE_FETCH_BUF_DATA): Change &arg_.num_params to offsetof(typeof(arg_), num_params). (tee_fetch_buf_data): Accept offset of the num_params field instead of pointer to it; reconstruct the num_params pointer using it.
* doc/strace.1.in: tfixEugene Syromyatnikov2021-08-201-1/+1
| | | | | doc/strace.1.in: Remove an excess space character in "\-\-summary\-syscall\-overhead".
* signal: simplify an expression for calculating signal mask size a bitEugene Syromyatnikov2021-08-201-1/+1
| | | | | | | | With all the cool macros we have now it can be rewritten into something a bit more comprehensible and easier to read. * src/signal.c (sprintsigmask_n): Rewrite size calculation using ROUNDUP_DIV and MIN.
* Update ioctl entries from linux v5.14Gleb Fotengauer-Malinovskiy2021-08-1913-205/+48
| | | | | | | | | | | | | | | | | * src/linux/32/ioctls_inc_align16.h: Update from linux v5.14-rc6 using ioctls_gen.sh. * src/linux/32/ioctls_inc_align32.h: Likewise. * src/linux/32/ioctls_inc_align64.h: Likewise. * src/linux/64/ioctls_inc.h: Likewise. * src/linux/x32/ioctls_inc0.h: Likewise. * src/linux/aarch64/ioctls_arch0.h: Likewise. * src/linux/i386/ioctls_arch0.h: Likewise. * src/linux/mips/ioctls_arch0.h: Likewise. * src/linux/powerpc/ioctls_arch0.h: Likewise. * src/linux/s390/ioctls_arch0.h: Likewise. * src/linux/s390x/ioctls_arch0.h: Likewise. * src/linux/x86_64/ioctls_arch0.h: Likewise. * NEWS: Mention this.
* maint: update for linux v5.14-rc6Gleb Fotengauer-Malinovskiy2021-08-191-1/+1
| | | | * maint/ioctls_sym.sh (x86_list): Add KVM_[SG]ET_SREGS2 ioctls.
* tests: replace AUDIO_STOP with NET_REMOVE_IF in ioctl_ubi testDmitry V. Levin2021-08-191-2/+2
| | | | | | | Do not use constants defined in <linux/dvb/audio.h> as the latter was moved to staging by Linux kernel commit v5.14-rc1~165^2~129. * tests/ioctl_ubi.c (main): Replace AUDIO_STOP with NET_REMOVE_IF.
* trie: cache fill_value value instead of calculating it each timeEugene Syromyatnikov2021-08-192-11/+14
| | | | | | | | | | | | trie_create_data_block may be a rather hot function if a trie is actively used; it seems wasteful to re-calculate fill_value each time a new data block is allocated, considering the fact that it, as well as empty_value, remains constant after the trie creation. Let's prematurely optimise it by pre-calculating the value in trie_create. * src/trie.h (struct trie): Add fill_value field. * src/trie.c (trie_create_data_block): Move fill_value calculation... (trie_create): ...here, assign it to the fill_value field.
* trie: use BIT* and MASK* macrosEugene Syromyatnikov2021-08-181-17/+17
| | | | | | | | | | | | | | | | This makes reading the code a bit easier. It also solves some issues where there is a hypothertical possibility of having bit shifts of size 64, by virtue of using the *_SAFE macros (that should silence some reported "left shifting by more than 63 bits has undefined behavior" covscan issues). * src/trie.c (trie_create): Use BIT32, MASK64. (trie_create_data_block): Use BIT32, change iterator variable type to size_t. (trie_get_node): Use BIT64, MASK64. (trie_data_block_calc_pos): Use BIT32, MASK64, MASK64_SAFE. (trie_iterate_keys_node): Use BIT64, MASK64, MASK64_SAFE. (trie_free_node): Use BIT64.
* pidns: remove the remaining leftover mention of btreeEugene Syromyatnikov2021-08-181-1/+1
| | | | | | | | | It was an original (incorrect) name of the supporting structure; see also [1]. [1] https://lists.strace.io/pipermail/strace-devel/2020-June/009805.html * src/pidns.c (ns_pid_to_proc_pid): Fix the comment.
* macros: expand BIT macros, add MASK macros; add *_SAFE macrosEugene Syromyatnikov2021-08-181-3/+27
| | | | | | | | | | | | | | | | | | These macros might make reading a code that often converts between powers of 2 and values/masks a bit easier; moreover, the *_SAFE versions should help in cases where the shift values are expected to be equal to the type bit width (which lead to UB otherwise). Switching from BIT to BIT32 should also clarify bitness, which may be somewhat murky at times (cf. printxval, printflags, and printxvals). * src/macros.h [!BIT] (BIT): Rename to... [!BIT32] (BIT32): ...this. [!BIT64] (BIT64): New macro. [!MASK32] (MASK32): Likewise. [!MASK64] (MASK64): Likewise. (BIT32_SAFE, BIT64_SAFE, MASK32_SAFE, MASK64_SAFE): New macros. (FLAG): Use BIT32.
* filter_qualify: free allocated data on the error path exit of parse_poke_tokenEugene Syromyatnikov2021-08-181-6/+12
| | | | | | | | | | | | | | | | While not terribly required due to the fact that issues with option parsing lead to program termination, these changes avoid leaking data allocated in the function's scope and not stored elsewhere, which might come handy if it ever be used dynamically during the runtime. This also has been reported as resource leaks by covscan, and these changes should calm it. * src/filter_qualify.c (parse_poke_token): Go to err label instead of returning right away; free poke->data, poke, and str_tokenized before returning false. References: https://bugzilla.redhat.com/show_bug.cgi?id=1995509
* tests: add prctl(PR_SET_PTRACER) testsEugene Syromyatnikov2021-08-1811-0/+119
| | | | | | | | | | | | | | | | | | | | | | | | | | * tests/.gitignore: Add prctl-set-ptracer-success, prctl-set-ptracer-success-Xabbrev, prctl-set-ptracer-success-Xraw, prctl-set-ptracer-success-Xverbose, prctl-set-ptracer-success--pidns-translation, prctl-set-ptracer-success-Xabbrev--pidns-translation, prctl-set-ptracer-success-Xraw--pidns-translation, and prctl-set-ptracer-success-Xverbose--pidns-translation. * tests/Makefile.am (check_PROGRAMS): Likewise. * tests/gen_tests.in (prctl-set-ptracer-success, prctl-set-ptracer-success-Xabbrev, prctl-set-ptracer-success-Xraw, prctl-set-ptracer-success-Xverbose, prctl-set-ptracer-success--pidns-translation, prctl-set-ptracer-success-Xabbrev--pidns-translation, prctl-set-ptracer-success-Xraw--pidns-translation, prctl-set-ptracer-success-Xverbose--pidns-translation): New tests. * tests/prctl-set-ptracer-success--pidns-translation.c: New file. * tests/prctl-set-ptracer-success-Xabbrev--pidns-translation.c: Likewise. * tests/prctl-set-ptracer-success-Xabbrev.c: Likewise. * tests/prctl-set-ptracer-success-Xraw--pidns-translation.c: Likewise. * tests/prctl-set-ptracer-success-Xraw.c: Likewise. * tests/prctl-set-ptracer-success-Xverbose--pidns-translation.c: Likewise. * tests/prctl-set-ptracer-success-Xverbose.c: Likewise. * tests/prctl-set-ptracer-success.c: Likewise.
* prctl: implement PR_SCHED_CORE op decodingEugene Syromyatnikov2021-08-1824-0/+289
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduced by Linux commit v5.14-rc1~6^2~50. * src/xlat/pr_sched_core_cmds.in: New file. * src/xlat/pr_sched_core_pidtypes.in: Likewise. * src/xlat/prctl_options.in (PR_SCHED_CORE): New constant. * src/prctl.c: Include "xlat/pr_sched_core_cmds.h", "xlat/pr_sched_core_pidtypes.h". (SYS_FUNC(prctl)) <case PR_SCHED_CORE>: Implement decoding. * tests/prctl-sched-core--pidns-translation-Xabbrev.c: New file. * tests/prctl-sched-core--pidns-translation-Xraw.c: Likewise. * tests/prctl-sched-core--pidns-translation-Xverbose.c: Likewise. * tests/prctl-sched-core--pidns-translation.c: Likewise. * tests/prctl-sched-core-Xabbrev.c: Likewise. * tests/prctl-sched-core-Xraw.c: Likewise. * tests/prctl-sched-core-Xverbose.c: Likewise. * tests/prctl-sched-core-success--pidns-translation-Xabbrev.c: Likewise. * tests/prctl-sched-core-success--pidns-translation-Xraw.c: Likewise. * tests/prctl-sched-core-success--pidns-translation-Xverbose.c: Likewise. * tests/prctl-sched-core-success--pidns-translation.c: Likewise. * tests/prctl-sched-core-success-Xabbrev.c: Likewise. * tests/prctl-sched-core-success-Xraw.c: Likewise. * tests/prctl-sched-core-success-Xverbose.c: Likewise. * tests/prctl-sched-core-success.c: Likewise. * tests/prctl-sched-core.c: Likewise. * tests/.gitignore: Add prctl-sched-core, prctl-sched-core-Xabbrev, prctl-sched-core-Xraw, prctl-sched-core-Xverbose, prctl-sched-core--pidns-translation, prctl-sched-core--pidns-translation-Xabbrev, prctl-sched-core--pidns-translation-Xraw, prctl-sched-core--pidns-translation-Xverbose, prctl-sched-core-success, prctl-sched-core-success-Xabbrev, prctl-sched-core-success-Xraw, prctl-sched-core-success-Xverbose, prctl-sched-core-success--pidns-translation, prctl-sched-core-success--pidns-translation-Xabbrev, prctl-sched-core-success--pidns-translation-Xraw, and prctl-sched-core-success--pidns-translation-Xverbose. * tests/Makefile.am (check_PROGRAMS): Add prctl-sched-core--pidns-translation, prctl-sched-core--pidns-translation-Xabbrev, prctl-sched-core--pidns-translation-Xraw, prctl-sched-core--pidns-translation-Xverbose, prctl-sched-core-success, prctl-sched-core-success-Xabbrev, prctl-sched-core-success-Xraw, prctl-sched-core-success-Xverbose, prctl-sched-core-success--pidns-translation, prctl-sched-core-success--pidns-translation-Xabbrev, prctl-sched-core-success--pidns-translation-Xraw, and prctl-sched-core-success--pidns-translation-Xverbose. * tests/gen_tests.in (prctl-sched-core, prctl-sched-core-Xabbrev, prctl-sched-core-Xraw, prctl-sched-core-Xverbose, prctl-sched-core--pidns-translation, prctl-sched-core--pidns-translation-Xabbrev, prctl-sched-core--pidns-translation-Xraw, prctl-sched-core--pidns-translation-Xverbose, prctl-sched-core-success, prctl-sched-core-success-Xabbrev, prctl-sched-core-success-Xraw, prctl-sched-core-success-Xverbose, prctl-sched-core-success--pidns-translation, prctl-sched-core-success--pidns-translation-Xabbrev, prctl-sched-core-success--pidns-translation-Xraw, and prctl-sched-core-success--pidns-translation-Xverbose): New tests. * tests/pure_executables.list: Add prctl-sched-core, prctl-sched-core-Xabbrev, prctl-sched-core-Xraw, and prctl-sched-core-Xverbose.
* tests: use prctl_markerDmitry V. Levin2021-08-1721-85/+38
| | | | | | | | | | | | | | | | | | | | | | | | * tests/prctl-arg2-intptr.c (main): Use prctl_marker. * tests/prctl-cap-ambient.c: Likewise. * tests/prctl-capbset.c: Likewise. * tests/prctl-dumpable.c: Likewise. * tests/prctl-fp-mode.c: Likewise. * tests/prctl-mce-kill.c: Likewise. * tests/prctl-name.c: Likewise. * tests/prctl-no-args.c: Likewise. * tests/prctl-pac-enabled-keys.c: Likewise. * tests/prctl-pac-reset-keys.c: Likewise. * tests/prctl-pdeathsig.c: Likewise. * tests/prctl-seccomp-filter-v.c: Likewise. * tests/prctl-seccomp-strict.c: Likewise. * tests/prctl-securebits.c: Likewise. * tests/prctl-spec-inject.c: Likewise. * tests/prctl-sve.c: Likewise. * tests/prctl-syscall-user-dispatch.c: Likewise. * tests/prctl-tagged-addr.c: Likewise. * tests/prctl-tid_address.c: Likewise. * tests/prctl-tsc.c: Likewise. * tests/prctl-unalign.c: Likewise.
* tests: introduce prctl_markerDmitry V. Levin2021-08-173-0/+26
| | | | | | | | | This helper invokes a prctl syscall with very specific arguments for use as a marker. * tests/prctl_marker.c: New file. * tests/Makefile.am (libtests_a_SOURCES): Add prctl_marker.c. * tests/tests.h (prctl_marker): New prototype.
* tests/prctl-success.sh: match strace output with -a value more than 79Eugene Syromyatnikov2021-08-171-1/+1
| | | | | | | | | | | | For some tests it is instructive to set -a to value more than 79; the issue is that this alignment width is more than the marker output, which leads to a match failure. To avoid that, allow for arbitrary number of spaces before the syscall return value. * tests/prctl-success.sh: Relax the regular expression to allow for arbitrary (non-zero) number of spaces. Complements: v5.13-49-g6f0be228b "tests/prctl.sh: match strace output with -a value more than 79"
* tests/prctl.sh: match strace output with -a value more than 79Eugene Syromyatnikov2021-08-141-1/+1
| | | | | | | | | | For some tests it is instructive to set -a to value more than 79; the issue is that this alignment width is more than the marker output, which leads to a match failure. To avoid that, allow for arbitrary number of spaces before the syscall return value. * tests/prctl.sh: Relax the regular expression to allow for arbitrary (non-zero) number of spaces.
* tests: move scno tampering check to init.shEugene Syromyatnikov2021-08-142-34/+39
| | | | | | | | And convert it to a function. * tests/init.sh (check_scno_tampering): New funtion, move the body from... * tests/scno_tampering.sh: ...here; call check_scno_tampering.
* prctl: print PR_SET_PTRACER_ANY numerical value as intEugene Syromyatnikov2021-08-141-2/+2
| | | | | | | | | While it is declared as (unsigned long)-1, there's little sense to print it as it is, since the comparison is ultimately done against arg2 casted to int. * src/prctl.c (SYS_FUNC(prctl)) <case PR_SET_PTRACER>: Cast arg2 to int when passing to print_xlat_ex; use XLAT_STYLE_FMT_D style.
* tests: convert prctl-fp-mode and prctl-spec-inject into generated testsEugene Syromyatnikov2021-08-146-79/+48
| | | | | | | | | | | | | And also avoid injecting values into prctl() calls issued by libc during process startup. * tests/Makefile.am (DECODER_TESTS): Remove prctl-fp-mode.test and prctl-spec-inject.test. * tests/gen_tests.in (prctl-fp-mode, prctl-spec-inject): New tests. * tests/prctl-fp-mode.test: Remove. * tests/prctl-spec-inject.test: Likewise. * tests/prctl-fp-mode.c: Implement injected return value locking sequence. * tests/prctl-spec-inject.c: Likewise.
* tests/prctl-success.sh: support error injectionEugene Syromyatnikov2021-08-141-3/+13
| | | | | * tests/prctl-success.sh: properly construct strace arguments and sed expression if an item that begins with "error=" occurs in PRCTL_INJECT_RETVALS.
* prctl: implement PR_PAC_[GS]ET_ENABLED_KEYS ops decodingEugene Syromyatnikov2021-08-1415-5/+200
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduced by Linux commit v5.13-rc1~17^2~18^2~1. * src/xlat/pr_pac_enabled_keys.in: New file. * src/xlat/pr_pac_keys.in (PR_PAC_APIAKEY, PR_PAC_APIBKEY, PR_PAC_APDAKEY, PR_PAC_APDBKEY): Remove entries that moved to src/xlat/pr_pac_enabled_keys.in. * src/prctl.c: Include "xlat/pr_pac_enabled_keys.h". (SYS_FUNC(prctl)) <case PR_PAC_SET_ENABLED_KEYS, case PR_PAC_GET_ENABLED_KEYS>: Implement decoding. (SYS_FUNC(prctl)) <case PR_PAC_RESET_KEYS>: Call printflags_ex with both pr_pac_enabled_keys and pr_pac_keys. * tests/.gitignore: Add prctl-pac-enabled-keys, prctl-pac-enabled-keys-Xabbrev, prctl-pac-enabled-keys-Xraw, prctl-pac-enabled-keys-Xverbose, prctl-pac-enabled-keys-success, prctl-pac-enabled-keys-success-Xabbrev, prctl-pac-enabled-keys-success-Xraw, and prctl-pac-enabled-keys-success-Xverbose. * tests/Makefile.am (check_PROGRAMS): Add prctl-pac-enabled-keys-success, prctl-pac-enabled-keys-success-Xabbrev, prctl-pac-enabled-keys-success-Xraw, and prctl-pac-enabled-keys-success-Xverbose. * tests/prctl-pac-enabled-keys-Xabbrev.c: New file. * tests/prctl-pac-enabled-keys-Xraw.c: Likewise. * tests/prctl-pac-enabled-keys-Xverbose.c: Likewise. * tests/prctl-pac-enabled-keys-success-Xabbrev.c: Likewise. * tests/prctl-pac-enabled-keys-success-Xraw.c: Likewise. * tests/prctl-pac-enabled-keys-success-Xverbose.c: Likewise. * tests/prctl-pac-enabled-keys-success.c: Likewise. * tests/prctl-pac-enabled-keys.c: Likewise. * tests/gen_tests.in (prctl-pac-enabled-keys, prctl-pac-enabled-keys-Xabbrev, prctl-pac-enabled-keys-Xraw, prctl-pac-enabled-keys-Xverbose, prctl-pac-enabled-keys-success, prctl-pac-enabled-keys-success-Xabbrev, prctl-pac-enabled-keys-success-Xraw, prctl-pac-enabled-keys-success-Xverbose): New tests. * tests/pure_executables.list: Add prctl-pac-enabled-keys, prctl-pac-enabled-keys-Xabbrev, prctl-pac-enabled-keys-Xraw, and prctl-pac-enabled-keys-Xverbose.
* prctl: use SPFF_AUXSTR_MODE for ops that use sprintflags for auxstrEugene Syromyatnikov2021-08-145-27/+42
| | | | | | | | | | | | | and also return RVAL_HEX flag in addition to RVAL_STR. * src/prctl.c (SYS_FUNC(prctl)) <case PR_GET_SECUREBITS, case PR_GET_FP_MODE, case PR_GET_SPECULATION_CTRL>: Use sprintflags_ex, pass SPFF_AUXSTR_MODE flag, return RVAL_HEX flag in addition to RVAL_STR. * tests/prctl-fp-mode.c: Update expected output. * tests/prctl-securebits.c: Likewise. * tests/prctl-spec-inject.c: Likewise. * tests/prctl-spec-inject.test: Add check for the injected value of 32.
* tests: add prctl-securebits-success* testsEugene Syromyatnikov2021-08-148-16/+81
| | | | | | | | | | | | | | | | * tests/.gitignore: Add prctl-securebits-success, prctl-securebits-success-Xabbrev, prctl-securebits-success-Xraw, and prctl-securebits-success-Xverbose. * tests/Makefile.am (check_PROGRAMS): Likewise. * tests/gen_tests.in(prctl-securebits-success, prctl-securebits-success-Xabbrev, prctl-securebits-success-Xraw, prctl-securebits-success-Xverbose): New tests. * tests/prctl-securebits-success-Xabbrev.c: New file. * tests/prctl-securebits-success-Xraw.c: Likewise. * tests/prctl-securebits-success-Xverbose.c: Likewise. * tests/prctl-securebits-success.c: Likewise. * tests/prctl-securebits.c: Add injected-based and xlat-verbosity-varied checks support.
* xlat: add auxval mode to sprintflags_exEugene Syromyatnikov2021-08-142-7/+18
| | | | | | | | | | | | | | | | | | sprintflags is often used to decode flag set returned by a syscall; it, however, looks somewhat ugly when collided with xlat styles (and even without it, somewhat superfluous[1] when values that do not match any flags are printed). Introduce a special mode that makes sprintflags output more akin to XLAT_STYLE_VERBOSE comment (except when XLAT_STYLE_RAW is used). [1] It may be seen useful as the default return value format is decimal and sprintflags uses hex, but at least fcntl always prints flags in return values as RVAL_HEX anyway. * src/defs.h (enum xlat_style_private_flag_bits) <SPFF_AUXSTR_MODE_BIT>: New flag bit. (enum xlat_style_private_flags) <SPFF_AUXSTR_MODE>: New flag. * src/xlat.c (sprintflags_ex): Handle SPFF_AUXSTR_MODE flag in style.
* prctl: implement PR_[GS]ET_TAGGED_ADDR_CTRL op decodingEugene Syromyatnikov2021-08-1417-3/+301
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduced by Linux commit v5.4-rc1~100^2~6^9~8 and extended in Linux commits v5.10-rc1~49^2~9^2~12 and v5.10-rc1~49^2~9^2~11. * src/xlat/pr_tagged_addr_enable.in: New file. * src/xlat/pr_tagged_addr_mte_tcf.in: Likewise. * src/prctl.c: Include "xlat/pr_tagged_addr_enable.h" and "xlat/pr_tagged_addr_mte_tcf.h". (sprint_tagged_addr_val): New function. (SYS_FUNC(prctl)) <case PR_SET_TAGGED_ADDR_CTRL, case PR_GET_TAGGED_ADDR_CTRL>: Implement arg2/retval decoding. * tests/.gitignore: Add prctl-tagged-addr, prctl-tagged-addr-Xabbrev, prctl-tagged-addr-Xraw, prctl-tagged-addr-Xverbose, prctl-tagged-addr-success, prctl-tagged-addr-success-Xabbrev, prctl-tagged-addr-success-Xraw, and prctl-tagged-addr-success-Xverbose. * tests/Makefile.am (check_PROGRAMS): Add prctl-tagged-addr-success, prctl-tagged-addr-success-Xabbrev, prctl-tagged-addr-success-Xraw, and prctl-tagged-addr-success-Xverbose. (EXTRA_DIST): Add prctl-success.sh. * tests/gen_tests.in (prctl-tagged-addr, prctl-tagged-addr-Xabbrev, prctl-tagged-addr-Xraw, prctl-tagged-addr-Xverbose, prctl-tagged-addr-success, prctl-tagged-addr-success-Xabbrev, prctl-tagged-addr-success-Xraw, prctl-tagged-addr-success-Xverbose): New tests. * tests/prctl-no-args.c (main) <options>: Remove PR_GET_TAGGED_ADDR_CTRL. * tests/prctl-success.sh: New file. * tests/prctl-tagged-addr-Xabbrev.c: Likewise. * tests/prctl-tagged-addr-Xraw.c: Likewise. * tests/prctl-tagged-addr-Xverbose.c: Likewise. * tests/prctl-tagged-addr-success-Xabbrev.c: Likewise. * tests/prctl-tagged-addr-success-Xraw.c: Likewise. * tests/prctl-tagged-addr-success-Xverbose.c: Likewise. * tests/prctl-tagged-addr-success.c: Likewise. * tests/prctl-tagged-addr.c: Likewise. * tests/pure_executables.list: Add prctl-tagged-addr, prctl-tagged-addr-Xabbrev, prctl-tagged-addr-Xraw, and prctl-tagged-addr-Xverbose.
* xlat/gen.sh: call read with "-r" optionEugene Syromyatnikov2021-08-141-2/+2
| | | | | | | There is no need to support backslashes interpretation and the xlat input is somewhat user-provided, so it is better to safeguard it a bit. * src/xlat/gen.sh: Call read with "-r" option.
* src/Makefile.am: whitespace fixesEugene Syromyatnikov2021-08-111-3/+3
| | | | | * src/Makefile.am (libstrace_a_SOURCES, EXTRA_DIST): Remove spaces before tabs.