[PATCH v6 0/5] [PIDNS] Final

Ákos Uzonyi uzonyi.akos at gmail.com
Thu Aug 6 19:02:06 UTC 2020


From: Uzonyi Ákos <uzonyi.akos at gmail.com>

NS ID type is unsigned int now. -1U is no longer used as an error indicator,
it just simply left 0 if initialization fails (but is's unlikely to happen).

I added a new function for creating tries, with a documentation explaining
the choice of using 4 for node_key_bits and data_block_key_bits.

Changes in v6:
  - Add function with documentation for creating tries
  - Do not use -1ULL as error indicator in tcb.pid_ns
  - Use unsigned int (instead of uint64_t) for NS IDs
  - Add constant for NS ID size.
  - Modify get_proc_pid a bit
  - Die if trie creation fails
Changes in v5:
  - Squash "Use printpid in *" commits
  - Makefile.am: move adding getpid.c to "Use printpid in decoders"
  - Remove pid_ns_inited field from struct tcb
  - strace.1.in: remove -Y flag
  - Use tprints instead of tprintf where possible
  - Make some global variables static
  - pidns_init: remove "inited" bool variable
  - Make printpid_translation static
  - tests/pidns.c: refactor a bit
  - check_ns_ioctl: fix error msg
  - defs.h: Move adding get_proc_pid to "PID namespace translation support"
  - Remove tcp paramter name from declarations
  - Update printfd_pid_tracee_ns documentation
  - Use named constants for trie_create arguments
  - Add documentation comments
  - Add printpid_tgid_pgid function
  - Delete get_pid_max function; use global variables instead
  - Refactor trie:
    - Move key_size argument
    - Remove support for TRIE_SET
    - Merge trie_create, trie_init, trie_check functions
    - trie_free_node: make static, fix "node" argument type
    - Add max_depth field
    - Reorder functions
    - Extract common parts of trie_get, trie_set
Changes in v4:
  - Skip tests if NS_* ioctl commands are not supported
  - Improve documentation in pidns.h
  - Use pipe for init process termination (instead of SIGKILL)
  - Add PIDNS_TEST_INIT macro
  - Remove "ifdef __NR_gettid"
  - Fix fork--pidns-tranlsation.test: skip if unshare fails with EPERM
  - Use debug message instead of normal message in some cases
  - Rename some labels
  - Rewrite get_ns function
  - Remove O_NONBLOCK from open(/proc/<pid>/ns/pid)
Changes in v3:
  - Split accidentally sqashed last commit
  - Undo modification of tests/pidfd_send_signal.c
  - Rename kcmp-yY test to kcmp-y--pidns-translation
  - Skip tests if unshare fails with EPERM
  - Fix buffer size in pidns_pid2str
  - Use largefile_wrappers.h macros
  - Return early if from_ns or our_ns is 0
  - Do not call ioctl(NS_GET_PARENT) again, if first failed with ENOTTY
  - Skip pidns tests if Linux kernel version < 4.9
  - Use smaller trie nodes in pidns.c
  - Remove race condition from fork--pidns-translation test
  - Move "key_size" to center in trie description
  - Use PT_TID (not PT_TGID) when translating tcp->pid
  - Fix get_ns_hierarchy and get_id_list functions
  - Fix migrate_pages test if syscall succeds
  - Fix filtering in ioctl_block--pidns-translation.test
  - Fix -a flag value in xetpriority test
Changes in v2:
  - Add missing header files to Makefile
  - Fix pointer-to-int-cast errors
  - Fix unused-result errors
  - Use perror_msg instead of perror_func_msg where appropriate
  - Remove tcb parameter of read_int_from_file
  - Use xsprintf instead of snprintf
  - Refactor get_pid_max, get_ns_hierarchy, get_id_list functions
  - Remove -Y flag
  - Improve documentation of trie
  - Fix printing of f_owner_ex struct
  - Use printpid for F_GETOWN, F_SETOWN fcntl command arguments
  - Use printpid for shmid_ds.shm_cpid, shmid_ds.shm_clid
  - Call pidns_init before parsing arguments

Ákos Uzonyi (5):
  PID namespace translation support
  Use printpid in decoders
  Use get_proc_pid for /proc paths
  Implement testing framework for pidns
  Add tests for PID namespace translation

 Makefile.am                                   |   4 +
 NEWS                                          |   1 +
 affinity.c                                    |   6 +-
 block.c                                       |   2 +-
 bpf.c                                         |   2 +-
 capability.c                                  |   4 +-
 clone.c                                       |  14 +-
 defs.h                                        |  58 +-
 fcntl.c                                       |  24 +-
 get_robust_list.c                             |   3 +-
 getpid.c                                      |  46 ++
 ioprio.c                                      |  26 +-
 ipc_shmctl.c                                  |   5 +-
 kcmp.c                                        |   5 +-
 largefile_wrappers.h                          |   2 +
 linux/dummy.h                                 |   8 +-
 mmap_cache.c                                  |   2 +-
 msghdr.c                                      |   2 +-
 net.c                                         |   2 +-
 netlink.c                                     |   5 +-
 numa.c                                        |   6 +-
 pathtrace.c                                   |   5 +-
 pidfd_open.c                                  |   2 +-
 pidns.c                                       | 613 ++++++++++++++++++
 print_fields.h                                |  24 +
 printsiginfo.c                                |   2 +-
 process.c                                     |   3 +-
 process_vm.c                                  |   6 +-
 resource.c                                    |  27 +-
 sched.c                                       |  25 +-
 signal.c                                      |  21 +-
 sockaddr.c                                    |   2 +-
 strace.1.in                                   |   4 +
 strace.c                                      |  11 +-
 syscall.c                                     |  15 +
 tests/.gitignore                              |  31 +
 tests/Makefile.am                             |  37 ++
 tests/fcntl--pidns-translation.c              |   2 +
 tests/fcntl-common.c                          |  82 ++-
 tests/fcntl.c                                 |   1 +
 tests/fcntl64--pidns-translation.c            |   2 +
 tests/fcntl64.c                               |   3 +
 tests/fork--pidns-translation.awk             |  15 +
 tests/fork--pidns-translation.c               |  69 ++
 tests/fork--pidns-translation.test            |  16 +
 tests/gen_tests.in                            |  30 +-
 tests/getpgrp--pidns-translation.c            |   2 +
 tests/getpgrp.c                               |   8 +-
 tests/getpid--pidns-translation.c             |   2 +
 tests/getpid.c                                |   8 +-
 tests/getsid--pidns-translation.c             |   2 +
 tests/getsid.c                                |   9 +-
 tests/gettid--pidns-translation.c             |   2 +
 tests/gettid.c                                |   8 +-
 tests/init.sh                                 |  31 +
 tests/ioctl_block--pidns-translation.c        |   2 +
 tests/ioctl_block--pidns-translation.test     |  24 +
 tests/ioctl_block.c                           |  24 +-
 tests/ioprio--pidns-translation.c             |   2 +
 tests/ioprio.c                                |  54 +-
 tests/kcmp-y--pidns-translation.c             |   2 +
 tests/kcmp.c                                  |  36 +-
 tests/kill--pidns-translation.c               |   2 +
 tests/kill.c                                  |  12 +-
 tests/migrate_pages--pidns-translation.c      |   2 +
 tests/migrate_pages.c                         |  17 +-
 tests/move_pages--pidns-translation.c         |   2 +
 tests/move_pages.c                            |  51 +-
 tests/net-sockaddr--pidns-translation.c       |   2 +
 tests/net-sockaddr.c                          |  66 +-
 tests/netlink_audit--pidns-translation.c      |   2 +
 tests/netlink_audit--pidns-translation.test   |  13 +
 tests/netlink_audit.c                         |  11 +-
 tests/pidfd_open--pidns-translation.c         |   2 +
 tests/pidfd_open.c                            |  21 +-
 tests/pidfd_send_signal--pidns-translation.c  |   2 +
 tests/pidfd_send_signal.c                     |  13 +-
 tests/pidns.c                                 | 214 ++++++
 tests/pidns.h                                 |  56 ++
 tests/prlimit64--pidns-translation.c          |   2 +
 tests/prlimit64.c                             |  17 +-
 tests/process_vm_readv--pidns-translation.c   |   2 +
 tests/process_vm_readv_writev.c               |  27 +-
 tests/process_vm_writev--pidns-translation.c  |   2 +
 tests/rt_sigqueueinfo--pidns-translation.c    |   2 +
 tests/rt_sigqueueinfo.c                       |  15 +-
 tests/rt_tgsigqueueinfo--pidns-translation.c  |   2 +
 tests/rt_tgsigqueueinfo.c                     |  26 +-
 tests/sched_xetaffinity--pidns-translation.c  |   2 +
 tests/sched_xetaffinity.c                     |  31 +-
 tests/sched_xetattr--pidns-translation.c      |   2 +
 tests/sched_xetattr.c                         |  47 +-
 tests/sched_xetparam--pidns-translation.c     |   2 +
 tests/sched_xetparam.c                        |  20 +-
 tests/sched_xetscheduler--pidns-translation.c |   2 +
 tests/sched_xetscheduler.c                    |  44 +-
 tests/signal_receive--pidns-translation.c     |   2 +
 tests/signal_receive.c                        |  22 +-
 tests/so_peercred--pidns-translation.c        |   2 +
 tests/so_peercred.c                           |  22 +
 tests/xet_robust_list--pidns-translation.c    |   2 +
 tests/xet_robust_list.c                       |  18 +-
 tests/xetpgid--pidns-translation.c            |   2 +
 tests/xetpgid.c                               |  21 +-
 tests/xetpriority--pidns-translation.c        |   2 +
 tests/xetpriority.c                           |  20 +-
 trie.c                                        | 250 +++++++
 trie.h                                        |  89 +++
 util.c                                        |  27 +-
 wait.c                                        |  36 +-
 110 files changed, 2484 insertions(+), 255 deletions(-)
 create mode 100644 getpid.c
 create mode 100644 pidns.c
 create mode 100644 tests/fcntl--pidns-translation.c
 create mode 100644 tests/fcntl64--pidns-translation.c
 create mode 100644 tests/fork--pidns-translation.awk
 create mode 100644 tests/fork--pidns-translation.c
 create mode 100755 tests/fork--pidns-translation.test
 create mode 100644 tests/getpgrp--pidns-translation.c
 create mode 100644 tests/getpid--pidns-translation.c
 create mode 100644 tests/getsid--pidns-translation.c
 create mode 100644 tests/gettid--pidns-translation.c
 create mode 100644 tests/ioctl_block--pidns-translation.c
 create mode 100755 tests/ioctl_block--pidns-translation.test
 create mode 100644 tests/ioprio--pidns-translation.c
 create mode 100644 tests/kcmp-y--pidns-translation.c
 create mode 100644 tests/kill--pidns-translation.c
 create mode 100644 tests/migrate_pages--pidns-translation.c
 create mode 100644 tests/move_pages--pidns-translation.c
 create mode 100644 tests/net-sockaddr--pidns-translation.c
 create mode 100644 tests/netlink_audit--pidns-translation.c
 create mode 100755 tests/netlink_audit--pidns-translation.test
 create mode 100644 tests/pidfd_open--pidns-translation.c
 create mode 100644 tests/pidfd_send_signal--pidns-translation.c
 create mode 100644 tests/pidns.c
 create mode 100644 tests/pidns.h
 create mode 100644 tests/prlimit64--pidns-translation.c
 create mode 100644 tests/process_vm_readv--pidns-translation.c
 create mode 100644 tests/process_vm_writev--pidns-translation.c
 create mode 100644 tests/rt_sigqueueinfo--pidns-translation.c
 create mode 100644 tests/rt_tgsigqueueinfo--pidns-translation.c
 create mode 100644 tests/sched_xetaffinity--pidns-translation.c
 create mode 100644 tests/sched_xetattr--pidns-translation.c
 create mode 100644 tests/sched_xetparam--pidns-translation.c
 create mode 100644 tests/sched_xetscheduler--pidns-translation.c
 create mode 100644 tests/signal_receive--pidns-translation.c
 create mode 100644 tests/so_peercred--pidns-translation.c
 create mode 100644 tests/xet_robust_list--pidns-translation.c
 create mode 100644 tests/xetpgid--pidns-translation.c
 create mode 100644 tests/xetpriority--pidns-translation.c
 create mode 100644 trie.c
 create mode 100644 trie.h

--
2.27.0



More information about the Strace-devel mailing list