summaryrefslogtreecommitdiff
path: root/Makefile.am
Commit message (Collapse)AuthorAgeFilesLines
* Update copyright headersDmitry V. Levin2022-01-091-1/+1
| | | | | Headers updated automatically using maint/update_copyright_years.sh script.
* Use a separate manpage date for strace-log-merge.1Dmitry V. Levin2022-01-011-1/+4
| | | | | | | | | | | | | | | strace-log-merge.1 used cause confusion by sharing the manpage date with strace.1. * Makefile.am (dist-hook): Rename MANPAGE_DATE to STRACE_MANPAGE_DATE, generate $(distdir)/doc/.strace-log-merge.1.in.date. * configure.ac (manpage_date): Rename to strace_manpage_date. (slm_manpage_date): Define from doc/strace-log-merge.1.in. (MANPAGE_DATE): Rename to STRACE_MANPAGE_DATE. (SLM_MANPAGE_DATE): Define to slm_manpage_date. * doc/strace-log-merge.1.in: Replace MANPAGE_DATE with SLM_MANPAGE_DATE. * doc/strace.1.in: Replace MANPAGE_DATE with STRACE_MANPAGE_DATE. * strace.spec.in: Likewise, generate doc/.strace-log-merge.1.in.date.
* Do not distribute generated manual pagesDmitry V. Levin2021-06-131-1/+0
| | | | | | * Makefile.am (EXTRA_DIST): Remove $(man_MANS). Complements: v4.19~153 "Make strace.1 generated"
* Update copyright headersDmitry V. Levin2021-02-161-1/+1
| | | | | Headers updated automatically using maint/update_copyright_years.sh script.
* Remove src/types infrastructureDmitry V. Levin2021-02-131-1/+1
| | | | | | | | | | | | | All its former users have been converted to use bundled Linux uapi header files. * src/types/gen.sh: Remove. * src/types/find_last_type_fields.awk: Likewise. * Makefile.am (ACLOCAL_AMFLAGS): Remove "-I src/types". * bootstrap: Remove ./src/types/gen.sh invocation. * configure.ac: Remove st_CHECK_TYPES invocation. * src/Makefile.am: Do not include types/Makemodule.am. (EXTRA_DIST): Remove types/find_last_type_fields.awk and types/gen.sh.
* Introduce bundled directoryDmitry V. Levin2021-02-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This is the first step of adding bundled Linux kernel UAPI headers for compatibility purposes. These headers are going to be copied verbatim from the Linux kernel, they are provided by the Linux kernel under the terms of the GNU General Public License version 2 only with an explicit syscall exception. According to analysis made by Kent Gibson at [1], we are allowed to re-distribute unmodified Linux kernel UAPI headers under the same terms as they are provided by the Linux kernel, and such re-distribution does not affect the license of strace itself. [1] https://lore.kernel.org/linux-gpio/20210128032641.GA11655@sol/ * bundled/Makefile.am: New file. * configure.ac (AC_CONFIG_FILES): Add bundled/Makefile. * Makefile.am (SUBDIRS): Add bundled. * bundled/linux/GPL-2.0: New file, copied from Linux kernel v5.10:LICENSES/preferred/GPL-2.0 file. * bundled/linux/Linux-syscall-note: New file, copied from Linux kernel v5.10:LICENSES/exceptions/Linux-syscall-note file. * bundled/linux/COPYING: New file. * COPYING: Mention it. Thanks-to: Kent Gibson <warthog618@gmail.com>
* Move source files into src subdirectoryDmitry V. Levin2021-02-031-1131/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/Makefile.am: New file. * src/.gitignore: Likewise. * scno.am: Move into src subdirectory. * scno.head: Likewise. * strace-graph: Likewise. * strace-log-merge: Likewise. * linux/: Likewise. * types/: Likewise. * xlat/: Likewise. * *.awk: Likewise. * *.c: Likewise. * *.h: Likewise. * *.sh: Likewise. * .gitignore: Update. * Makefile.am: Update. * bootstrap: Update. * configure.ac: Update. * debian/rules: Update. * debian/strace-udeb.install: Update. * debian/strace.examples: Update. * debian/strace.install: Update. * debian/strace64.install: Update. * m4/gen_bpf_attr_m4.sh: Update. * m4/mpers.m4: Update. * tests/Makefile.am: Update. * tests/init.sh: Update. * tests/legacy_syscall_info.test: Update. * tests/strace-log-merge-error.test: Update. * tests/strace-log-merge-suffix.test: Update.
* Move manual pages and some dev documentation into doc subdirectoryDmitry V. Levin2021-02-021-3/+3
| | | | | | | | | | | | | | | | * doc/.gitignore: New file. * HACKING-scripts: Rename to doc/HACKING-scripts. * README-linux-ptrace: Rename to doc/README-linux-ptrace. * README-mpers: Rename to doc/README-mpers. * strace-log-merge.1.in: Rename to doc/strace-log-merge.1.in. * strace.1.in: Rename to doc/strace.1.in. * .gitignore (/strace-log-merge.1, /strace.1): Remove. * Makefile.am (man_MANS, EXTRA_DIST, dist-hook): Update. * configure.ac (manpage_date, AC_CONFIG_FILES): Update. * debian/rules: Update. * debian/strace.manpages: Update. * debian/strace64.manpages: Update. * strace.spec.in: Update.
* Move auxiliary build scripts to build-aux subdirectoryDmitry V. Levin2021-02-021-5/+5
| | | | | | | | | | | | | | | | | | | | | | | * copyright-year-gen: Rename to build-aux/copyright-year-gen. * file-date-gen: Rename to build-aux/file-date-gen. * git-set-file-times: Rename to build-aux/git-set-file-times. * git-version-gen: Rename to build-aux/git-version-gen. * gitlog-to-changelog: Rename to build-aux/gitlog-to-changelog. * Makefile.am (EXTRA_DIST): Rename copyright-year-gen to build-aux/copyright-year-gen, file-date-gen to build-aux/file-date-gen, and git-version-gen to build-aux/git-version-gen. ($(srcdir)/ChangeLog): Rename gitlog-to-changelog to build-aux/gitlog-to-changelog. * ci/run-build-and-tests.sh: Rename git-set-file-times to build-aux/git-set-file-times. * configure.ac: Rename git-version-gen to build-aux/git-version-gen, copyright-year-gen to build-aux/copyright-year-gen, and file-date-gen to build-aux/file-date-gen. * maint/make-dist: Rename git-set-file-times to build-aux/git-set-file-times. * maint/update_copyright_years.sh: Rename git-set-file-times to build-aux/git-set-file-times, gitlog-to-changelog to build-aux/gitlog-to-changelog.
* Do not install strace-graphDmitry V. Levin2021-02-021-1/+1
| | | | | | | | | | | | | | | | | | | | Apparently, nobody uses this utility, since it barely works, and nobody complained. For example, $ strace -qe/exit -o'|./strace-graph' true Use of uninitialized value $pid in concatenation (.) or string at ./strace-graph line 207, <> line 1. Use of uninitialized value $time in concatenation (.) or string at ./strace-graph line 207, <> line 1. Use of uninitialized value $pid in hash element at ./strace-graph line 214, <> line 1. Use of uninitialized value $pid in delete at ./strace-graph line 244, <> line 1. Use of uninitialized value $startpid in hash element at ./strace-graph line 336, <> line 2. Use of uninitialized value $pid in hash element at ./strace-graph line 284, <> line 2. Can't use an undefined value as an ARRAY reference at ./strace-graph line 284, <> line 2. This is not surprising because downstreams stopped packaging strace-graph long time ago. * Makefile.am (bin_SCRIPTS): Remove strace-graph. * strace.spec.in (%install): Stop removing strace-graph.
* Rename print_aio_sigset to print_kernel_sigsetDmitry V. Levin2021-01-301-1/+1
| | | | | | | | | | | | This function is not specific to aio. * print_aio_sigset.c: Rename to ... * print_kernel_sigset.c: ... this file, rename strace_aio_sigset to struct_sigset_addr_size. * Makefile.am (libstrace_a_SOURCES): Replace print_aio_sigset.c with print_kernel_sigset.c. * aio.c (print_io_getevents): Replace print_aio_sigset with print_kernel_sigset.
* print_fields.h: introduce a few tprint_* helper inline functionsDmitry V. Levin2021-01-271-1/+1
| | | | | | | | | | | | These functions are going to be needed for removal of the first argument from PRINT_FIELD_* macros. * Makefile.am (strace_CPPFLAGS): Add -DIN_STRACE=1. * print_fields.h (tprint_{struct,array}_{begin,next,end}, tprint_more_data_follows, tprint_value_changed, tprints_field_name): New inline functions. (STRACE_PRINTF): New macro. * tests/tests.h (STRACE_PRINTF): Remove.
* Add GPIO ioctl decodingKent Gibson2021-01-261-0/+1
| | | | | | | | | | | | | | | | | | | | Decode the GPIO character device ioctls first introduced in Linux v4.6, as well as those added in subsequent kernel releases up to Linux v5.7. Signed-off-by: Kent Gibson <warthog618@gmail.com> * gpio_ioctl.c: New file. * Makefile.am (libstrace_a_SOURCES): Add it. * types/gpio.h: New file. * xlat/gpio_event_flags.in: Likewise. * xlat/gpio_handle_flags.in: Likewise. * xlat/gpio_ioctl_cmds.in: Likewise. * xlat/gpio_line_flags.in: Likewise. * defs.h (DECL_IOCTL): Add gpio. * ioctl.c (ioctl_decode): Add 0xb4 case. * NEWS: Mention this change. Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
* coverage: update genhtml optionsDmitry V. Levin2021-01-171-1/+3
| | | | | * Makefile.am (CODE_COVERAGE_GENHTML_OPTIONS): Add --title, --precision, and --missed options, update --prefix option.
* disable_ptrace_get_syscall_info, disable_ptrace_getregset: new helper programsDmitry V. Levin2021-01-131-0/+5
| | | | | | | | | | | * disable_ptrace_request.c: New file. * disable_ptrace_get_syscall_info.c: Likewise. * disable_ptrace_getregset.c: Likewise. * Makefile.am (noinst_PROGRAMS, disable_ptrace_get_syscall_info_LDADD, disable_ptrace_getregset_LDADD): New variables. (EXTRA_DIST): Add disable_ptrace_request.c. * .gitignore: Add /disable_ptrace_get_syscall_info and /disable_ptrace_getregset.
* file_ioctl: rename to fs_f_ioctlDmitry V. Levin2021-01-041-1/+1
| | | | | | | | | | * Makefile.am (libstrace_a_SOURCES): Replace file_ioctl.c with fs_f_ioctl.c. * defs.h (DECL_IOCTL): Replace file with fs_f. * file_ioctl.c: Rename to ... * fs_f_ioctl.c: ... new file. (file_ioctl): Rename to fs_f_ioctl. * ioctl.c (ioctl_decode): Replace file_ioctl with fs_f_ioctl.
* file_ioctl: move decoders of linux/fs.h 0x94 commands to a separate fileDmitry V. Levin2021-01-031-0/+1
| | | | | | | | * file_ioctl.c: Move decoders of 0x94 ioctl commands to ... * fs_0x94_ioctl.c: ... new file. * Makefile.am (libstrace_a_SOURCES): Add it. * btrfs.c (btrfs_ioctl): Replace file_ioctl with fs_0x94_ioctl. * defs.h (DECL_IOCTL): Add fs_0x94.
* Change my email addressDmitry V. Levin2020-12-311-1/+1
|
* tee: use types/ directory for the type definitions headerEugene Syromyatnikov2020-09-231-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also, switch ioctl_tee test to system header usage, to double-check things. * tee.h: Rename to... * types/tee.h: ...this. Remove "xlat/tee_ioctl_cmds.h", "xlat/tee_ioctl_gen_caps.h", "xlat/tee_ioctl_impl_ids.h", "xlat/tee_ioctl_login_types.h", "xlat/tee_ioctl_max_arg_size.h", "xlat/tee_ioctl_origins.h", "xlat/tee_ioctl_optee_caps.h", "xlat/tee_ioctl_param_attr_types.h", "xlat/tee_ioctl_shm_flags.h" includes. Add header guard. [!HAVE_STRUCT_TEE_IOCTL_BUF_DATA, !HAVE_STRUCT_TEE_IOCTL_CANCEL_ARG, !HAVE_STRUCT_TEE_IOCTL_CLOSE_SESSION_ARG, !HAVE_STRUCT_TEE_IOCTL_SHM_ALLOC_DATA, !HAVE_STRUCT_TEE_IOCTL_SHM_REGISTER_FD_DATA, !HAVE_STRUCT_TEE_IOCTL_SHM_REGISTER_DATA, !HAVE_STRUCT_TEE_IOCTL_VERSION_DATA, !HAVE_STRUCT_TEE_IOCTL_PARAM, !HAVE_STRUCT_TEE_IOCTL_INVOKE_ARG, !HAVE_STRUCT_TEE_IOCL_SUPP_RECV_ARG, !HAVE_STRUCT_TEE_IOCL_SUPP_SEND_ARG, !HAVE_STRUCT_TEE_IOCTL_OPEN_SESSION_ARG]: Remove ifdefs. (struct tee_ioctl_buf_data): Change to... (typedef struct_tee_ioctl_buf_data): ...this. (struct tee_ioctl_cancel_arg): Change to... (typedef struct_tee_ioctl_cancel_arg): ...this. (struct tee_ioctl_close_session_arg): Change to... (typedef struct_tee_ioctl_close_session_arg): ...this. (struct tee_ioctl_shm_alloc_data): Change to... (typedef struct_tee_ioctl_shm_alloc_data): ...this. (struct tee_ioctl_shm_register_fd_data): Change to... (typedef struct_tee_ioctl_shm_register_fd_data): ...this. (struct tee_ioctl_shm_register_data): Change to... (typedef struct_tee_ioctl_shm_register_data): ...this. (struct tee_ioctl_version_data): Change to... (typedef struct_tee_ioctl_version_data): ...this. (struct tee_ioctl_param): Change to... (typedef struct_tee_ioctl_param): ...this. (struct tee_ioctl_invoke_arg): Change to... (typedef struct_tee_ioctl_invoke_arg): ...this. Change params field type from struct tee_ioctl_param to struct_tee_ioctl_param. (struct tee_iocl_supp_recv_arg): Change to... (typedef struct_tee_iocl_supp_recv_arg): ...this. Change params field type from struct tee_ioctl_param to struct_tee_ioctl_param. (struct tee_iocl_supp_send_arg): Change to... (typedef struct_tee_iocl_supp_send_arg): ...this. Change params field type from struct tee_ioctl_param to struct_tee_ioctl_param. (struct tee_ioctl_open_session_arg): Change to... (typedef struct_tee_ioctl_open_session_arg): ...this. Change params field type from struct tee_ioctl_param to struct_tee_ioctl_param. [TEE_IOCTL_PARAM_SIZE]: Move to tee.c. * Makefile.am (libstrace_a_SOURCES): Remove tee.h. * configure.ac (AC_CHECK_HEADERS([linux/tee.h])): Remove in favour of auto-generated checks courtesy of types/tee.h. * tee.c: Remove "tee.h" include. Add "types/tee.h", "xlat/tee_ioctl_cmds.h" (under XLAT_MACROS_ONLY definition), "xlat/tee_ioctl_gen_caps.h", "xlat/tee_ioctl_impl_ids.h", "xlat/tee_ioctl_login_types.h", "xlat/tee_ioctl_max_arg_size.h", "xlat/tee_ioctl_origins.h", "xlat/tee_ioctl_optee_caps.h", "xlat/tee_ioctl_param_attr_types.h", "xlat/tee_ioctl_shm_flags.h" includes. [TEE_IOCTL_PARAM_SIZE]: Move from tee.h. (tee_print_buf, tee_fetch_buf_data): Change the buf argument type from struct tee_ioctl_buf_data to struct_tee_ioctl_buf_data. (tee_print_param_fn): Change the param variable type from struct tee_ioctl_param to struct_tee_ioctl_param. (tee_print_params): Change the param_buffer variable type from struct tee_ioctl_param to struct_tee_ioctl_param. (tee_version): Change the version variable type from struct tee_ioctl_version_data to struct_tee_ioctl_version_data. (tee_open_session): Change the buf_data variable type from struct_tee ioctl_buf_data to struct_tee_ioctl_buf_data. Change the open_session variable type from struct tee_ioctl_open_session_arg to struct_tee_ioctl_open_session_arg. (tee_invoke): Change the buf_data variable type from struct_tee ioctl_buf_data to struct_tee_ioctl_buf_data. Change the invoke variable type from struct tee_ioctl_invoke_arg to struct_tee_ioctl_invoke_arg. (tee_cancel): Change the cancel variable type from struct tee_ioctl_cancel_arg to struct_tee_ioctl_cancel_arg. (tee_close_session): Change the close_session variable type from struct tee_ioctl_close_session_arg to struct_tee_ioctl_close_session_arg. (tee_suppl_recv): Change the buf_data variable type from struct_tee ioctl_buf_data to struct_tee_ioctl_buf_data. Change the supp_recv variable type from struct tee_iocl_supp_recv_arg to struct_tee_iocl_supp_recv_arg. (tee_suppl_send): Change the buf_data variable type from struct_tee ioctl_buf_data to struct_tee_ioctl_buf_data. Change the supp_send variable type from struct tee_iocl_supp_send_arg to struct_tee_iocl_supp_send_arg. (tee_shm_alloc): Change the shm_alloc variable type from struct tee_ioctl_shm_alloc_data to struct_tee_ioctl_shm_alloc_data. (tee_shm_register_fd): Change the shm_register_fd variable type from struct tee_ioctl_shm_register_fd_data to struct_tee_ioctl_shm_register_fd_data. (tee_shm_register): Change the shm_register variable type from struct tee_ioctl_shm_register_data to struct_tee_ioctl_shm_register_data. * tests/ioctl_tee.c: Put the contents under HAVE_LINUX_TEE_H ifdef. Remove "tee.h" include. Add <linux/tee.h> include. [!TEE_IOCTL_PARAM_ATTR_META] (TEE_IOCTL_PARAM_ATTR_META): New definition. [!HAVE_STRUCT_TEE_IOCTL_SHM_REGISTER_FD_DATA] (struct tee_ioctl_shm_register_fd_data): New type definition. [!HAVE_STRUCT_TEE_IOCTL_SHM_REGISTER_DATA] (struct tee_ioctl_shm_register_data): Likewise. [!TEE_IOC_SHM_REGISTER_FD] (TEE_IOC_SHM_REGISTER_FD): New definition. [!TEE_IOC_SHM_REGISTER] (TEE_IOC_SHM_REGISTER): Likewise. * xlat/tee_ioctl_cmds.in (TEE_IOC_VERSION): Change type in the _IOR macro argument from struct tee_ioctl_version_data to struct_tee_ioctl_version_data. (TEE_IOC_SHM_ALLOC): Change the type in the _IOWR macro argument from struct tee_ioctl_shm_alloc_data to struct_tee_ioctl_shm_alloc_data. (TEE_IOC_OPEN_SESSION): Change the type in the _IOR macro argument from struct tee_ioctl_buf_data to struct_tee_ioctl_buf_data. (TEE_IOC_INVOKE): Change the type in the _IOR macro argument from struct tee_ioctl_buf_data to struct_tee_ioctl_buf_data. (TEE_IOC_CANCEL): Change the type in the _IOR macro argument from struct tee_ioctl_cancel_arg to struct_tee_ioctl_cancel_arg. (TEE_IOC_CLOSE_SESSION): Change the type in the _IOR macro argument from struct tee_ioctl_close_session_arg to struct_tee_ioctl_close_session_arg. (TEE_IOC_SUPPL_RECV): Change the type in the _IOR macro argument from struct tee_ioctl_buf_data to struct_tee_ioctl_buf_data. (TEE_IOC_SUPPL_SEND): Change the type in the _IOR macro argument from struct tee_ioctl_buf_data to struct_tee_ioctl_buf_data. (TEE_IOC_SHM_REGISTER_FD): Change the type in the _IOWR macro argument from struct tee_ioctl_shm_register_fd_data to struct_tee_ioctl_shm_register_fd_data. (TEE_IOC_SHM_REGISTER): Change the type in the _IOWR macro argument from struct tee_ioctl_shm_register_data to struct_tee_ioctl_shm_register_data.
* Implement decoding of TEE_* ioctlsElvira Khabirova2020-09-231-0/+2
| | | | | | | | | | | | | | | | | | | | | | | * tee.c: New file. * tee.h: Likewise. * Makefile.am (libstrace_a_SOURCES): Add them. * configure.ac (AC_CHECK_HEADERS): Add linux/tee.h. * defs.h (DECL_IOCTL): Add tee. * ioctl.c (ioctl_decode): Add 0xa4 (tee) case. * xlat/tee_ioctl_cmds.in: New file. * xlat/tee_ioctl_gen_caps.in: Likewise. * xlat/tee_ioctl_impl_ids.in: Likewise. * xlat/tee_ioctl_login_types.in: Likewise. * xlat/tee_ioctl_max_arg_size.in: Likewise. * xlat/tee_ioctl_optee_caps.in: Likewise. * xlat/tee_ioctl_origins.in: Likewise. * xlat/tee_ioctl_param_attr_types.in: Likewise. * xlat/tee_ioctl_shm_flags.in: Likewise. * tests/gen_tests.in (ioctl_tee): New entry. * tests/ioctl_tee.c: New file. * tests/.gitignore: Add ioctl_tee. * tests/pure_executables.list: Likewise. * NEWS: Mention the change.
* semctl: decode struct arguments of IPC_* and SEM_* commandsDmitry V. Levin2020-09-191-0/+1
| | | | | | | | | | | | | * ipc_semctl.c: New file. * Makefile.am (libstrace_a_SOURCES): Add it. * ipc_defs.h (NAME_OF_STRUCT_SEMID_DS): New macro. * ipc_sem.c: Stop including "xlat/semctl_flags.h". (SYS_FUNC(semctl)): Remove. * tests/ipc_sem.c (str_ipc_info): New macro. (print_semid_ds, print_sem_info): New functions. (main): Use them to check decoding IPC_INFO, SEM_INFO, IPC_SET, IPC_STAT, SEM_STAT, and SEM_STAT_ANY semctl syscall commands. * NEWS: Mention this change.
* Implement decoding of close_range syscallDmitry V. Levin2020-09-061-0/+1
| | | | | | | | | | | | | | | | | | | | | Introduced by Linux kernel commit v5.9-rc1~160. * close_range.c: New file. * Makefile.am (libstrace_a_SOURCES): Add it. * configure.ac (AC_CHECK_HEADERS): Add linux/close_range.h. * xlat/close_range_flags.in: New file. * pathtrace.c (pathtrace_match_set): Handle SEN_close_range. * linux/syscallent-common.h [BASE_NR + 436]: Wire up close_range. * NEWS: Mention this change. * tests/close_range.c: New file. * tests/close_range-P.c: Likewise. * tests/close_range-y.c: Likewise. * tests/close_range-yy.c: Likewise. * tests/gen_tests.in (close_range. close_range-P, close_range-y, close_range-yy): New entries. * tests/pure_executables.list: Add close_range, close_range-P, close_range-y, and close_range-yy. * tests/.gitignore: Likewise.
* Add tests for PID namespace translationAkosUzonyi/pidnsÁkos Uzonyi2020-08-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Makefile.am (CODE_COVERAGE_IGNORE_PATTERN): Add test directories. * tests/.gitignore: Add new test executables. * tests/Makefile.am (check_PROGRAMS): Add new test executables. (DECODER_TESTS) Add new test files. (libtests_a_SOURCES): Add trie_for_tests.c, xmalloc_for_tests.c. * tests/gen_tests.in: Add new tests. * tests/trie_test.c: New file. * tests/trie_for_tests.c: New file. * tests/xmalloc_for_tests.c: New file. * tests/pidns-cache.c: New file. * tests/pidns-cache.test: New file. * tests/fcntl--pidns-translation.c: New file. * tests/fcntl64--pidns-translation.c: New file. * tests/fork--pidns-translation.awk: New file. * tests/fork--pidns-translation.c: New file. * tests/fork--pidns-translation.test: New file. * tests/getpgrp--pidns-translation.c: New file. * tests/getpid--pidns-translation.c: New file. * tests/getsid--pidns-translation.c: New file. * tests/gettid--pidns-translation.c: New file. * tests/gettid--pidns-translation.test: New file. * tests/ioctl_block--pidns-translation.c: New file. * tests/ioctl_block--pidns-translation.test: New file. * tests/ioprio--pidns-translation.c: New file. * tests/kill--pidns-translation.c: New file. * tests/migrate_pages--pidns-translation.c: New file. * tests/move_pages--pidns-translation.c: New file. * tests/net-sockaddr--pidns-translation.c: New file. * tests/netlink_audit--pidns-translation.c: New file. * tests/netlink_audit--pidns-translation.test: New file. * tests/pidfd_open--pidns-translation.c: New file. * tests/pidfd_send_signal--pidns-translation.c: New file. * tests/prlimit64--pidns-translation.c: New file. * tests/process_vm_readv--pidns-translation.c: New file. * tests/process_vm_writev--pidns-translation.c: New file. * tests/rt_sigqueueinfo--pidns-translation.c: New file. * tests/rt_tgsigqueueinfo--pidns-translation.c: New file. * tests/sched_xetaffinity--pidns-translation.c: New file. * tests/sched_xetattr--pidns-translation.c: New file. * tests/sched_xetparam--pidns-translation.c: New file. * tests/sched_xetscheduler--pidns-translation.c: New file. * tests/signal_receive--pidns-translation.c: New file. * tests/so_peercred--pidns-translation.c: New file. * tests/tkill--pidns-translation.c: New file. * tests/tgkill--pidns-translation.c: New file. * tests/xet_robust_list--pidns-translation.c: New file. * tests/xetpgid--pidns-translation.c: New file. * tests/xetpriority--pidns-translation.c: New file. * tests/fcntl-common.c: Print PID translation string after PIDs. * tests/fcntl.c: Likewise. * tests/fcntl64.c: Likewise. * tests/getpgrp.c: Likewise. * tests/getpid.c: Likewise. * tests/getsid.c: Likewise. * tests/gettid.c: Likewise. * tests/ioctl_block.c: Likewise. * tests/ioprio.c: Likewise. * tests/kcmp.c: Likewise. * tests/kill.c: Likewise. * tests/migrate_pages.c: Likewise. * tests/move_pages.c: Likewise. * tests/net-sockaddr.c: Likewise. * tests/netlink_audit.c: Likewise. * tests/pidfd_open.c: Likewise. * tests/pidfd_send_signal.c: Likewise. * tests/prlimit64.c: Likewise. * tests/process_vm_readv_writev.c: Likewise. * tests/rt_sigqueueinfo.c: Likewise. * tests/rt_tgsigqueueinfo.c: Likewise. * tests/sched_xetaffinity.c: Likewise. * tests/sched_xetattr.c: Likewise. * tests/sched_xetparam.c: Likewise. * tests/sched_xetscheduler.c: Likewise. * tests/signal_receive.c: Likewise. * tests/so_peercred.c: Likewise. * tests/tgkill.c: Likewise. * tests/tkill.c: Likewise. * tests/xet_robust_list.c: Likewise. * tests/xetpgid.c: Likewise. * tests/xetpriority.c: Likewise.
* Use printpid in decodersÁkos Uzonyi2020-08-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * getpid.c: New file. * Makefile.am (libstrace_a_SOURCES): Add it. * linux/dummy.h (sys_getpid, sys_getppid, sys_gettid, sys_setpgid, sys_setpgrp): Remove. * util.c (printfd_pid_tracee_ns): Implement using translate_pid. * defs.h (printnum_pid): New function definition. (printfd_pid_tracee_ns): Update documentation * util.c: (printnum_pid): New function. * print_fields.h (PRINT_FIELD_TID): New macro. (PRINT_FIELD_TGID): Likewise. (PRINT_FIELD_PGID): Likewise. (PRINT_FIELD_SID): Likewise. * affinity.c: Print PIDs with printpid. * block.c: Likewise. * bpf.c: Likewise. * capability.c: Likewise. * clone.c: Likewise. * fcntl.c: Likewise. * get_robust_list.c: Likewise. * ioprio.c: Likewise. * kcmp.c: Likewise. * msghdr.c: Likewise. * net.c: Likewise. * netlink.c: Likewise. * numa.c: Likewise. * pidfd_open.c: Likewise. * printsiginfo.c: Likewise. * process.c: Likewise. * process_vm.c: Likewise. * resource.c: Likewise. * sched.c: Likewise. * signal.c: Likewise. * sockaddr.c: Likewise. * wait.c: Likewise. * kcmp.c (SYS_FUNC(kcmp)): Fix KCMP_FILE pid arguments. * tests/kcmp.c (printpidfd): Print path if VERBOSE_FD. (main): Use our real pid if real fds are used.
* PID namespace translation supportÁkos Uzonyi2020-08-251-0/+3
| | | | | | | | | | | | | | | | | | | | | | * defs.h (pidns_translation): New variable. (tcb): Add pid_ns field. (RVAL_MASK): Change value from 013 to 017. (RVAL_TID, RVAL_SID, RVAL_TGID, RVAL_PGID): New definitions. (pid_type): New enum. (pidns_init, translate_pid, get_proc_pid, printpid, printpid_tgid_pgid): New function declarations. * largefile_wrappers.h (fstat_fd): New macro. * pidns.c: New file. * trie.c: New file. * trie.h: New file. * Makefile.am (libstrace_a_SOURCES): Add trie.c, trie.h, pidns.c. * strace.c (pidns_translation): New variable. (init): Add --pidns-translation option. * syscall.c (syscall_exiting_trace): Handle RVAL_* return values. * NEWS: Mention this. * strace.1.in: Add description for new option. Co-Authored-by: Eugene Syromyatnikov <evgsyr@gmail.com>
* strace: add an option for printing syscall numbersElvira Khabirova2020-08-211-0/+1
| | | | | | | | | | | | | * print_syscall_number.c: New file. * Makefile.am (libstrace_a_SOURCES): Add it. * defs.h (struct tcb): Add true_scno field. (print_syscall_number): New function declaration. * strace.c: Add -n/--syscall-number option. (printleader): Call print_syscall_number. * syscall.c (get_scno): Assign tcp->true_scno. * tests/options-syntax.test: Check with -c/--summary-only. * strace.1.in: Document new option. * NEWS: Mention the new option.
* xlat: generate m4 checks for enumerationsEugene Syromyatnikov2020-05-301-1/+1
| | | | | | | | | | | | | | | | | | | | * xlat/gen.sh (print_m4_record, gen_m4_entry): New functions. (print_xlat_pair): Accept macro name in the third argument. (print_xlat, print_xlat_pair): Call print_m4_record. (cond_xlat): Pass $m to print_xlat_pair call. Set first_enum to 0. (gen_header, gen_make, gen_git): Output the "generating ..." line to stderr. (gen_header): Get output_m4 as the fourth parameter, redirect fd 3 to stdout, set enum to 1 if #enum is present and $output_m4 is set, append #include argument to includes, generate $output_m4 is $enum is set to 1, pass macro name to print_xlat_pair call, close fd 3. (gen_git): Add st_check_enums.m4 and "/*.m4". (main): Allow passing $output_m4 as the third argument, pass m4 file name as the fourth argument to gen_header calls, pipe gen_header output to gen_m4_entry in case of no-argument invocation, redirect gen_header output to /dev/null in case of single-file invocation. * Makefile.am (ACLOCAL_AMFLAGS): Add "-I xlat". * configure.ac: Add st_CHECK_ENUMS.
* Replace struct v4l2_buffer with a reliable alternative definitionDmitry V. Levin2020-05-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Starting with Linux kernel commit v5.6-rc1~93^2~102, the definition of struct v4l2_buffer provided by the kernel depends on the flavour of struct timeval provided by libc. This effectively means that we cannot use the definition provided by the kernel, neither in the decoder nor in tests. * kernel_v4l2_types.h: New file. * Makefile.am (libstrace_a_SOURCES): Add it. * types/v4l2.h (struct_v4l2_buffer): Remove. * v4l2.c: Include "kernel_v4l2_types.h". Replace struct_v4l2_buffer with kernel_v4l2_buffer_t. (VIDIOC_QUERYBUF, VIDIOC_QBUF, VIDIOC_DQBUF, VIDIOC_PREPARE_BUF): Redefine. (print_v4l2_buffer): Use print_timeval64_data_size to print timestamp field. * linux/32/ioctls_inc_align16.h (VIDIOC_QUERYBUF, VIDIOC_QBUF, VIDIOC_DQBUF, VIDIOC_PREPARE_BUF): Update. * linux/32/ioctls_inc_align32.h: Likewise. * linux/32/ioctls_inc_align64.h: Likewise. * xlat/v4l2_ioctl_cmds.in (VIDIOC_QUERYBUF, VIDIOC_QBUF, VIDIOC_DQBUF, VIDIOC_PREPARE_BUF): Comment out. * tests/ioctl_v4l2.c: Include "kernel_v4l2_types.h". (main): Replace struct_v4l2_buffer with kernel_v4l2_buffer_t. (VIDIOC_QUERYBUF, VIDIOC_QBUF, VIDIOC_DQBUF, VIDIOC_PREPARE_BUF): Redefine. * tests/ioctl_v4l2-success.c: Likewise. Resolves: https://github.com/strace/strace/issues/133
* Rewrite decoders of dup, dup2, and dup3 syscallsDmitry V. Levin2020-04-241-0/+1
| | | | | | | * dup.c: New file. * Makefile.am (libstrace_a_SOURCES): Add it. * desc.c (do_dup2, SYS_FUNC(dup), SYS_FUNC(dup2), SYS_FUNC(dup3)): Remove.
* Rework printing of SO_TIMESTAMPNS_OLD and SO_TIMESTAMPING_OLD timestampsDmitry V. Levin2020-04-191-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | On architectures with 32-bit kernel_long_t the kernel sends 32-bit timespecs in SO_TIMESTAMPNS_OLD and SO_TIMESTAMPING_OLD messages. Unfortunately, this applies to all 32-bit architectures including those (like RV32) that do not define __ARCH_WANT_TIME32_SYSCALLS. * print_timespec.c: Remove. * Makefile.am (libstrace_a_SOURCES): Remove it. * linux/arch_defs_.h (ARCH_TIMESIZE): Remove. (MIN_KLONGSIZE, HAVE_ARCH_TIMESPEC32): New macros. * linux/x32/arch_defs_.h (ARCH_TIMESIZE): Remove. * defs.h (print_timespec32_data_size, print_timespec32_array_data_size): Declare for [HAVE_ARCH_TIMESPEC32]. * kernel_timespec.h (kernel_timespec32_t): Define for [HAVE_ARCH_TIMESPEC32]. * print_timespec32.c (TIMESPEC_T, PRINT_TIMESPEC_DATA_SIZE, PRINT_TIMESPEC_ARRAY_DATA_SIZE): Define for [HAVE_ARCH_TIMESPEC32]. * msghdr.c (PRINT_TIMESPEC_DATA_SIZE, PRINT_TIMESPEC_ARRAY_DATA_SIZE): Define. (print_scm_timestampns_old): Use PRINT_TIMESPEC_DATA_SIZE instead of print_struct_timespec_data_size. (print_scm_timestamping_old): Use PRINT_TIMESPEC_ARRAY_DATA_SIZE instead of print_struct_timespec_array_data_size.
* kernel_rusage.h: introduce kernel_rusage_tAlistair Francis2020-04-191-0/+1
| | | | | | | | | | | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> * printrusage.c: Include "kernel_rusage.h" instead of "kernel_timeval.h". (rusage_t): Rename to kernel_rusage_t, move the definition to ... * kernel_rusage.h: ... new file. * Makefile.am (libstrace_a_SOURCES): Add it. Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
* Makefile.am: move almost all of strace_SOURCES to libstrace_a_SOURCESDmitry V. Levin2020-04-121-24/+21
| | | | | | | There is no need to track files that are used conditionally. * Makefile.am (strace_SOURCES): Move all except strace.c ... (libstrace_a_SOURCES): ... here.
* Rewrite decoders of getdents, getdents64, and readdir syscallsDmitry V. Levin2020-04-121-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | The old approach of allocating memory for all dentries returned by getdents/getdents64 was problematic, fix it by fetching and printing dentries sequentially. * dirent_types.c: New file. * xgetdents.c: Likewise. * xgetdents.h: Likewise. * Makefile.am (strace_SOURCES): Add them. * dirent.c: Include "xgetdents.h" and "print_fields.h". (header_size): New variable. (print_dentry_head, decode_dentry_head, decode_dentry_tail): New functions. (print_old_dirent): Rewrite using print_dentry_head. (SYS_FUNC(getdents)): Rewrite using xgetdents, decode_dentry_head, and decode_dentry_tail. * dirent64.c: Include "xgetdents.h", "kernel_dirent.h" and "print_fields.h" instead of "defs.h", <dirent.h> and "xlat/dirent_types.h". (decode_dentry_head, decode_dentry_tail): New functions. (SYS_FUNC(getdents64)): Rewrite using xgetdents, decode_dentry_head, and decode_dentry_tail. Resolves: https://github.com/strace/strace/issues/19 Resolves: https://github.com/strace/strace/pull/20
* Move kernel_dirent definition from kernel_types.h to a separate headerDmitry V. Levin2020-04-111-0/+1
| | | | | | | | | | | ... and rename kernel_dirent type to kernel_dirent_t * kernel_types.h (kernel_dirent): Rename to kernel_dirent_t, move ... * kernel_dirent.h: ... to new file. * Makefile.am (strace_SOURCES): Add it. * dirent.c: Include "kernel_dirent.h", rename kernel_dirent to kernel_dirent_t. * tests/getdents.c: Likewise.
* Implement pidfd_getfd syscall decodingEugene Syromyatnikov2020-03-301-0/+1
| | | | | | | | | | | | | | Introduced by Linux commit v5.6-rc1~122^2~4 and wired up in Linux commit v5.6-rc1~122^2~3. * pidfd_getfd.c: New file. * Makefile.am (strace_SOURCES): Add it. * linux/syscallent-common.h ([BASE_NR + 438]): Wire up pidfd_getfd. * tests/pidfd_getfd.c: New file. * tests/pidfd_getfd-y.c: Likewise. * tests/.gitignore: Add pidfd_getfd and pidfd_getfd-y. * tests/pure_executables.list: Likewise. * tests/gen_tests.in: Add pidfd_getfd and pidfd_getfd-y tests.
* xtensa: switch to PTRACE_GETREGS APIDmitry V. Levin2020-03-301-1/+0
| | | | | | | | | | | | | | | | | | Implement PTRACE_GETREGS API introduced on xtensa by Linux kernel commit v2.6.13-rc1~68^2~366. * configure.ac [xtensa]: Remove arch_enable_Werror=no. * linux/xtensa/get_syscall_result.c: Remove. * Makefile.am (EXTRA_DIST): Remove it. * linux/xtensa/arch_regs.c (xtensa_regs): New variable. (ARCH_REGS_FOR_GETREGS, ARCH_PC_REG, ARCH_SP_REG): New macros. (xtensa_a2, ARCH_PC_PEEK_ADDR, ARCH_SP_PEEK_ADDR): Remove. * linux/xtensa/get_error.c (arch_get_error): Use xtensa_regs.a[2]. * linux/xtensa/get_syscall_args.c (arch_get_syscall_args): Use xtensa_regs.a. * linux/xtensa/set_error.c (arch_set_error, arch_set_success): Use xtensa_regs.a[2]. * NEWS: Mention this change.
* sh64: switch to PTRACE_GETREGS APIDmitry V. Levin2020-03-301-2/+0
| | | | | | | | | | | | | | | | | | | | Implement PTRACE_GETREGS API introduced on sh64 by Linux kernel commit v2.6.28-rc1~99^2~56. * configure.ac [sh64]: Remove arch_enable_Werror=no. * linux/sh64/arch_regs.h: Remove. * linux/sh64/get_syscall_result.c: Likewise. * Makefile.am (EXTRA_DIST): Remove them. * linux/sh64/arch_regs.c (sh64_regs): New variable. (ARCH_REGS_FOR_GETREGS, ARCH_PC_REG, ARCH_SP_REG): New macros. (sh64_r9, ARCH_PC_PEEK_ADDR, ARCH_SP_PEEK_ADDR): Remove. * linux/sh64/get_error.c (arch_get_error): Use sh64_regs.regs[9]. * linux/sh64/get_scno.c (arch_get_scno): Use sh64_regs.regs[9]. * linux/sh64/get_syscall_args.c (arch_get_syscall_args): Use sh64_regs.regs. * linux/sh64/set_error.c (arch_set_error, arch_set_success): Use sh64_regs.gr[9]. * linux/sh64/set_scno.c (arch_set_scno): Use sh64_regs.regs[9]. * NEWS: Mention this change.
* sh: switch to PTRACE_GETREGS APIDmitry V. Levin2020-03-301-1/+0
| | | | | | | | | | | | | | | | | | | | Implement PTRACE_GETREGS API introduced on sh by Linux kernel commit v2.6.28-rc1~99^2~56. * configure.ac [sh]: Remove arch_enable_Werror=no. * linux/sh/get_syscall_result.c: Remove. * Makefile.am (EXTRA_DIST): Remove it. * linux/sh/arch_regs.c (sh_regs): New variable. (ARCH_REGS_FOR_GETREGS, ARCH_PC_REG, ARCH_SP_REG): New macros. (sh_r0, ARCH_PC_PEEK_ADDR, ARCH_SP_PEEK_ADDR): Remove. * linux/sh/arch_getrval2.c (getrval2): Use sh_regs.regs[1]. * linux/sh/get_error.c (arch_get_error): Use sh_regs.regs[0]. * linux/sh/get_scno.c (arch_get_scno): Use sh_regs.regs[3]. * linux/sh/get_syscall_args.c (arch_get_syscall_args): Use sh_regs.regs. * linux/sh/set_error.c (arch_set_error, arch_set_success): Use sh_regs.gr[0]. * linux/sh/set_scno.c (arch_set_scno): Use sh_regs.regs[3]. * NEWS: Mention this change.
* hppa: switch to PTRACE_GETREGS APIDmitry V. Levin2020-03-271-1/+0
| | | | | | | | | | | | | | | | | | | | | Implement PTRACE_GETREGS API introduced on hppa by Linux kernel commit v4.7-rc1~58^2~10. * configure.ac [hppa]: Remove arch_enable_Werror=no. * linux/hppa/get_syscall_result.c: Remove. * Makefile.am (EXTRA_DIST): Remove it. * linux/hppa/arch_regs.c (hppa_regs): New variable. (ARCH_REGS_FOR_GETREGS, ARCH_PC_REG, ARCH_SP_REG): New macros. (hppa_r28, PT_GR20, PT_GR28, ARCH_PC_PEEK_ADDR, ARCH_SP_PEEK_ADDR): Remove. * linux/hppa/get_error.c (arch_get_error): Use hppa_regs.gr[28]. * linux/hppa/get_scno.c (arch_get_scno): Use hppa_regs.gr[20]. * linux/hppa/get_syscall_args.c (arch_get_syscall_args): Use hppa_regs.gr. * linux/hppa/set_error.c (arch_set_error, arch_set_success): Use hppa_regs.gr[28]. * linux/hppa/set_scno.c (arch_set_scno): Use hppa_regs.gr[20]. * NEWS: Mention this change.
* linux/32: Split 32-bit time_t based syscalls into a separate headerAlistair Francis2020-02-261-0/+1
| | | | | | | | | | | | | | | | | | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Starting with Linux kernel v5.1, new 32-bit architectures do not implement old 32-bit time_t based system calls, so they should not have the corresponding syscallent records. * linux/32/syscallent-time32.h: New file, generated using the following command: grep 'timex\?32)' linux/32/syscallent.h * Makefile.am (EXTRA_DIST): Add it. * linux/32/syscallent.h: Replace entries for 32-bit time_t based syscalls with stub comments using the following command: sed -i '/timex\?32)/ s/\(^\[[^]]\+\]\)[^"]*"\([^"]\+\)".*/\/\* \1 \2 \*\//' [HAVE_ARCH_TIME32_SYSCALLS]: Include "32/syscallent-time32.h". Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
* Update copyright headersDmitry V. Levin2020-02-061-1/+1
| | | | | Headers updated automatically using maint/update_copyright_years.sh script.
* types: new infrastructure for automatic checking of structure typesDmitry V. Levin2020-01-211-2/+6
| | | | | | | | | | | | | * types/gen.sh: New file. * bootstrap: Invoke it. * types/find_last_type_fields.awk: New file. * configure.ac: Invoke st_CHECK_TYPES. (AM_INIT_AUTOMAKE): Add subdir-objects. * Makefile.am: Include types/Makemodule.am. (ACLOCAL_AMFLAGS): Add -I types. (strace_SOURCES): Add $(TYPES_HEADER_FILES). (strace_SOURCES_check): Add $(TYPES_CHECK_FILES). (EXTRA_DIST): Add types/find_last_type_fields.awk and types/gen.sh.
* s390: workaround Linux kernel bug in syscall_get_nrDmitry V. Levin2020-01-081-0/+2
| | | | | | | | | | | | Apparently, arch/s390/include/asm/syscall.h:syscall_get_nr() returns 0 for out-of-range syscall numbers. This kernel bug is exposed via PTRACE_GET_SYSCALL_INFO interface. Workaround it by falling back to get_regs() for the zero syscall number. * linux/s390/check_scno.c: New file. * linux/s390x/check_scno.c: Likewise. * Makefile.am (EXTRA_DIST): Add them. * syscall.c (get_scno): Update comment.
* Add support for per-mpers compiler settingsEugene Syromyatnikov2019-11-151-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | As some very special architectures require a separate compiler in order to compile binaries for additional supported personalities, we have to introduce such support. * Makefile.am (mpers_CPPFLAGS): Move $(strace_CPPFLAGS) ... (mpers_sh_opts): ... here. (mpers-m%.stamp:): Use $(mpers_CC) instead of $(CC) for compiler, pass $(mpers_CC_FLAGS) in quotes as it might be empty or contain spaces. ($(mpers_m32_targets)): Add @CFLAGS_FOR_M32@ to mpers_CC_FLAGS, set mpers_CPPFLAGS and mpers_CC. ($(mpers_mx32_targets)): Add @CFLAGS_FOR_MX32@ to mpers_CC_FLAGS, set mpers_CPPFLAGS and mpers_CC. * bootstrap (m_upper): Derive uppercase personality name. Set CC for mpers Makefile.am, add @CFLAGS_FOR_{M32,MX32}@ to MPERS_CC_FLAGS definition. * configure.ac: Derive default values for {CC,CPP,CFLAGS,CPPFLAGS}_FOR_{M32,MX32} from the respective CC, CPP, CFLAGS, and CPPFLAGS values. * m4/mpers.m4 (AC_DEFUN([st_MPERS])): Use {CC,CPP,CFLAGS,CPPFLAGS}_FOR_<$1> as CC, CPP, CFLAGS, and CPPFLAGS, respectively. Enclose MPERS_CFLAGS in quotes in mpers.sh call. Provide information about compiler in the AC_CACHE_CHECK message. * tests/Makefile.am (CC): New variable. Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
* riscv64: remove dead code left after riscv64 mpers removalEugene Syromyatnikov2019-10-121-1/+0
| | | | | | | | | | | | Since there is no compat on RISCV64 so far, its dead remains are only confusing. * linux/riscv64/arch_get_personality.c: Remove. * Makefile.am (EXTRA_DIST): Remove it. Reported-by: Elvira Khabirova <lineprinter0@gmail.com> Suggested-by: Dmitry V. Levin <ldv@altlinux.org> Complements: v5.3~18 "riscv64: remove mpers support"
* Distribute copyright-year-gen, file-date-gen, and git-version-genDmitry V. Levin2019-10-021-0/+3
| | | | | | | | These scripts have to be distributed along with configure.ac since the latter uses them. * Makefile.am (EXTRA_DIST): Add copyright-year-gen, file-date-gen, and git-version-gen.
* Introduce seccomp-assisted syscall filteringChen Jingpiao2019-09-251-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this patch, strace can rely on seccomp to only be stopped at syscalls of interest, instead of stopping at all syscalls. The seccomp filtering of syscalls is opt-in only; it must be enabled with the --seccomp-bpf option. Kernel support is first checked with check_seccomp_filter(), which also ensures the BPF program derived from the syscalls to filter is not larger than the kernel's limit. The --seccomp-bpf option implies -f, but a warning is emitted if -f is not explicitly specified. Since a task's children inherit its seccomp filters, we want to ensure all children are also traced to avoid their syscalls failing with ENOSYS (cf. SECCOMP_RET_TRACE in seccomp man page). Fork/vfork/clone children of traced processes are marked as not having a seccomp filter until we receive a first seccomp-stop. They are therefore stopped at every syscall entries and exits until that first seccomp-stop. The current BPF program implements a simple linear match of the syscall numbers. Contiguous sequences of syscall numbers are however matched as an interval, with two instructions only. The algorithm can be improved or replaced in the future without impacting user-observed behavior. The behavior of SECCOMP_RET_TRACE changed between Linux 4.7 and 4.8 (cf. PTRACE_EVENT_SECCOMP in ptrace man page). This patch supports both behaviors by checking the kernel's actual behavior before installing the seccomp filter. * filter_seccomp.c: New file. * filter_seccomp.h: New file. * Makefile.am (strace_SOURCES): Add filter_seccomp.c and filter_seccomp.h. * linux/aarch64/arch_defs_.h (PERSONALITY0_AUDIT_ARCH, PERSONALITY1_AUDIT_ARCH): Define for aarch64. * linux/powerpc64/arch_defs_.h (PERSONALITY0_AUDIT_ARCH, PERSONALITY1_AUDIT_ARCH): Likewise for powerpc64. * linux/s390x/arch_defs_.h (PERSONALITY0_AUDIT_ARCH, * linux/sparc64/arch_defs_.h (PERSONALITY0_AUDIT_ARCH, PERSONALITY1_AUDIT_ARCH): Likewise for sparc64. PERSONALITY1_AUDIT_ARCH): Likewise for s390x. * linux/tile/arch_defs_.h (PERSONALITY0_AUDIT_ARCH, PERSONALITY1_AUDIT_ARCH): Likewise for tile. * linux/x32/arch_defs_.h (PERSONALITY0_AUDIT_ARCH, PERSONALITY1_AUDIT_ARCH): Likewise for x32. * linux/x86_64/arch_defs_.h (PERSONALITY0_AUDIT_ARCH, PERSONALITY1_AUDIT_ARCH, PERSONALITY2_AUDIT_ARCH): Likewise for x86_64. * linux/ia64/arch_defs_.h (PERSONALITY0_AUDIT_ARCH): Likewise for IA64. * strace.c (usage): Document --seccomp-bpf option. (startup_child): Mark process has having seccomp filter. (exec_or_die): Initialize seccomp filtering if requested. (init): Handle --seccomp-bpf option and check that seccomp can be enabled. (print_debug_info): Handle PTRACE_EVENT_SECCOMP. (next_event): Capture PTRACE_EVENT_SECCOMP event. (dispatch_event): Handle PTRACE_EVENT_SECCOMP event. * trace_event.h (trace_event): New enumeration entity. * strace.1.in: Document new --seccomp-bpf option. * NEWS: Mention this change. Co-authored-by: Paul Chaignon <paul.chaignon@gmail.com> Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
* riscv64: remove mpers supportEugene Syromyatnikov2019-09-241-4/+0
| | | | | | | | | | | | | | | | There is no riscv32 Linux support in Linux mainline, and no compat support in riscv64 as well. * linux/riscv64/arch_defs_.h: Remove. * linux/riscv64/ioctls_arch1.h: Likewise. * linux/riscv64/ioctls_inc1.h: Likewise. * linux/riscv64/syscallent1.h: Likewise. * Makefile.am (EXTRA_DIST): Remove them. * configure.ac (st_MPERS([m32])): Remove riscv64. * strace.1.in (.SH "MULTIPLE PERSONALITY SUPPORT"): Remove RISC-V from the list. Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
* riscv: rename to riscv64Dmitry V. Levin2019-09-231-15/+15
| | | | | | | | | | | | | | | The only currently supported RISC-V architecture is the 64-bit RISC-V. As the generic name we use causes confusion [1], rename it to riscv64. [1] https://lists.strace.io/pipermail/strace-devel/2019-August/009057.html * Makefile.am (EXTRA_DIST): Rename linux/riscv to linux/riscv64. * configure.ac: Rename riscv to riscv64, RISCV to RISCV64. * linux/riscv: Rename to linux/riscv64. * riscv.c: Rename RISCV to RISCV64. * tests/options-syntax.test: Rename riscv to riscv64. * tests/qualify_personality.sh: Likewise. * tests/strace-V.test: Likewise.
* Add support for /dev/watchdog ioctlsRasmus Villemoes2019-08-231-0/+1
| | | | | | | | | | | | | | | * watchdog_ioctl.c: New file. * Makefile.am (strace_SOURCES): Add it. * defs.h (DECL_IOCTL): Add watchdog. * ioctl.c (ioctl_decode): Add 'W' case. * xlat/watchdog_ioctl_cmds.in: New file. * tests/ioctl_watchdog.c: New file. * tests/.gitignore: Add ioctl_watchdog. * tests/pure_executables.list: Likewise. * tests/gen_tests.in (ioctl_watchdog): New entry. Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>