summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* prctl: implement PR_[GS]ET_MDWE decodingesyr/prctl-mdweEugene Syromyatnikov2023-04-287-4/+176
| | | | | | | | | | | | | | Introduced by Linux commit v6.3-rc1~113^2~215. * src/xlat/pr_mdwe_flags.in: New file. * src/prctl.c: Include "xlat/pr_mdwe_flags.h". (SYS_FUNC(prctl)) <case PR_SET_MDWE, case PR_GET_MDWE>: Implement command decoders. * tests/.gitignore: Add prctl-mdwe. * tests/Makefile.am (check_PROGRAMS): Add prctl-mdwe. * tests/gen_tests.in (prctl-mdwe): New test. * tests/prctl-mdwe.c: New file. * NEWS: Mention it.
* io_uring: rename pad field of io_uring_buf_reg to flagsDmitry V. Levin2023-04-283-9/+7
| | | | | | | | * bundled/linux/include/uapi/linux/io_uring.h (struct io_uring_buf_reg): Rename pad to flags following the change introduced by Linux kernel commit v6.3-rc5-6-g81cf17cd3ab3. * src/io_uring.c (print_io_uring_buf_reg): Likewise. * tests/io_uring_register.c (main): Likewise.
* xlat: update V4L2_PIX_FMT_* constantsDmitry V. Levin2023-04-282-1/+7
| | | | | | | | | * src/xlat/v4l2_pix_fmts.in (V4L2_PIX_FMT_RGBX1010102, V4L2_PIX_FMT_RGBA1010102, V4L2_PIX_FMT_ARGB2101010): New constants introduced by Linux kernel commit v6.3-rc1~28^2~19^2~18. (V4L2_PIX_FMT_Y210, V4L2_PIX_FMT_Y212, V4L2_PIX_FMT_Y216): New constants introduced by Linux kernel commit v6.3-rc1~28^2~19^2~17. * NEWS: Mention this.
* xlat: update TCA_* constantsDmitry V. Levin2023-04-283-3/+5
| | | | | | | * src/xlat/rtnl_tc_attrs.in (TCA_EXT_WARN_MSG): New constant introduced by Linux kernel commit v6.3-rc1~162^2~279. * src/rtnl_tc.c (tcmsg_nla_decoders): Add TCA_EXT_WARN_MSG. * NEWS: Mention this.
* xlat: update PR_* constantsDmitry V. Levin2023-04-283-1/+5
| | | | | | | * src/xlat/prctl_options.in (PR_SET_MDWE, PR_GET_MDWE): New constants introduced by Linux kernel commit v6.3-rc1~113^2~215. * src/prctl.c (SYS_FUNC(prctl)): Handle them. * NEWS: Mention this.
* xlat: update NFT_MSG_* constantsDmitry V. Levin2023-04-283-1/+16
| | | | | | | | | * src/xlat/nf_nftables_msg_types.in (NFT_MSG_DESTROYTABLE, NFT_MSG_DESTROYCHAIN, NFT_MSG_DESTROYRULE, NFT_MSG_DESTROYSET, NFT_MSG_DESTROYSETELEM, NFT_MSG_DESTROYOBJ, NFT_MSG_DESTROYFLOWTABLE): New constants introduced by Linux kernel commit v6.3-rc1~162^2~264^2. * src/netlink.c (decode_nlmsg_flags_netfilter): Handle them. * NEWS: Mention this.
* xlat: update MFD_* constantsDmitry V. Levin2023-04-283-6/+9
| | | | | | | * src/xlat/memfd_create_flags.in (MFD_NOEXEC_SEAL, MFD_EXEC): New constants introduced by Linux kernel commit v6.3-rc1~113^2~502. * tests/memfd_create.c (main): Update expected output. * NEWS: Mention this.
* xlat: update IORING_* constantsDmitry V. Levin2023-04-282-1/+2
| | | | | | * src/xlat/uring_setup_features.in (IORING_FEAT_REG_REG_RING): New constant introduced by Linux kernel commit v6.3-rc1~209^2. * NEWS: Mention this.
* xlat: update IP_* constantsDmitry V. Levin2023-04-282-1/+2
| | | | | | * src/xlat/sock_ip_options.in (IP_LOCAL_PORT_RANGE): New constant introduced by Linux kernel commit v6.3-rc1~162^2~206^2~1. * NEWS: Mention this.
* xlat: update IFLA_BRPORT_* constantsDmitry V. Levin2023-04-285-4/+13
| | | | | | | | | | | * src/xlat/rtnl_ifla_brport_attrs.in (IFLA_BRPORT_MCAST_N_GROUPS, IFLA_BRPORT_MCAST_MAX_GROUPS): New constants introduced by Linux kernel commit v6.3-rc1~162^2~139^2~8. * src/rtnl_link.c (ifla_brport_nla_decoders): Add IFLA_BRPORT_MCAST_N_GROUPS and IFLA_BRPORT_MCAST_MAX_GROUPS. * tests/nlattr_ifla_brport.c (main): Update expected output. * tests/nlattr_ifla_linkinfo.c (main): Likewise. * NEWS: Mention this.
* xlat: update IFLA_* constantsDmitry V. Levin2023-04-283-1/+7
| | | | | | | | | * src/xlat/rtnl_link_attrs.in (IFLA_GSO_IPV4_MAX_SIZE, IFLA_GRO_IPV4_MAX_SIZE): New constants introduced by Linux kernel commit v6.3-rc1~162^2~162^2~1. * src/rtnl_link.c (ifinfomsg_nla_decoders): Add IFLA_GSO_IPV4_MAX_SIZE and IFLA_GRO_IPV4_MAX_SIZE. * NEWS: Mention this.
* xlat: update F_SEAL_* constantsDmitry V. Levin2023-04-282-0/+2
| | | | | | * xlat/f_seals.in (F_SEAL_EXEC): New constant introduced by Linux kernel commit v6.3-rc1~113^2~504. * NEWS: Mention this.
* bundled: update linux UAPI headers to v6.3-rc7Dmitry V. Levin2023-04-2815-7/+74
| | | | | | | | | | | | | | | | | | | * bundled/linux/include/uapi/linux/btrfs.h: Update to headers_install'ed Linux kernel v6.3-rc7. * bundled/linux/include/uapi/linux/dcbnl.h: Likewise. * bundled/linux/include/uapi/linux/fcntl.h: Likewise. * bundled/linux/include/uapi/linux/if_bridge.h: Likewise. * bundled/linux/include/uapi/linux/if_link.h: Likewise. * bundled/linux/include/uapi/linux/in.h: Likewise. * bundled/linux/include/uapi/linux/io_uring.h: Likewise. * bundled/linux/include/uapi/linux/memfd.h: Likewise. * bundled/linux/include/uapi/linux/netfilter/nf_tables.h: Likewise. * bundled/linux/include/uapi/linux/netfilter/nfnetlink_cttimeout.h: Likewise. * bundled/linux/include/uapi/linux/prctl.h: Likewise. * bundled/linux/include/uapi/linux/rtnetlink.h: Likewise. * bundled/linux/include/uapi/linux/v4l2-controls.h: Likewise. * bundled/linux/include/uapi/linux/version.h: Likewise. * bundled/linux/include/uapi/linux/videodev2.h: Likewise.
* tests: fix strace--syscall-limit testDmitry V. Levin2023-04-282-4/+13
| | | | | | | | | | * tests/strace--syscall-limit.c: Include "scno.h" and <fcntl.h>. (test_rmdir): Invoke unlinkat syscall instead of rmdir because the latter is not guaranteed to be present on all architectures nowadays. * tests/strace--syscall-limit.test: Filter unlinkat syscall instead of rmdir. Fixes: v6.2-15-g628b7eb7449e "tests: check -l/--syscall-limit options"
* tests/prctl-sve: fix prctl(PR_SVE_GET_VL) return expected value printingesyr/tests-prctl-sve-fixEugene Syromyatnikov2023-04-271-4/+20
| | | | | | | | | * tests/prctl-sve.c: Print the expected return value string based on the value returned, similarly to the way it is done in tests/prctl-sme.c:print_sme_vl_arg(). Fixes: v5.13~8 "tests: improve test coverage of prctl syscall decoder" Closes: https://github.com/strace/strace/issues/251
* tests/gen_tests: remove redundant optionSahil Siddiq2023-04-241-1/+1
| | | | | | | | | | | | | --trace=all option for strace--syscall-limit-path in gen_tests.in can be omitted. Only 'chdir' and 'rmdir' are used to access 'invalid.dir' in the test and --trace='chdir,rmdir' is set in the corresponding bash script. * tests/gen_tests.in (strace--syscall-limit-path): Remove --trace=all option. Signed-off-by: Sahil Siddiq <icegambit91@gmail.com>
* tests: expand symlink test, add symlink-P testEugene Syromyatnikov2023-04-225-3/+45
| | | | | | | | | | | * tests/.gitignore: Add symlink-P. * tests/Makefile.am (check_PROGRAMS): Likewise. * tests/gen_tests.in (symlink): Change the alignment from 32 to 20 columns. (symlink-P): New test. * tests/symlink-P.c: New file. * tests/symlink.c: Add checks, print the output based on the presence of the PATH_TRACING macro.
* tests: expand link test, add link-P testEugene Syromyatnikov2023-04-225-5/+48
| | | | | | | | | | * tests/.gitignore: Add link-P. * tests/Makefile.am (check_PROGRAMS): Likewise. * tests/gen_tests.in (link): Add -a17 option. (link-P): New test. * tests/link-P.c: New file. * tests/link.c: Add checks, print the output based on the presence of the PATH_TRACING macro.
* Implement an ability to filter syscalls that operate on specific FDsEugene Syromyatnikov2023-04-2233-107/+449
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce -e trace-fds= qualifier that allows specifying a set of FDs of interest, operations on which are to be traced. Works in conjunction (or, more specifically, inclusive disjunction) with the path tracing functionality. * src/defs.h: Include "number_set.h". (tracing_fds): New external variable. (pathtrace_match_set): Add new fdset argument to the declaration. (pathtrace_match): Pass trace_fd_set in the new argument to the pathtrace_match_set call. (qualify_trace_fd): New function declaration. * src/filter_qualify.c (trace_fd_set): New variable. (qualify_trace_fd): New function. (qual_options): Add various FD tracing-related items. * src/number_set.h (trace_fd_set): New external variable declaration. * src/pathtrace.c (pathmatch, upathmatch): Bail out if set is NULL. (fdmatch): Add fdset argument, check fd for non-negativity and presence in fdset if fdset is non-NULL. (match_xselect_args): Add fdset argument, pass it to the fdmatch call. (pathtrace_match_set): Add fdset argument, pass it to fdmatch and match_xselect_args calls. * src/syscall.c (syscall_entering_trace): Check tracing_fds in addition to tracing_paths as a predicate for performing pathtrace_match check. * src/strace.c (tracing_fds): New variable. (init) <GETOPT_QUAL_TRACE_FD>: New enum item. (init) <longopts>: Add"trace-fds" option. (init) <case GETOPT_QUAL_TRACE_FD>: Call qualify_trace_fd. (usage): Document -e trace-fds. * doc/strace.1.in: Likewise. * tests/.gitignore: Add dup-trace-fds-0, dup-trace-fds-0-9, dup-trace-fds-0-P, dup-trace-fds-not-9, dup2-e-fd-0, dup2-e-fd-0-9, dup2-e-fd-0-P, dup2-e-fd-not-9, ppoll-e-trace-fds-23, ppoll-e-trace-fds-23-42, ppoll-e-trace-fds-not-9-42-P, select-trace-fd-7, select-trace-fd-7-9, and select-trace-fd-7-P. * tests/Makefile.am (check_PROGRAMS): Add ppoll-e-trace-fds-23, ppoll-e-trace-fds-23-42, ppoll-e-trace-fds-not-9-42-P, select-trace-fd-7, select-trace-fd-7-9, and select-trace-fd-7-P. * tests/dup-P.c (PATH_TRACING): Set to 1. * tests/dup2-P.c (PATH_TRACING): Likewise. * tests/dup.c: Accommodate test for checking tracing-fds functionality. * tests/dup2.c: Likewise. * tests/ppoll.c: Likewise. * tests/xselect.c: Likewise. * tests/gen_tests.in (dup-trace-fds-0, dup-trace-fds-0-9, dup-trace-fds-0-P, dup-trace-fds-not-9, dup2-e-fd-0, dup2-e-fd-0-9, dup2-e-fd-0-P, dup2-e-fd-not-9, ppoll-e-trace-fds-23, ppoll-e-trace-fds-23-42, ppoll-e-trace-fds-not-9-42-P, select-trace-fd-7, select-trace-fd-7-9, select-trace-fd-7-P): New tests. * tests/options-syntax.test: Add trace-fds-related option syntax checks. * tests/pure_executables.list: Add dup-trace-fds-0, dup-trace-fds-0-9, dup-trace-fds-0-P, dup-trace-fds-not-9, dup2-e-fd-0, dup2-e-fd-0-9, dup2-e-fd-0-P, and dup2-e-fd-not-9. * tests/dup-trace-fds-0-9.c: New file. * tests/dup-trace-fds-0-P.c: Likewise. * tests/dup-trace-fds-0.c: Likewise. * tests/dup-trace-fds-not-9.c: Likewise. * tests/dup2-e-fd-0-9.c: Likewise. * tests/dup2-e-fd-0-P.c: Likewise. * tests/dup2-e-fd-0.c: Likewise. * tests/dup2-e-fd-not-9.c: Likewise. * tests/ppoll-e-trace-fds-23-42.c: Likewise. * tests/ppoll-e-trace-fds-23.c: Likewise. * tests/ppoll-e-trace-fds-not-9-42-P.c: Likewise. * tests/select-trace-fd-7-9.c: Likewise. * tests/select-trace-fd-7-P.c: Likewise. * tests/select-trace-fd-7.c: Likewise. * NEWS: Mention it. Suggested-by: Marty Leisner <maleisner@gmail.com> Link: https://lists.strace.io/pipermail/strace-devel/2023-March/011209.html
* strauss: add a couple of new tipsEugene Syromyatnikov2023-04-221-0/+17
| | | | | | * src/strauss.c (tips_tricks_tweaks): Add a note about the historical handling of "(deleted)" in file paths got from procfs and about system time accounting.
* strauss: rely on strace--tips test instead of forcibly trimming linesEugene Syromyatnikov2023-04-221-2/+2
| | | | | | | | | | | | | | | | | The regression introduced in commit v5.19~99 "strauss: tips whitespace and phrasing cleanups" (and subsequently fixed in v6.2-6-g5b4f05f42 "strauss: add missing line separators") highlights the issue with the current approach with respect to tips formatting: it masks the issues related to overlong lines in favor to the pretty formatting; however, the presence of a (working) strace--tips test, that checks the correctness of the tips rendering, makes this trimming superfluous. Drop it and rely on the testing with respect to the guaranteeing the proper wrapping of (overly) long tip lines. * src/strauss.c (print_totd): Do not provide precision to the format specification that prints tip line. References: v6.2-6-g5b4f05f42 "strauss: add missing line separators"
* tests: fix strace--tips testEugene Syromyatnikov2023-04-221-23/+30
| | | | | | | | | | | | | | | | | | | | Apparently, it has been broken in many places and checked the output incorrectly, so it was basically useless. Make it a bit less broken by properly escaping all the regular expressions and implement the logic that actually checks the output against the expected patterns. * tests/strace--tips.test (IFS): Set the variable to avoid stripping whitespace from the read lines. (grep_ere_escape): A variant of sed_re_escape that also escapes "{", "}", and "|" characters. Add "-r" option to the read call to avoid interpreting backslashes, especially at the end of the line; escape "|", "/", and "\" characters in $pat/$end/$btm definitions and fix the whitespace usage in there; use grep_ere_escape instead of sed_re_escape; break after matching one last line against $btm if TIPS_FULL is not set; pass "-x" option to the grep calls. Fixes: v5.18~38 "Raise strace awareness"
* tests: double quote array expansions to avoid re-splitting elementsDmitry V. Levin2023-04-043-3/+3
| | | | This fixes shellcheck SC2068.
* tests: check -l/--syscall-limit optionsSahil Siddiq2023-04-038-0/+175
| | | | | | | | | | | | | | | | | | | | | These tests check the correctness of -l/--syscall-limit options when used with --trace, --trace-path and --status options. * tests/options-syntax.test: Check for invalid -l/--syscall-limit arguments. * tests/strace--syscall-limit.c: New file. * tests/strace--syscall-limit-path.c: Likewise. * tests/strace--syscall-limit-status.c: Likewise. * tests/strace--syscall-limit.test: New test. * tests/.gitignore: Add strace--syscall-limit, strace--syscall-limit-path, and strace--syscall-limit-status. * tests/Makefile.am (check_PROGRAMS): Likewise. (MISC_TESTS): Add strace--syscall-limit.test. * tests/gen_tests.in (strace--syscall-limit-path, strace--syscall-limit-status): New entries. Signed-off-by: Sahil Siddiq <icegambit91@gmail.com> Co-authored-by: Dmitry V. Levin <ldv@strace.io>
* Document new -l/--syscall-limit optionsSahil Siddiq2023-04-032-0/+16
| | | | | | | * doc/strace.1.in: Document -l/--syscall-limit options. * NEWS: Mention them. Signed-off-by: Sahil Siddiq <icegambit91@gmail.com>
* Introduce -l/--syscall-limit optionsSahil Siddiq2023-04-033-1/+23
| | | | | | | | | | | | | | | Add new options to detach strace after capturing the specified number of syscalls. * src/defs.h (syscall_limit): New variable declaration. * src/strace.c (syscall_limit): New variable. (usage): Mention new options. (init): Handle them. (next_event): Break the event loop when syscall_limit == 0. * src/syscall.c (syscall_exiting_trace): Update syscall_limit. Signed-off-by: Sahil Siddiq <icegambit91@gmail.com> Resolves: https://github.com/strace/strace/issues/179
* open_by_handle_at: add RVAL_FD to return valueKossi Glokpor2023-04-031-1/+1
| | | | | | | | | | Mark the return value of open_by_handle_at decoder as a file descriptor. * src/file_handle.c (SYS_FUNC(open_by_handle_at)): Add RVAL_FD flag to the return value. Signed-off-by: Kossi Glokpor <hotkatz32@gmail.com> Fixes: v4.11~121 "Implement name_to_handle_at and open_by_handle_at syscalls decoding"
* tests/membarrier: add new combination of flagsSven Schnelle2023-03-311-0/+12
| | | | | | | | | linux v6.3 reports a new combination of flags when ARCH_HAS_MEMBARRIER_SYNC_CORE is enabled. Signed-off-by: Sven Schnelle <svens@linux.ibm.com> * tests/membarrier.c (main): Update expected output.
* Make --tips more easily availableDmitry V. Levin2023-04-015-1/+21
| | | | | | | | | | | | | | Allow --tips option to be used without any tracing, so that tips, tricks and tweaks could be displayed without running any program or attaching to any process. * src/strace.c (init): When --tips is specified without running any program or attaching to any process, show the tips and exit. * tests/strace--tips-0.exp: New file. * tests/Makefile.am (check_DATA): Add it. * tests/strace--tips.test: Check that simple "strace --tips=0" works as expected. * tests/options-syntax.test: Update expected output.
* treewide: fix unnecessary $ on arithmetic variablesDmitry V. Levin2023-03-3020-31/+31
| | | | This silences shellcheck SC2004.
* Update ioctl entries from linux v6.3Gleb Fotengauer-Malinovskiy2023-03-278-405/+101
| | | | | | | | | | | | * src/linux/32/ioctls_inc_align16.h: Update from linux v6.3-rc4 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/s390/ioctls_arch0.h: Likewise. * src/linux/s390x/ioctls_arch0.h: Likewise. * NEWS: Mention this.
* debian/control: fix wording in descriptionadrien-n2023-03-201-3/+3
| | | | | | | | | This commit incorporates a change from Debian's packaging: "a another" is replaced with "another". Note that there is another change in Debian packaging which I'm skipping on purpose since it is not correct as far as I know: "tracer, i.e." becoming "tracer: i.e.".
* strauss: add missing line separatorsJakub Wilk2023-03-101-4/+4
| | | | | | | * src/strauss.c (tips_tricks_tweaks): Add missing line separators. (MAX_TIP_LINES): Bump. Resolves: https://github.com/strace/strace/pull/245
* Add config3 field to struct perf_event_attrSven Schnelle2023-03-094-1/+20
| | | | | | | | | | | | | | | | Linux kernel commit 09519ec3b19 ("perf: Add perf_event_attr::config3") aka v6.3-rc1~29^2~13 added a new config3 field to struct perf_event_attr. Add this field and implement its decoding in strace, which also fixes compilation of tests because of an array out-of-bounds warning in tests/perf_event.c. Signed-off-by: Sven Schnelle <svens@linux.ibm.com> * bundled/linux/include/uapi/linux/perf_event.h: Update to headers_install'ed Linux kernel v6.3-rc1. * src/perf_event_struct.h (struct perf_event_attr): Add config3 field. * src/perf.c (print_perf_event_attr): Print config3 field. * tests/perf_event_open.c (print_event_attr): Check it.
* Add a configure flag for installing testsElvira Khabirova2023-03-052-0/+20
| | | | | | | | | | | | | | | | | | | | --enable-install-tests=yes installs binaries and scripts from the test suite to $libexec/strace. This flag does not install everything necessary to run the test suite (no harness), but at least installs the binaries and the scripts. This can be useful when debugging various targets and how strace behaves on them. This can also be extended later with a standalone test harness that would allow for an easier testing. * configure.ac: Add --enable-install-tests. * tests/Makefile.am [ENABLE_INSTALL_TESTS] (testslibexecdir, testslibexec_PROGRAMS, testslibexec_DATA, testslibexec_SCRIPTS): New variables. Signed-off-by: Elvira Khabirova <lineprinter0@gmail.com>
* tests: split EXTRA_DISTElvira Khabirova2023-03-051-77/+86
| | | | | | | | | | | | | Split EXTRA_DIST into check_SCRIPTS, check_DATA and EXTRA_DIST. Place scripts required for running the tests into check_SCRIPTS, auxiliary files required for running the tests into check_DATA, and everything else (= build-time required) into EXTRA_DIST. * tests/Makefile.am (check_SCRIPTS, check_DATA): New variables. (EXTRA_DIST): Shrink. Use check_SCRIPTS and check_DATA. Signed-off-by: Elvira Khabirova <lineprinter0@gmail.com>
* mips: fix raw_syscall_0Elvira Khabirova2023-03-051-3/+13
| | | | | | | | | | | | | | | | | | | | | Some of the tests use a custom function (raw_syscall_0) for syscall invocation. The implementation for mips was flawed: it unconditionally clobbered "hi" and "lo", which is not valid for MIPS R6, because these targets lack those registers w/o DSP extension. GCC 10+ refuses to compile such constructs: [1], [2]. Fix the syscall invocation implementation for mips. [1] https://gcc.gnu.org/git/?p=gcc.git&a=commit;h=0a59215131c02dee4c8829f93d1ee678647614da [2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91233 * src/linux/mips/raw_syscall.h (SYSCALL_CLOBBERLIST): Define. (raw_syscall_0): Use it. Signed-off-by: Elvira Khabirova <lineprinter0@gmail.com>
* Post-release administriviaDmitry V. Levin2023-02-273-0/+14
| | | | | | * NEWS: Add a header line for the next release. * debian/changelog.in: Add a changelog entry for 6.2-1. * strace.spec.in: Likewise.
* Prepare for 6.2 releasev6.2Dmitry V. Levin2023-02-261-1/+1
| | | | * NEWS: Update for 6.2 release.
* Update copyright headersDmitry V. Levin2023-02-2660-54/+60
| | | | | Headers updated automatically using maint/update_copyright_years.sh script.
* Fix build on alphaDmitry V. Levin2023-02-244-8/+13
| | | | | | | | | | | | | | Workaround a bug in glibc headers that fail to provide si_trapno field in their definition of siginfo_t on alpha. Link: https://sourceware.org/bugzilla/show_bug.cgi?id=30173 Resolves: https://github.com/strace/strace/issues/220 * configure.ac (AC_CHECK_MEMBERS): Add siginfo_t.si_trapno. * src/printsiginfo.c [ALPHA]: Guard use of si_trapno with HAVE_SIGINFO_T_SI_TRAPNO. * tests/ptrace.c [ALPHA]: Likewise. * NEWS: Mention this fix.
* filter_seccomp: do not call PR_SET_NO_NEW_PRIVS if privileged enoughDmitry V. Levin2023-02-231-5/+11
| | | | | | | | | If strace process is privileged enough to add SECCOMP_MODE_FILTER without PR_SET_NO_NEW_PRIVS, there is no need to do the latter. * src/filter_seccomp.c (init_seccomp_filter): Try to add SECCOMP_MODE_FILTER first, and if it failed with EACCES, do PR_SET_NO_NEW_PRIVS and try to add SECCOMP_MODE_FILTER again.
* NEWS: mention collision resolution for overlapping ioctl commandsMasatake YAMATO2023-02-221-0/+2
| | | | | | Resolves: https://github.com/strace/strace/pull/239 Signed-off-by: Masatake YAMATO <yamato@redhat.com> Signed-off-by: Dmitry V. Levin <ldv@strace.io>
* dyxlat: make the type of the xlat created by dyxlat_alloc customizableMasatake YAMATO2023-02-213-4/+4
| | | | | | | | | | * src/defs.h (dyxlat_alloc): Add xlat_type argument. * src/dyxlat.c (dyxlat_alloc): Likewise. * src/socketutils.c (genl_families_xlat): Pass XT_NORMAL to dyxlat_alloc invocation. Signed-off-by: Masatake YAMATO <yamato@redhat.com> Signed-off-by: Dmitry V. Levin <ldv@strace.io>
* ioctl: use finfo as hints for resolving overlapping ioctl commandsMasatake YAMATO2023-02-205-8/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Such an overlapping can be observed, e.g. when running vi under strace: ioctl(0, SNDCTL_TMR_START or TCSETS, {B38400 ... After this change, when the file descriptor corresponds to a terminal device, strace would be able to resolve the collision between ioctl commands from different subsystems: ioctl(0, TCSETS, {B38400 ... * src/defs.h (term_ioctl_decode_command_number): New function declaration. * src/ioctl.c (ioctl_decode_command_number): Add a new argument for passing finfo that can be used as hints for decoding ioctl commands. Handle the code `T'. (SYS_FUNC(ioctl)): Pass finfo as hints to ioctl_decode_command_number. * src/term.c: Include "xlat/term_cmds_overlapping.h". (term_ioctl_decode_command_number): Decode the command in this earlier stage if the corresponding file descriptor corresponds to a terminal device. * src/xlat/term_cmds_overlapping.in: New file listing overlapping tty ioctl commands. * tests/ioctl_termios.c (main): Extend cmds[] in checks[]. (main::checks::cmds): Add new member "pass_invalid_fd". Omit " or ..." substring in case of TCSETS, TCSETSW, and TCSETSF for a valid tty descriptor. Add test commands for invalid descriptors. Signed-off-by: Masatake YAMATO <yamato@redhat.com> Signed-off-by: Dmitry V. Levin <ldv@strace.io>
* ioctl: pass finfo to ioctl_decode() as hints for decodingMasatake YAMATO2023-02-201-3/+8
| | | | | | | | | | Just pass the data, a real use case comes in subsequent commits. * src/ioctl.c (ioctl_decode): Add "finfo" argument. (SYS_FUNC(ioctl)): Pass the finfo for the target fd to ioctl_decode. Signed-off-by: Masatake YAMATO <yamato@redhat.com> Signed-off-by: Dmitry V. Levin <ldv@strace.io>
* ioctl: prepare finfo only when ioctl command can overlapMasatake YAMATO2023-02-201-1/+12
| | | | | | | | | | | | If an ioctl decoder does not deal with overlapping commands, avoid issuing extra syscalls required to obtain finfo. * src/ioctl.c (ioctl_command_overlaps): New function. (SYS_FUNC(ioctl)): Call getfdpath_pid only when ioctl_command_overlaps returns true. Signed-off-by: Masatake YAMATO <yamato@redhat.com> Signed-off-by: Dmitry V. Levin <ldv@strace.io>
* ioctl: collect finfo just before decoding ioctl commandMasatake YAMATO2023-02-203-2/+22
| | | | | | | | | | | | | | | This way finfo can be used as hints for decoding ioctl commands. * src/defs.h (get_finfo_for_dev): New declaration. (printfd_with_finfo): New inline function - a thin wrapper around printfd_pid_with_finfo. * src/util.c (get_finfo_for_dev): Remove static modifier to make it reusable the ioctl syscall decoder. (SYS_FUNC(ioctl)): Call get_finfo_for_dev and printfd_with_finfo instead of calling printfd. Signed-off-by: Masatake YAMATO <yamato@redhat.com> Signed-off-by: Dmitry V. Levin <ldv@strace.io>
* Allow to pass pre-filled finfo data to printdev() from upper layersMasatake YAMATO2023-02-192-8/+20
| | | | | | | | | | | | | | | | | | printdev() used to collect struct finfo data just before printing. However, if the finfo data can be filled somewhere else, printdev() does not have to collect the finfo data by itself. * src/defs.h (printfd_pid_with_finfo): New function declaration. (printfd_pid): Turn into a thin wrapper around printfd_pid_with_finfo. (struct finfo): New member "deleted". * src/util.c (get_finfo_for_dev): Initialize "deleted" member of finfo. (printdev): Add finfo argument. If non-NULL is specified as finfo argument, omit get_finfo_for_dev invocation. (printfd_pid): Rename to printfd_pid_with_finfo, add finfo argument and pass it on to printdev. Signed-off-by: Masatake YAMATO <yamato@redhat.com> Signed-off-by: Dmitry V. Levin <ldv@strace.io>
* util: introduce get_finfo_for_dev functionMasatake YAMATO2023-02-192-7/+47
| | | | | | | | | | | | | | | | printdev() function does two things: it first obtains the information about the given fd and then prints it. Introduce get_finfo_for_dev() to implement the first part of printdev(). struct finfo is a new data structure for keeping information passed from get_finfo_for_dev() to printdev(). * src/defs.h (struct finfo): New data structure. * src/utils.c (get_finfo_for_dev): New function derived from printdev. (printdev): Use it. Signed-off-by: Masatake YAMATO <yamato@redhat.com> Signed-off-by: Dmitry V. Levin <ldv@strace.io>