]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
8 months agomeson: add -D tty-setgid=[false|true]
Karel Zak [Fri, 15 Nov 2024 10:32:34 +0000 (11:32 +0100)] 
meson: add -D tty-setgid=[false|true]

If your distribution does not define permissions for installed
binaries and follows the upstream guidelines, disabling the tty
group's setgid could be a beneficial decision in certain situations.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 months agoautotools: add --disable-makeinstall-tty-setgid
Karel Zak [Fri, 15 Nov 2024 10:30:17 +0000 (11:30 +0100)] 
autotools: add --disable-makeinstall-tty-setgid

If your distribution does not define permissions for installed
binaries and follows the upstream guidelines, disabling the tty
group's setgid could be a beneficial decision in certain situations.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 months agoMerge branch 'PR/lscpu-hotplug' of https://github.com/karelzak/util-linux-work
Karel Zak [Wed, 6 Nov 2024 09:50:26 +0000 (10:50 +0100)] 
Merge branch 'PR/lscpu-hotplug' of https://github.com/karelzak/util-linux-work

* 'PR/lscpu-hotplug' of https://github.com/karelzak/util-linux-work:
  lscpu: fix incorrect number of sockets during hotplug

8 months agoMerge branch 'PR/nsenter-pidfd' of https://github.com/karelzak/util-linux-work
Karel Zak [Tue, 5 Nov 2024 10:17:10 +0000 (11:17 +0100)] 
Merge branch 'PR/nsenter-pidfd' of https://github.com/karelzak/util-linux-work

* 'PR/nsenter-pidfd' of https://github.com/karelzak/util-linux-work:
  nsenter: Rewrite --user-parent to use pidfd
  include/pidfd-utils: add namespaces ioctls
  nsenter: reuse pidfd for --net-socket
  nsenter: use macros to access the nsfiles array
  nsenter: use pidfd to enter target namespaces
  nsenter: use separate function to enter namespaces
  nsenter: add functions to enable/disable namespaces

8 months agolibsmartcols: make __attributes__ more portable
Karel Zak [Tue, 5 Nov 2024 10:10:31 +0000 (11:10 +0100)] 
libsmartcols: make __attributes__ more portable

Let's use what is already used for libmount. The header file is a public
header and does not require support for the __attribute__() compiler
feature. We need an additional #ifdef to ensure portability.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 months agoMerge branch 'smartcols-printf' of https://github.com/rjarry/util-linux
Karel Zak [Tue, 5 Nov 2024 10:08:26 +0000 (11:08 +0100)] 
Merge branch 'smartcols-printf' of https://github.com/rjarry/util-linux

* 'smartcols-printf' of https://github.com/rjarry/util-linux:
  treewide: use scols printf api where possible
  libsmartcols: add printf api to fill in column data

8 months agoMerge branch 'mkfds--minor-fixes' of https://github.com/masatake/util-linux
Karel Zak [Tue, 5 Nov 2024 10:00:11 +0000 (11:00 +0100)] 
Merge branch 'mkfds--minor-fixes' of https://github.com/masatake/util-linux

* 'mkfds--minor-fixes' of https://github.com/masatake/util-linux:
  tests: (test_mkfds::make-regular-file) fix the default union member for \"readable\" parameter
  test_mkfds: reserve file descriptors in the early stage of execution

8 months agoMerge branch 'PR/hardlink-nftw-imrovements' of https://github.com/karelzak/util-linux...
Karel Zak [Tue, 5 Nov 2024 09:59:13 +0000 (10:59 +0100)] 
Merge branch 'PR/hardlink-nftw-imrovements' of https://github.com/karelzak/util-linux-work

* 'PR/hardlink-nftw-imrovements' of https://github.com/karelzak/util-linux-work:
  hardlink: implement --mount
  hardlink: add missing verbose messages and unify them
  hardlink: implement --exclude-subtree

8 months agohardlink: add new options to the bash-completion
Karel Zak [Tue, 5 Nov 2024 09:56:14 +0000 (10:56 +0100)] 
hardlink: add new options to the bash-completion

Signed-off-by: Karel Zak <kzak@redhat.com>
8 months agolscpu: fix incorrect number of sockets during hotplug
Anjali K [Mon, 4 Nov 2024 06:32:26 +0000 (12:02 +0530)] 
lscpu: fix incorrect number of sockets during hotplug

lscpu sometimes shows incorrect 'Socket(s)' value if a hotplug operation
is running.
On a 32 CPU 2-socket system, the expected output is as shown below:
Architecture:                  ppc64le
Byte Order:                    Little Endian
CPU(s):                         32
On-line CPU(s) list:          0-31
Model name:                      POWER10 (architected), altivec supported
Model:                         2.0 (pvr 0080 0200)
Thread(s) per core:            8
Core(s) per socket:            2
Socket(s):                     2

On the same system, if hotplug is running along with lscpu, it shows
"Socket(s):" as 3 and 4 incorrectly sometimes.
Architecture:                         ppc64le
Byte Order:                           Little Endian
CPU(s):                               32
On-line CPU(s) list:                  0-11,16-31
Off-line CPU(s) list:                 12-15
Model name:                           POWER10 (architected), altivec supported
Model:                                2.0 (pvr 0080 0200)
Thread(s) per core:                   8
Core(s) per socket:                   1
Socket(s):                            3

The number of sockets is considered as the number of unique core_siblings
CPU groups. The issues causing the number of sockets to sometimes be
higher during hotplug is:
1. The core_siblings of CPUs on the same socket are different because a CPU
on the socket has been onlined/offlined in between. In the below example,
nr sockets was wrongly incremented for CPU 5 though CPU 4 and 5 are on the
same socket because their core_siblings was different as CPU 12 was onlined
in between.
CPU: 4
core_siblings: ff f0 0 0 0 0 0 0
CPU: 5
core_siblings: ff f8 0 0 0 0 0 0

2. The core_siblings file of a CPU is created when a CPU is onlined. It may
have an invalid value for some time until the online operation is fully
complete. In the below example, nr sockets is wrongly incremented because
the core_siblings of CPU 14 was 0 as it had just been onlined.
CPU: 14
core_siblings: 0 0 0 0 0 0 0 0

To fix this, make the below changes:
1. Instead of considering CPUs to be on different sockets if their
core_siblings masks are unequal, consider them to be on different sockets
only if their core_siblings masks don't have even one common CPU. Then CPUs
on the same socket will be correctly identified even if offline/online
operations happen while they are read if at least one CPU in the socket is
online during both reads.
2. Check if a CPU's hotplug operation has been completed before using its
core_siblings file

[kzak@redhat.com: - use xmalloc(),
                  - use ul_strtos32(),
                  - use err() on CPU_ALLOC() error]

Reported-by: Anushree Mathur <anushree.mathur@linux.vnet.ibm.com>
Signed-off-by: Anjali K <anjalik@linux.ibm.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 months agotreewide: use scols printf api where possible
Robin Jarry [Thu, 31 Oct 2024 22:55:44 +0000 (23:55 +0100)] 
treewide: use scols printf api where possible

Everywhere a string generated with xasprintf() is directly passed to
scols_line_refer_data(), use scols_line_sprintf() to remove the need for
an intermediate buffer.

Replace the (now redundant) private scols_line_asprintf() function.

Signed-off-by: Robin Jarry <robin@jarry.cc>
9 months agolibsmartcols: add printf api to fill in column data
Robin Jarry [Thu, 31 Oct 2024 22:16:56 +0000 (23:16 +0100)] 
libsmartcols: add printf api to fill in column data

Add new API functions using printf(3) compatible format strings to fill
in column data.

These can be used to avoid intermediate buffers in the calling
application code.

Signed-off-by: Robin Jarry <robin@jarry.cc>
9 months agotests: (test_mkfds::make-regular-file) fix the default union member for \"readable...
Masatake YAMATO [Sat, 26 Oct 2024 20:23:03 +0000 (05:23 +0900)] 
tests: (test_mkfds::make-regular-file) fix the default union member for \"readable\" parameter

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
9 months agotest_mkfds: reserve file descriptors in the early stage of execution
Masatake YAMATO [Sat, 26 Oct 2024 17:05:45 +0000 (02:05 +0900)] 
test_mkfds: reserve file descriptors in the early stage of execution

A factory specified with command line opens some files.  After
opening, the factory remaps the opened file descriptors (ofds) to file
descriptors (rfds) specified with the command line with dup2 system all.

This remapping may fail if there is an overlap between ofds and rfds.
With this change, there cannot be an overlap between ofds and rfds;
test_mkfds reserves rfds in the early stage of execution.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
9 months agohardlink: implement --mount
Karel Zak [Thu, 31 Oct 2024 10:21:20 +0000 (11:21 +0100)] 
hardlink: implement --mount

Let's export another feature of nftw() to the hardlink command line.
In this case, we will force the file-tree-walk to stay within the same
filesystem.

Addresses: https://github.com/util-linux/util-linux/discussions/3244
Signed-off-by: Karel Zak <kzak@redhat.com>
9 months agohardlink: add missing verbose messages and unify them
Karel Zak [Thu, 31 Oct 2024 10:00:32 +0000 (11:00 +0100)] 
hardlink: add missing verbose messages and unify them

* use the concept of "Skipped (<reason>) <filename>" for all verbose  messages

* also add "Skipped" messages for the options --exclude and --exclude-subtree

Signed-off-by: Karel Zak <kzak@redhat.com>
9 months agohardlink: implement --exclude-subtree
Karel Zak [Thu, 31 Oct 2024 09:51:11 +0000 (10:51 +0100)] 
hardlink: implement --exclude-subtree

Now, it is possible to exclude files by their names, but it does not
allow for ignoring entire subtrees of the scanned hierarchy. The new
option only applies to directory names and forces the file-tree-walk
to skip the directory and all of its subdirectories.

This is based on FTW_SKIP_SUBTREE, which was originally only available
in glibc (since 2004). Therefore, the code is #ifdef-ed to make it
portable to other libc versions.

Addresses: https://github.com/util-linux/util-linux/discussions/3244
Signed-off-by: Karel Zak <kzak@redhat.com>
9 months agohardlink: re-raise SIGINT instead of exiting
наб [Mon, 28 Oct 2024 18:19:53 +0000 (19:19 +0100)] 
hardlink: re-raise SIGINT instead of exiting

Every TRUE return was either exit(1) or "return error;" anyway,
this is more correct (exit-status-wise) and doesn't hang pipelines weirdly

This also removes a seemingly-extraneous newline written to the standard
output stream in the interrupt handler itself?

9 months agohardlink: fix 0-sized file processing
наб [Mon, 28 Oct 2024 18:19:34 +0000 (19:19 +0100)] 
hardlink: fix 0-sized file processing

The manual says that -s0 will process 0-sized files normally,
but as it stands (a) hardlink considers 0-sized files unlinkable
(so, with -l, unlistable) and (b) fileeq considers reading an empty
prologue to be an error

9 months agohardlink: add --list-duplicates and --zero
наб [Mon, 28 Oct 2024 18:19:30 +0000 (19:19 +0100)] 
hardlink: add --list-duplicates and --zero

--list-duplicates codifies what everyone keeps re-implementing with
find -exec b2sum or src:perforate's finddup or whatever.

hardlink already knows this, so make the data available thusly,
in a format well-suited for pipeline processing
(fixed-width key for uniq/cut/&c.,
 tab delimiter for cut &a.,
 -z for correct filename handling).

9 months agohardlink.1: directory|file is mandatory
наб [Mon, 28 Oct 2024 18:19:14 +0000 (19:19 +0100)] 
hardlink.1: directory|file is mandatory

9 months agoMerge branch 'PR/liblastlog2-stderr' of https://github.com/karelzak/util-linux-work
Karel Zak [Wed, 30 Oct 2024 10:14:46 +0000 (11:14 +0100)] 
Merge branch 'PR/liblastlog2-stderr' of https://github.com/karelzak/util-linux-work

* 'PR/liblastlog2-stderr' of https://github.com/karelzak/util-linux-work:
  tests: (liblastlog2) don't write to stderr and stdout

9 months agoMerge branch 'lsfd--bpf-prog-id-and-tag' of https://github.com/masatake/util-linux
Karel Zak [Wed, 30 Oct 2024 10:14:19 +0000 (11:14 +0100)] 
Merge branch 'lsfd--bpf-prog-id-and-tag' of https://github.com/masatake/util-linux

* 'lsfd--bpf-prog-id-and-tag' of https://github.com/masatake/util-linux:
  tests: (lsfd::mkfds-bpf-prog) verify BPF-PROG.{ID,TAG} column
  tests: (test_mkfds::bpf-prog) report id and tag
  lsfd: add BPF-PROG.TAG column
  lsfd: update bpf related tables
  lsfd: (bugfix) fix wrong type usage in anon_bpf_map_fill_column
  test_mkfds: (bugfix) listing ALL output values for a given factory

9 months agobits: cleanup --help output, add missing _( )
Karel Zak [Wed, 30 Oct 2024 10:10:19 +0000 (11:10 +0100)] 
bits: cleanup --help output, add missing _( )

Signed-off-by: Karel Zak <kzak@redhat.com>
9 months agotests: (lsfd::mkfds-bpf-prog) verify BPF-PROG.{ID,TAG} column
Masatake YAMATO [Fri, 25 Oct 2024 20:41:29 +0000 (05:41 +0900)] 
tests: (lsfd::mkfds-bpf-prog) verify BPF-PROG.{ID,TAG} column

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
9 months agotests: (test_mkfds::bpf-prog) report id and tag
Masatake YAMATO [Fri, 25 Oct 2024 20:32:47 +0000 (05:32 +0900)] 
tests: (test_mkfds::bpf-prog) report id and tag

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
9 months agolsfd: add BPF-PROG.TAG column
Masatake YAMATO [Mon, 14 Oct 2024 07:31:02 +0000 (16:31 +0900)] 
lsfd: add BPF-PROG.TAG column

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
9 months agolsfd: update bpf related tables
Masatake YAMATO [Mon, 14 Oct 2024 07:51:33 +0000 (16:51 +0900)] 
lsfd: update bpf related tables

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
9 months agolsfd: (bugfix) fix wrong type usage in anon_bpf_map_fill_column
Masatake YAMATO [Mon, 14 Oct 2024 08:39:15 +0000 (17:39 +0900)] 
lsfd: (bugfix) fix wrong type usage in anon_bpf_map_fill_column

Where we should use anon_bpf_map_data, anon_bpf_prog_data was used.
Fortunately, this has not been a big trouble because anon_bpf_map_data
and anon_bpf_prog_data had no difference in their member layout

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
9 months agotest_mkfds: (bugfix) listing ALL output values for a given factory
Masatake YAMATO [Fri, 25 Oct 2024 20:14:06 +0000 (05:14 +0900)] 
test_mkfds: (bugfix) listing ALL output values for a given factory

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
9 months agotext-utils: add bits command
Robin Jarry [Mon, 6 May 2024 21:45:21 +0000 (23:45 +0200)] 
text-utils: add bits command

Add a new text utility to convert bit masks in various formats.

This can be handy to avoid parsing affinity masks in one's head and/or
to interact with the kernel in a more human friendly way. It is
a rewrite in C of the bits command from my linux-tools python package so
that it can be more widely available.

Here is an example:

 ~# cat /sys/kernel/debug/tracing/tracing_cpumask
 ffffffff,ffffffff,ffffffff,ffffffff
 ~# bits -l ,$(cat /sys/kernel/debug/tracing/tracing_cpumask)
 0-128
 ~# bits -g 58,59,120,123
 9000000,00000000,0c000000,00000000
 ~# bits -g 58,59,120,123 > /sys/kernel/debug/tracing/tracing_cpumask
 ~# echo 1 > /sys/kernel/debug/tracing/tracing_on

Add man page and basic tests.

Link: https://git.sr.ht/~rjarry/linux-tools#bits
Signed-off-by: Robin Jarry <robin@jarry.cc>
9 months agotests: (liblastlog2) don't write to stderr and stdout
Karel Zak [Tue, 22 Oct 2024 09:17:23 +0000 (11:17 +0200)] 
tests: (liblastlog2) don't write to stderr and stdout

Signed-off-by: Karel Zak <kzak@redhat.com>
9 months agohwclock: cleanup save_adjtime()
Karel Zak [Tue, 22 Oct 2024 08:22:08 +0000 (10:22 +0200)] 
hwclock: cleanup save_adjtime()

Signed-off-by: Karel Zak <kzak@redhat.com>
9 months agoMerge branch 'patch-1' of https://github.com/bearhoney/util-linux
Karel Zak [Tue, 22 Oct 2024 08:13:04 +0000 (10:13 +0200)] 
Merge branch 'patch-1' of https://github.com/bearhoney/util-linux

* 'patch-1' of https://github.com/bearhoney/util-linux:
  Update chsh.1.adoc to avoid duplicates in man page

9 months agoMerge branch 'patch-1' of https://github.com/Geo25rey/util-linux
Karel Zak [Tue, 22 Oct 2024 08:12:09 +0000 (10:12 +0200)] 
Merge branch 'patch-1' of https://github.com/Geo25rey/util-linux

* 'patch-1' of https://github.com/Geo25rey/util-linux:
  doc: fsck.8.adoc - fix email typo

9 months agoMerge branch 'hwclock' of https://github.com/maks-mishin/util-linux
Karel Zak [Tue, 22 Oct 2024 08:10:38 +0000 (10:10 +0200)] 
Merge branch 'hwclock' of https://github.com/maks-mishin/util-linux

* 'hwclock' of https://github.com/maks-mishin/util-linux:
  sys-utils: (save_adjtime): fix memory leak

9 months agonsenter: Rewrite --user-parent to use pidfd
Karel Zak [Mon, 21 Oct 2024 11:09:43 +0000 (13:09 +0200)] 
nsenter: Rewrite --user-parent to use pidfd

The latest kernel pidfd supports ioctls to ask for the target's
namespaces. It seems we can use it for --user-parent if no user
namespace is explicitly specified. The fallback is to use any other
namespace or open the target's /proc/<pid>/ns/user file directly.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 months agoinclude/pidfd-utils: add namespaces ioctls
Karel Zak [Mon, 21 Oct 2024 11:08:36 +0000 (13:08 +0200)] 
include/pidfd-utils: add namespaces ioctls

Signed-off-by: Karel Zak <kzak@redhat.com>
9 months agonsenter: reuse pidfd for --net-socket
Karel Zak [Fri, 18 Oct 2024 12:50:11 +0000 (14:50 +0200)] 
nsenter: reuse pidfd for --net-socket

Signed-off-by: Karel Zak <kzak@redhat.com>
9 months agonsenter: use macros to access the nsfiles array
Karel Zak [Fri, 18 Oct 2024 12:08:35 +0000 (14:08 +0200)] 
nsenter: use macros to access the nsfiles array

This change implements macros to access the nsfiles array, resulting
in a slight reduction in code.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 months agonsenter: use pidfd to enter target namespaces
Karel Zak [Fri, 18 Oct 2024 10:16:04 +0000 (12:16 +0200)] 
nsenter: use pidfd to enter target namespaces

The typical use case is to enter namespaces of the task (--target
<pid>). The original nsenter opens /proc/<pid>/ns/* files and uses the
file descriptors to enter the namespaces by setns(). The recent kernel
allows using the pid file descriptor instead of the files in /proc,
making it possible to enter multiple namespaces with one setns call.
This solution reduces the number of syscalls (open+setns for each
namespace), removes the dependence on /proc, and allows entering
nested namespaces.

This commit should be backwardly compatible, meaning it can be used on
systems without pidfd_open(). Explicitly specified namespaces by
filenames are still supported, and user namespaces are still entered
first/last according to permissions privileging/deprivileging.

Addresses: https://github.com/util-linux/util-linux/pull/301
Signed-off-by: Karel Zak <kzak@redhat.com>
9 months agonsenter: use separate function to enter namespaces
Karel Zak [Thu, 17 Oct 2024 10:17:10 +0000 (12:17 +0200)] 
nsenter: use separate function to enter namespaces

Remove the complicated for-loop from the main() function and instead
use a separate function to enable namespaces based on a given mask.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 months agoUpdate chsh.1.adoc to avoid duplicates in man page
bearhoney [Sun, 20 Oct 2024 21:21:02 +0000 (23:21 +0200)] 
Update chsh.1.adoc to avoid duplicates in man page

Excluded  man-common/help-version.adoc  to avoid duplicate -h  and -V option descriptions in the man page for  chsh(1).

9 months agodoc: fsck.8.adoc - fix email typo
Geoffrey Casper [Sat, 19 Oct 2024 05:34:35 +0000 (01:34 -0400)] 
doc: fsck.8.adoc - fix email typo

9 months agonsenter: add functions to enable/disable namespaces
Karel Zak [Thu, 17 Oct 2024 09:14:49 +0000 (11:14 +0200)] 
nsenter: add functions to enable/disable namespaces

Currently, enabled namespaces are those with an open file descriptor.
However, if we support pidfd, this will become unnecessary and we will
need an FD-independent enable/disable mechanism.

It also makes sense to delay opening --target <pid> namespaces files
until everything is ready and only handle it in one place.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 months agosys-utils: (save_adjtime): fix memory leak
Maks Mishin [Thu, 17 Oct 2024 04:14:26 +0000 (07:14 +0300)] 
sys-utils: (save_adjtime): fix memory leak

Dynamic memory, referenced by 'content', is allocated by calling function 'xasprintf'
and lost when function returns.

Found by the static analyzer Svace.

9 months agosfdisk: add --sector-size commanand line option
Karel Zak [Mon, 14 Oct 2024 13:50:40 +0000 (15:50 +0200)] 
sfdisk: add --sector-size commanand line option

* improves compatibility with fdisk
* add ability to work with disk images where libfdisk defaults to 512

Addresses: https://github.com/util-linux/util-linux/pull/3235
Signed-off-by: Karel Zak <kzak@redhat.com>
9 months agocfdisk: add --sector-size commanand line option
Karel Zak [Mon, 14 Oct 2024 13:48:46 +0000 (15:48 +0200)] 
cfdisk: add --sector-size commanand line option

* improves compatibility with fdisk
* add ability to work with disk images where libfdisk defaults to 512

Signed-off-by: Karel Zak <kzak@redhat.com>
9 months agofdisk: (man) improve --sector-size description
Karel Zak [Mon, 14 Oct 2024 13:47:03 +0000 (15:47 +0200)] 
fdisk: (man) improve --sector-size description

Signed-off-by: Karel Zak <kzak@redhat.com>
9 months agolibfdisk: make sure libblkid uses the same sector size
Karel Zak [Mon, 14 Oct 2024 09:45:32 +0000 (11:45 +0200)] 
libfdisk: make sure libblkid uses the same sector size

Libfdisk uses libblkid to check for filesystems on the device. It
makes sense for both libraries to share the logical sector size
setting, as this setting can be modified by using the fdisk command
line.

We do not see this as an issue, as filesystem detection rarely depends
on sector size (with the exception of some RAIDs). Additionally,
libblkid is usually intelligent enough to check multiple locations
independently of the current device's sector size setting.

Addresses: https://github.com/util-linux/util-linux/pull/3235
Signed-off-by: Karel Zak <kzak@redhat.com>
9 months agoMerge branch 'setpriv-parse-securebits' of https://github.com/maks-mishin/util-linux
Karel Zak [Mon, 14 Oct 2024 08:12:48 +0000 (10:12 +0200)] 
Merge branch 'setpriv-parse-securebits' of https://github.com/maks-mishin/util-linux

* 'setpriv-parse-securebits' of https://github.com/maks-mishin/util-linux:
  sys-utils: (setpriv): fix potential memory leak

9 months agosys-utils: (setpriv): fix potential memory leak
Maks Mishin [Thu, 10 Oct 2024 17:23:49 +0000 (20:23 +0300)] 
sys-utils: (setpriv): fix potential memory leak

Dynamic memory, referenced by 'buf' is allocated by calling function 'xstrdup'
add then changed by calling of strsep function.
The free(buf) call is incorrect if buf != NULL, and points to some
place inside or outside the source string.

9 months agolibblkid: add FSLASTBLOCK for swaparea
Karel Zak [Wed, 9 Oct 2024 07:54:41 +0000 (09:54 +0200)] 
libblkid: add FSLASTBLOCK for swaparea

Suggested-by: Peter Rajnoha <prajnoha@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 months agoMerge branch 'ci/llvm-19' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 7 Oct 2024 11:30:04 +0000 (13:30 +0200)] 
Merge branch 'ci/llvm-19' of https://github.com/t-8ch/util-linux

* 'ci/llvm-19' of https://github.com/t-8ch/util-linux:
  ci: use clang 19

9 months agoMerge branch 'sock-netns-with-tests' of https://github.com/masatake/util-linux
Karel Zak [Mon, 7 Oct 2024 11:27:43 +0000 (13:27 +0200)] 
Merge branch 'sock-netns-with-tests' of https://github.com/masatake/util-linux

* 'sock-netns-with-tests' of https://github.com/masatake/util-linux:
  tests: (lsfd) verify SOCK.NETID and ENDPOINTS for sockets made in another netns
  tests: (lsns) verify the code finding an isolated netns via socket
  tests: (nsenter) verify the code entering the network ns via socket made in the ns
  tests: (test_sysinfo) add a helper to detect NS_GET_USERNS
  tests: (test_mkfds::foreign-sockets) new factory
  tests: (test_mkfds, refactor) use xmemdup newly added in xalloc.h
  xalloc.h: add xmemdup
  tests: (test_mkfds) fix a typo in an option name
  test_mkfds: (cosmetic) remove whitespaces between a function and its arguments

9 months agoMerge branch 'libblkid/ubsan/exfat' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 7 Oct 2024 11:18:13 +0000 (13:18 +0200)] 
Merge branch 'libblkid/ubsan/exfat' of https://github.com/t-8ch/util-linux

* 'libblkid/ubsan/exfat' of https://github.com/t-8ch/util-linux:
  libblkid: (exfat): validate fields used by prober

9 months agoMerge branch 'lsfd--minor-fixes' of https://github.com/masatake/util-linux
Karel Zak [Mon, 7 Oct 2024 08:22:07 +0000 (10:22 +0200)] 
Merge branch 'lsfd--minor-fixes' of https://github.com/masatake/util-linux

* 'lsfd--minor-fixes' of https://github.com/masatake/util-linux:
  lsfd: avoid accessing an uninitialized value
  lsfd: finalize abst_class
  lsfd,test_mkfds: (refactor) specify the variable itself as an operand of sizeof
  tests: (test_mkfds) add a missing word in a comment

9 months agolibblkid: (exfat): validate fields used by prober
Thomas Weißschuh [Thu, 3 Oct 2024 07:14:57 +0000 (09:14 +0200)] 
libblkid: (exfat): validate fields used by prober

The exFAT specification lists valid value ranges for the superblock
fields. Validate the fields interpreted by the libblkid prober to avoid
undefined behaviour.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
9 months agolsfd: avoid accessing an uninitialized value
Masatake YAMATO [Thu, 3 Oct 2024 06:17:01 +0000 (15:17 +0900)] 
lsfd: avoid accessing an uninitialized value

sb, a local variable in collect_file_symlink, accessed
at

bool is_socket = (sb.st_mode & S_IFMT) == S_IFSOCK;

was not initialized if copy_file path is taken.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
9 months agolsfd: finalize abst_class
Masatake YAMATO [Thu, 3 Oct 2024 06:14:10 +0000 (15:14 +0900)] 
lsfd: finalize abst_class

This fixes a memory leak of still-reachable kind.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
9 months agolsfd,test_mkfds: (refactor) specify the variable itself as an operand of sizeof
Masatake YAMATO [Tue, 1 Oct 2024 20:58:34 +0000 (05:58 +0900)] 
lsfd,test_mkfds: (refactor) specify the variable itself as an operand of sizeof

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
9 months agotests: (test_mkfds) add a missing word in a comment
Masatake YAMATO [Thu, 3 Oct 2024 02:41:56 +0000 (11:41 +0900)] 
tests: (test_mkfds) add a missing word in a comment

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
9 months agotests: (lsfd) verify SOCK.NETID and ENDPOINTS for sockets made in another netns
Masatake YAMATO [Wed, 18 Sep 2024 19:32:42 +0000 (04:32 +0900)] 
tests: (lsfd) verify SOCK.NETID and ENDPOINTS for sockets made in another netns

This is for testing PR #3200.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
9 months agotests: (lsns) verify the code finding an isolated netns via socket
Masatake YAMATO [Wed, 18 Sep 2024 20:01:49 +0000 (05:01 +0900)] 
tests: (lsns) verify the code finding an isolated netns via socket

This is for testing PR #3200.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
9 months agoMerge branch 'PR/libmount-xnocanon' of https://github.com/karelzak/util-linux-work
Karel Zak [Wed, 2 Oct 2024 08:06:10 +0000 (10:06 +0200)] 
Merge branch 'PR/libmount-xnocanon' of https://github.com/karelzak/util-linux-work

* 'PR/libmount-xnocanon' of https://github.com/karelzak/util-linux-work:
  mount: (man) add note about symlink over symlink
  tests: add X-mount.nocanonicalize tests
  libmount: support bind symlink over symlink
  libmount: add X-mount.nocanonicalize[=source|target]

10 months agotests: (nsenter) verify the code entering the network ns via socket made in the ns
Masatake YAMATO [Thu, 19 Sep 2024 14:23:09 +0000 (23:23 +0900)] 
tests: (nsenter) verify the code entering the network ns via socket made in the ns

This is for testing PR #3200.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
10 months agotests: (test_sysinfo) add a helper to detect NS_GET_USERNS
Masatake YAMATO [Fri, 20 Sep 2024 20:10:38 +0000 (05:10 +0900)] 
tests: (test_sysinfo) add a helper to detect NS_GET_USERNS

This can be used to detect qemu-user returning ENOSYS for invalid ioctl
numbers.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
10 months agotests: (test_mkfds::foreign-sockets) new factory
Masatake YAMATO [Wed, 18 Sep 2024 19:04:40 +0000 (04:04 +0900)] 
tests: (test_mkfds::foreign-sockets) new factory

The way to make a socket in another net namespace is
suggested by Dmitry Safonov.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
10 months agotests: (test_mkfds, refactor) use xmemdup newly added in xalloc.h
Masatake YAMATO [Wed, 18 Sep 2024 19:01:23 +0000 (04:01 +0900)] 
tests: (test_mkfds, refactor) use xmemdup newly added in xalloc.h

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
10 months agoxalloc.h: add xmemdup
Masatake YAMATO [Thu, 26 Sep 2024 18:58:07 +0000 (03:58 +0900)] 
xalloc.h: add xmemdup

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
10 months agotests: (test_mkfds) fix a typo in an option name
Masatake YAMATO [Fri, 20 Sep 2024 19:22:00 +0000 (04:22 +0900)] 
tests: (test_mkfds) fix a typo in an option name

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
10 months agotest_mkfds: (cosmetic) remove whitespaces between a function and its arguments
Masatake YAMATO [Thu, 26 Sep 2024 19:11:24 +0000 (04:11 +0900)] 
test_mkfds: (cosmetic) remove whitespaces between a function and its arguments

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
10 months agomount: (man) add note about symlink over symlink
Karel Zak [Thu, 26 Sep 2024 13:56:02 +0000 (15:56 +0200)] 
mount: (man) add note about symlink over symlink

Signed-off-by: Karel Zak <kzak@redhat.com>
10 months agotests: add X-mount.nocanonicalize tests
Karel Zak [Thu, 26 Sep 2024 13:49:37 +0000 (15:49 +0200)] 
tests: add X-mount.nocanonicalize tests

Signed-off-by: Karel Zak <kzak@redhat.com>
10 months agoMerge branch 'test_mkfds-dont-free-and-close-when-exit-with-error' of https://github...
Karel Zak [Tue, 1 Oct 2024 11:56:52 +0000 (13:56 +0200)] 
Merge branch 'test_mkfds-dont-free-and-close-when-exit-with-error' of https://github.com/masatake/util-linux

* 'test_mkfds-dont-free-and-close-when-exit-with-error' of https://github.com/masatake/util-linux:
  tests: (test_mkfds) don't close fds and free memory objects when exiting with EXIT_FAILURE
  tests: (test_mkfds,refactor) simplify nested if conditions
  tests: (test_mkfds) save errno before calling system calls for clean-up
  tests: (test_mkfds, cosmetic) add an empty line before the definition of struct sysvshm_data

10 months agoMerge branch 'PR/libfdisk-EBR-list' of https://github.com/karelzak/util-linux-work
Karel Zak [Tue, 1 Oct 2024 11:55:21 +0000 (13:55 +0200)] 
Merge branch 'PR/libfdisk-EBR-list' of https://github.com/karelzak/util-linux-work

* 'PR/libfdisk-EBR-list' of https://github.com/karelzak/util-linux-work:
  libfdisk: (dos) ignore incomplete EBR for non-wholedisk

10 months agoci: use clang 19
Thomas Weißschuh [Fri, 27 Sep 2024 20:13:15 +0000 (22:13 +0200)] 
ci: use clang 19

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
10 months agotests: (test_mkfds) don't close fds and free memory objects when exiting with EXIT_FA...
Masatake YAMATO [Fri, 27 Sep 2024 17:06:19 +0000 (02:06 +0900)] 
tests: (test_mkfds) don't close fds and free memory objects when exiting with EXIT_FAILURE

However, we keep calling unlink even when exiting with EXIT_FAILURE not to pollute
file system.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
10 months agotests: (test_mkfds,refactor) simplify nested if conditions
Masatake YAMATO [Fri, 27 Sep 2024 16:44:21 +0000 (01:44 +0900)] 
tests: (test_mkfds,refactor) simplify nested if conditions

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
10 months agotests: (test_mkfds) save errno before calling system calls for clean-up
Masatake YAMATO [Fri, 27 Sep 2024 16:39:52 +0000 (01:39 +0900)] 
tests: (test_mkfds) save errno before calling system calls for clean-up

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
10 months agotests: (test_mkfds, cosmetic) add an empty line before the definition of struct sysvs...
Masatake YAMATO [Fri, 27 Sep 2024 16:23:21 +0000 (01:23 +0900)] 
tests: (test_mkfds, cosmetic) add an empty line before the definition of struct sysvshm_data

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
10 months agolibmount: support bind symlink over symlink
Karel Zak [Thu, 26 Sep 2024 12:44:36 +0000 (14:44 +0200)] 
libmount: support bind symlink over symlink

The new mount API allows for the use of AT_SYMLINK_NOFOLLOW when
opening a mount tree (aka the "mount source" for libmount).
As a result, you can now replace one symlink with another by using a
bind mount.

By default, the mount(8) command follows symlinks and canonicalizes
all paths. However, with the X-mount.nocanonicalize=source option, it
is possible to open the symlink itself. Similarly, with the
X-mount.nocanonicalize=target option, the path of the mount point can
be kept as the original symlink. (Using X-mount.nocanonicalize without
any argument works for both the "source" and "target".)

Example:

 # file /mnt/test/symlinkA /mnt/test/symlinkB
 /mnt/test/symlinkA: symbolic link to /mnt/test/fileA
 /mnt/test/symlinkB: symbolic link to /mnt/test/fileB

 # strace -e open_tree,move_mount \
   ./mount --bind -o X-mount.nocanonicalize /mnt/test/symlinkA /mnt/test/symlinkB
 ...
 open_tree(AT_FDCWD, "/mnt/test/symlinkA", OPEN_TREE_CLONE|OPEN_TREE_CLOEXEC|AT_SYMLINK_NOFOLLOW) = 3
 move_mount(3, "", AT_FDCWD, "/mnt/test/symlinkB", MOVE_MOUNT_F_EMPTY_PATH) = 0

 # ls -la  /mnt/test/symlinkB
 lrwxrwxrwx 1 root root 15 Sep 26 13:41 /mnt/test/symlinkB -> /mnt/test/fileA

The result is that 'symlinkB' is still a symlink, but it now points to
a different file.

This commit also modifies umount(8) because it does not work with
symlinks by default. The solution is to call umount2(UMOUNT_NOFOLLOW)
for symlinks after a failed regular umount(). For example:

 # strace -e umount,umount2 \
   ./umount /mnt/test/symlinkB
 ...
 umount2("/mnt/test/symlinkB", 0)        = -1 EINVAL (Invalid argument)
 umount2("/mnt/test/symlinkB", UMOUNT_NOFOLLOW) = 0

Signed-off-by: Karel Zak <kzak@redhat.com>
10 months agoMerge branch 'meson/pidfd_getfd' of https://github.com/t-8ch/util-linux
Karel Zak [Wed, 25 Sep 2024 11:43:50 +0000 (13:43 +0200)] 
Merge branch 'meson/pidfd_getfd' of https://github.com/t-8ch/util-linux

* 'meson/pidfd_getfd' of https://github.com/t-8ch/util-linux:
  meson: test for pidfd_getfd()

10 months agologin-utils/su-common: Validate all return values again
Thomas Weißschuh [Wed, 25 Sep 2024 06:12:45 +0000 (08:12 +0200)] 
login-utils/su-common: Validate all return values again

The additional coded added in commit
d6564701e812 ("login-utils/su-common: Check that the user didn't change during PAM transaction")
was inserted in between the assignment and tests of "rc",
making the return value unchecked.
Add a new explicit check.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
10 months agomeson: test for pidfd_getfd()
Thomas Weißschuh [Wed, 25 Sep 2024 06:09:29 +0000 (08:09 +0200)] 
meson: test for pidfd_getfd()

Commit 55c7120accab ("nsenter: Provide an option to join target process's socket net namespace")
added stubs for pidfd_getfd() but didn't add the code for meson to check
if the function is already available.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
10 months agoautotools: allow enabling dmesg with --disable-all-programs
Henrik Lindström [Sat, 21 Sep 2024 08:23:10 +0000 (10:23 +0200)] 
autotools: allow enabling dmesg with --disable-all-programs

Signed-off-by: Henrik Lindström <henrik@lxm.se>
10 months agoautotools: allow enabling lsblk with --disable-all-programs
Henrik Lindström [Sat, 21 Sep 2024 08:23:09 +0000 (10:23 +0200)] 
autotools: allow enabling lsblk with --disable-all-programs

Signed-off-by: Henrik Lindström <henrik@lxm.se>
10 months agolibfdisk: (dos) ignore incomplete EBR for non-wholedisk
Karel Zak [Tue, 24 Sep 2024 11:37:13 +0000 (13:37 +0200)] 
libfdisk: (dos) ignore incomplete EBR for non-wholedisk

The logical partitions are defined by a chain of extended partitions,
with the beginning of the chain located on the whole disk device.

If a user runs "fdisk --list /dev/sda4", libfdisk cannot calculate proper
offsets for the items in the chain, resulting in the following error
message:

 Failed to read extended partition table (offset=22528): Invalid argument

This error message may confuse users and is unnecessary when fdisk is
used in list-only mode (--list option). It would be sufficient to only
print the content of the partition without the error message and not
continue to the next item in the chain.

However, in write mode (without --list), the error message will still
be displayed as it is potentially dangerous to edit the EBR table.

Addresses: https://issues.redhat.com/browse/RHEL-59867
Signed-off-by: Karel Zak <kzak@redhat.com>
10 months agoMerge branch 'su-double-check-pam-user' of https://github.com/3v1n0/util-linux
Karel Zak [Tue, 24 Sep 2024 10:54:53 +0000 (12:54 +0200)] 
Merge branch 'su-double-check-pam-user' of https://github.com/3v1n0/util-linux

* 'su-double-check-pam-user' of https://github.com/3v1n0/util-linux:
  login-utils/su-common: Check that the user didn't change during PAM transaction

10 months agolibmount: add X-mount.nocanonicalize[=source|target]
Karel Zak [Thu, 19 Sep 2024 09:13:22 +0000 (11:13 +0200)] 
libmount: add X-mount.nocanonicalize[=source|target]

The new kernel mount API can bind-mount over a symlink. However, this
feature does not work with libmount because it canonicalizes all paths
by default. A possible workaround is to use the --no-canonicalize
option on the mount(8) command line, but this is a heavy-handed
solution as it disables all conversions for all paths and tags (such
as LABEL=) and fstab processing.

This commit introduces the X-mount.nocanonicalize userspace mount
option to control canonicalization. It only affects paths used for
mounting and does not affect tags and searching in fstab. Additionally,
this setting possible to use in fstab.

If the optional argument [=source|target] is not specified, then paths
canonicalization is disabled for both the source and target paths.

Adresses: https://github.com/util-linux/util-linux/issues/2370
Signed-off-by: Karel Zak <kzak@redhat.com>
10 months agoMerge branch 'test_mkfds--fix-typos' of https://github.com/masatake/util-linux
Karel Zak [Tue, 24 Sep 2024 10:39:35 +0000 (12:39 +0200)] 
Merge branch 'test_mkfds--fix-typos' of https://github.com/masatake/util-linux

* 'test_mkfds--fix-typos' of https://github.com/masatake/util-linux:
  tests: (test_mkfds) fix the way to detect errors in fork(2)

10 months agoMerge branch 'master' of https://github.com/hramrach/util-linux
Karel Zak [Tue, 24 Sep 2024 10:38:47 +0000 (12:38 +0200)] 
Merge branch 'master' of https://github.com/hramrach/util-linux

* 'master' of https://github.com/hramrach/util-linux:
  partx: Fix example in man page

10 months agobash-completion: add nsenter --net-socket
Karel Zak [Tue, 24 Sep 2024 10:34:17 +0000 (12:34 +0200)] 
bash-completion: add nsenter --net-socket

Signed-off-by: Karel Zak <kzak@redhat.com>
10 months agoMerge branch 'sock-netns' of https://github.com/0x7f454c46/util-linux
Karel Zak [Tue, 24 Sep 2024 10:31:39 +0000 (12:31 +0200)] 
Merge branch 'sock-netns' of https://github.com/0x7f454c46/util-linux

* 'sock-netns' of https://github.com/0x7f454c46/util-linux:
  lsns: List network namespaces that are held by a socket
  lsfd: Gather information on target socket's net namespace
  nsenter: Provide an option to join target process's socket net namespace

10 months agoMerge branch 'patch-2' of https://github.com/firasuke/util-linux
Karel Zak [Tue, 24 Sep 2024 10:28:59 +0000 (12:28 +0200)] 
Merge branch 'patch-2' of https://github.com/firasuke/util-linux

* 'patch-2' of https://github.com/firasuke/util-linux:
  Fix typos in TODO

10 months agoMerge branch 'patch-1' of https://github.com/firasuke/util-linux
Karel Zak [Tue, 24 Sep 2024 10:28:37 +0000 (12:28 +0200)] 
Merge branch 'patch-1' of https://github.com/firasuke/util-linux

* 'patch-1' of https://github.com/firasuke/util-linux:
  Update description of --disable-poman in configure.ac

10 months agoCI: Downgrade checkout version for compat build
Michal Suchanek [Tue, 24 Sep 2024 09:05:59 +0000 (11:05 +0200)] 
CI: Downgrade checkout version for compat build

The current checkout action does not run on Ubuntu 18.04

/usr/bin/docker exec  90a3de3652fb2e69b0cf70fc8567dba6b1a25bf1a6645236d19bb6f1486c6158 sh -c "cat /etc/*release | grep ^ID"
/__e/node20/bin/node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /__e/node20/bin/node)

Fixes: #3215
10 months agopartx: Fix example in man page
Michal Suchanek [Tue, 24 Sep 2024 07:19:39 +0000 (09:19 +0200)] 
partx: Fix example in man page

The example is:

  partx -d --nr :-1 /dev/sdd
  Removes the last partition on _/dev/sdd_.

The documentation says:

           M:
               Specifies the lower limit only (e.g. --nr 2:).

           :N
               Specifies the upper limit only (e.g. --nr :4).

In the above example the lower limit is not set and the upper is set to
the last partition, meaning all partitions. The lower limit should be
set instead.

  partx -d --nr -1: /dev/sdd

10 months agolsns: List network namespaces that are held by a socket
Dmitry Safonov [Wed, 18 Sep 2024 17:48:54 +0000 (18:48 +0100)] 
lsns: List network namespaces that are held by a socket

While parsing process's fds, check the network namespace of the socket.
That will provide fuller list of namespaces in the system.

Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com>
10 months agolsfd: Gather information on target socket's net namespace
Dmitry Safonov [Mon, 16 Sep 2024 23:18:12 +0000 (00:18 +0100)] 
lsfd: Gather information on target socket's net namespace

A sample of the output before (with SOCK.NETNS):
COMMAND     PID USER  ASSOC  XMODE TYPE SOURCE MNTID      INODE NAME                                                                                SOCK.NETNS
[..]
> tmp_ipv4 114075 root      0 rw----  CHR  pts:7    27         10 /dev/pts/7
> tmp_ipv4 114075 root      1 rw----  CHR  pts:7    27         10 /dev/pts/7
> tmp_ipv4 114075 root      2 rw----  CHR  pts:7    27         10 /dev/pts/7
> tmp_ipv4 114075 root      3 r-----  REG   nsfs     3 4026531840 net:[4026531840]
> tmp_ipv4 114075 root      4 r-----  REG   nsfs     3 4026532537 net:[4026532537]
> tmp_ipv4 114075 root      5 r-----  REG   nsfs     3 4026532864 net:[4026532864]
> tmp_ipv4 114075 root      6 r-----  REG   nsfs     3 4026532537 net:[4026532537]
> tmp_ipv4 114075 root      7 r-----  REG   nsfs     3 4026532947 net:[4026532947]
> tmp_ipv4 114075 root      8 rw----  TCP sockfs    10     100750 state=listen laddr=10.0.254.1:7010                                                  4026532947
> tmp_ipv4 114075 root      9 r-----  REG   nsfs     3 4026533109 net:[4026533109]
> tmp_ipv4 114075 root     10 rw----  TCP sockfs    10     100763 socket:[100763]
> tmp_ipv4 114075 root     11 rw----  TCP sockfs    10     100776 state=listen laddr=10.0.254.1:7012                                                  4026533109
> tmp_ipv4 114075 root     12 r-----  REG   nsfs     3 4026533271 net:[4026533271]
> tmp_ipv4 114075 root     13 rw----  TCP sockfs    10     100789 socket:[100789]
> tmp_ipv4 114075 root     14 rw----  TCP sockfs    10     100802 state=listen laddr=10.0.254.1:7014                                                  4026533271
> tmp_ipv4 114075 root     15 r-----  REG   nsfs     3 4026532537 net:[4026532537]
> tmp_ipv4 114075 root     16 r-----  REG   nsfs     3 4026532783 net:[4026532783]
> tmp_ipv4 114075 root     17 rw----  TCP sockfs    10     100815 state=listen laddr=10.0.254.1:7015                                                  4026532783
> tmp_ipv4 114075 root     18 r-----  REG   nsfs     3 4026533511 net:[4026533511]
> tmp_ipv4 114075 root     19 rw----  TCP sockfs    10     100828 socket:[100828]
> tmp_ipv4 114075 root     20 rw----  TCP sockfs    10     100841 state=listen laddr=10.0.254.1:7017                                                  4026533511
> tmp_ipv4 114075 root     21 r-----  REG   nsfs     3 4026533673 net:[4026533673]
> tmp_ipv4 114075 root     22 rw----  TCP sockfs    10     100854 socket:[100854]
> tmp_ipv4 114075 root     23 rw----  TCP sockfs    10     100867 state=listen laddr=10.0.254.1:7019                                                  4026533673
> tmp_ipv4 114075 root     24 r-----  REG   nsfs     3 4026532537 net:[4026532537]
> tmp_ipv4 114075 root     25 r-----  REG   nsfs     3 4026533754 net:[4026533754]
> tmp_ipv4 114075 root     26 rw----  TCP sockfs    10     100880 state=listen laddr=10.0.254.1:7020                                                  4026533754
> tmp_ipv4 114075 root     27 r-----  REG   nsfs     3 4026532504 net:[4026532504]
> tmp_ipv4 114075 root     28 rw----  TCP sockfs    10     100893 socket:[100893]
> tmp_ipv4 114075 root     29 rw----  TCP sockfs    10     100906 state=listen laddr=10.0.254.1:7022                                                  4026532504
> tmp_ipv4 114075 root     30 r-----  REG   nsfs     3 4026533999 net:[4026533999]
> tmp_ipv4 114075 root     31 rw----  TCP sockfs    10     100919 socket:[100919]
> tmp_ipv4 114075 root     32 rw----  TCP sockfs    10     100932 state=listen laddr=10.0.254.1:7024                                                  4026533999
> tmp_ipv4 114075 root     33 r-----  REG   nsfs     3 4026532537 net:[4026532537]
> tmp_ipv4 114075 root     34 r-----  REG   nsfs     3 4026534080 net:[4026534080]
> tmp_ipv4 114075 root     35 rw----  TCP sockfs    10     100945 state=listen laddr=10.0.254.1:7025                                                  4026534080
> tmp_ipv4 114075 root     36 r-----  REG   nsfs     3 4026534242 net:[4026534242]
> tmp_ipv4 114075 root     37 rw----  TCP sockfs    10     100958 socket:[100958]
> tmp_ipv4 114075 root     38 rw----  TCP sockfs    10     100971 state=listen laddr=10.0.254.1:7027                                                  4026534242
> tmp_ipv4 114075 root     39 r-----  REG   nsfs     3 4026534404 net:[4026534404]
> tmp_ipv4 114075 root     40 rw----  TCP sockfs    10     100984 socket:[100984]
> tmp_ipv4 114075 root     41 rw----  TCP sockfs    10     100997 state=listen laddr=10.0.254.1:7029                                                  4026534404
> tmp_ipv4 114075 root     42 r-----  REG   nsfs     3 4026532537 net:[4026532537]
> tmp_ipv4 114075 root     43 r-----  REG   nsfs     3 4026534484 net:[4026534484]
> tmp_ipv4 114075 root     44 rw----  TCP sockfs    10     101010 state=listen laddr=10.0.254.1:7030                                                  4026534484
> tmp_ipv4 114075 root     45 r-----  REG   nsfs     3 4026534646 net:[4026534646]
> tmp_ipv4 114075 root     46 rw----  TCP sockfs    10     101023 socket:[101023]
> tmp_ipv4 114075 root     47 rw----  TCP sockfs    10     101036 state=listen laddr=10.0.254.1:7032                                                  4026534646
> tmp_ipv4 114075 root     48 r-----  REG   nsfs     3 4026534808 net:[4026534808]
> tmp_ipv4 114075 root     49 rw----  TCP sockfs    10     101049 socket:[101049]
> tmp_ipv4 114075 root     50 rw----  TCP sockfs    10     101062 state=listen laddr=10.0.254.1:7034                                                  4026534808
> tmp_ipv4 114075 root     51 r-----  REG   nsfs     3 4026532537 net:[4026532537]
> tmp_ipv4 114075 root     52 r-----  REG   nsfs     3 4026534889 net:[4026534889]
> tmp_ipv4 114075 root     53 rw----  TCP sockfs    10     101075 state=listen laddr=10.0.254.1:7035                                                  4026534889
> tmp_ipv4 114075 root     54 r-----  REG   nsfs     3 4026535051 net:[4026535051]
> tmp_ipv4 114075 root     55 rw----  TCP sockfs    10     101088 socket:[101088]
> tmp_ipv4 114075 root     56 rw----  TCP sockfs    10     101101 state=listen laddr=10.0.254.1:7037                                                  4026535051
> tmp_ipv4 114075 root     57 r-----  REG   nsfs     3 4026535213 net:[4026535213]
> tmp_ipv4 114075 root     58 rw----  TCP sockfs    10     101114 socket:[101114]
> tmp_ipv4 114075 root     59 rw----  TCP sockfs    10     101127 state=listen laddr=10.0.254.1:7039                                                  4026535213
> tmp_ipv4 114075 root     60 r-----  REG   nsfs     3 4026532537 net:[4026532537]
> tmp_ipv4 114075 root     61 r-----  REG   nsfs     3 4026535294 net:[4026535294]
> tmp_ipv4 114075 root     62 rw----  TCP sockfs    10     101140 state=listen laddr=10.0.254.1:7040                                                  4026535294
[..]

A sample of the output after:
> COMMAND     PID USER  ASSOC  XMODE TYPE SOURCE MNTID      INODE NAME                                                                                SOCK.NETNS
[..]
> tmp_ipv4 114075 root      0 rw----  CHR  pts:7    27         10 /dev/pts/7
> tmp_ipv4 114075 root      1 rw----  CHR  pts:7    27         10 /dev/pts/7
> tmp_ipv4 114075 root      2 rw----  CHR  pts:7    27         10 /dev/pts/7
> tmp_ipv4 114075 root      3 r-----  REG   nsfs     3 4026531840 net:[4026531840]
> tmp_ipv4 114075 root      4 r-----  REG   nsfs     3 4026532537 net:[4026532537]
> tmp_ipv4 114075 root      5 r-----  REG   nsfs     3 4026532864 net:[4026532864]
> tmp_ipv4 114075 root      6 r-----  REG   nsfs     3 4026532537 net:[4026532537]
> tmp_ipv4 114075 root      7 r-----  REG   nsfs     3 4026532947 net:[4026532947]
> tmp_ipv4 114075 root      8 rw----  TCP sockfs    10     100750 state=listen laddr=10.0.254.1:7010                                                  4026532947
> tmp_ipv4 114075 root      9 r-----  REG   nsfs     3 4026533109 net:[4026533109]
> tmp_ipv4 114075 root     10 rw----  TCP sockfs    10     100763 state=listen laddr=10.0.254.1:7011                                                  4026533028
> tmp_ipv4 114075 root     11 rw----  TCP sockfs    10     100776 state=listen laddr=10.0.254.1:7012                                                  4026533109
> tmp_ipv4 114075 root     12 r-----  REG   nsfs     3 4026533271 net:[4026533271]
> tmp_ipv4 114075 root     13 rw----  TCP sockfs    10     100789 state=listen laddr=10.0.254.1:7013                                                  4026533190
> tmp_ipv4 114075 root     14 rw----  TCP sockfs    10     100802 state=listen laddr=10.0.254.1:7014                                                  4026533271
> tmp_ipv4 114075 root     15 r-----  REG   nsfs     3 4026532537 net:[4026532537]
> tmp_ipv4 114075 root     16 r-----  REG   nsfs     3 4026532783 net:[4026532783]
> tmp_ipv4 114075 root     17 rw----  TCP sockfs    10     100815 state=listen laddr=10.0.254.1:7015                                                  4026532783
> tmp_ipv4 114075 root     18 r-----  REG   nsfs     3 4026533511 net:[4026533511]
> tmp_ipv4 114075 root     19 rw----  TCP sockfs    10     100828 state=listen laddr=10.0.254.1:7016                                                  4026533430
> tmp_ipv4 114075 root     20 rw----  TCP sockfs    10     100841 state=listen laddr=10.0.254.1:7017                                                  4026533511
> tmp_ipv4 114075 root     21 r-----  REG   nsfs     3 4026533673 net:[4026533673]
> tmp_ipv4 114075 root     22 rw----  TCP sockfs    10     100854 state=listen laddr=10.0.254.1:7018                                                  4026533592
> tmp_ipv4 114075 root     23 rw----  TCP sockfs    10     100867 state=listen laddr=10.0.254.1:7019                                                  4026533673
> tmp_ipv4 114075 root     24 r-----  REG   nsfs     3 4026532537 net:[4026532537]
> tmp_ipv4 114075 root     25 r-----  REG   nsfs     3 4026533754 net:[4026533754]
> tmp_ipv4 114075 root     26 rw----  TCP sockfs    10     100880 state=listen laddr=10.0.254.1:7020                                                  4026533754
> tmp_ipv4 114075 root     27 r-----  REG   nsfs     3 4026532504 net:[4026532504]
> tmp_ipv4 114075 root     28 rw----  TCP sockfs    10     100893 state=listen laddr=10.0.254.1:7021                                                  4026533835
> tmp_ipv4 114075 root     29 rw----  TCP sockfs    10     100906 state=listen laddr=10.0.254.1:7022                                                  4026532504
> tmp_ipv4 114075 root     30 r-----  REG   nsfs     3 4026533999 net:[4026533999]
> tmp_ipv4 114075 root     31 rw----  TCP sockfs    10     100919 state=listen laddr=10.0.254.1:7023                                                  4026533918
> tmp_ipv4 114075 root     32 rw----  TCP sockfs    10     100932 state=listen laddr=10.0.254.1:7024                                                  4026533999
> tmp_ipv4 114075 root     33 r-----  REG   nsfs     3 4026532537 net:[4026532537]
> tmp_ipv4 114075 root     34 r-----  REG   nsfs     3 4026534080 net:[4026534080]
> tmp_ipv4 114075 root     35 rw----  TCP sockfs    10     100945 state=listen laddr=10.0.254.1:7025                                                  4026534080
> tmp_ipv4 114075 root     36 r-----  REG   nsfs     3 4026534242 net:[4026534242]
> tmp_ipv4 114075 root     37 rw----  TCP sockfs    10     100958 state=listen laddr=10.0.254.1:7026                                                  4026534161
> tmp_ipv4 114075 root     38 rw----  TCP sockfs    10     100971 state=listen laddr=10.0.254.1:7027                                                  4026534242
> tmp_ipv4 114075 root     39 r-----  REG   nsfs     3 4026534404 net:[4026534404]
> tmp_ipv4 114075 root     40 rw----  TCP sockfs    10     100984 state=listen laddr=10.0.254.1:7028                                                  4026534323
> tmp_ipv4 114075 root     41 rw----  TCP sockfs    10     100997 state=listen laddr=10.0.254.1:7029                                                  4026534404
> tmp_ipv4 114075 root     42 r-----  REG   nsfs     3 4026532537 net:[4026532537]
> tmp_ipv4 114075 root     43 r-----  REG   nsfs     3 4026534484 net:[4026534484]
> tmp_ipv4 114075 root     44 rw----  TCP sockfs    10     101010 state=listen laddr=10.0.254.1:7030                                                  4026534484
> tmp_ipv4 114075 root     45 r-----  REG   nsfs     3 4026534646 net:[4026534646]
> tmp_ipv4 114075 root     46 rw----  TCP sockfs    10     101023 state=listen laddr=10.0.254.1:7031                                                  4026534565
> tmp_ipv4 114075 root     47 rw----  TCP sockfs    10     101036 state=listen laddr=10.0.254.1:7032                                                  4026534646
> tmp_ipv4 114075 root     48 r-----  REG   nsfs     3 4026534808 net:[4026534808]
> tmp_ipv4 114075 root     49 rw----  TCP sockfs    10     101049 state=listen laddr=10.0.254.1:7033                                                  4026534727
> tmp_ipv4 114075 root     50 rw----  TCP sockfs    10     101062 state=listen laddr=10.0.254.1:7034                                                  4026534808
> tmp_ipv4 114075 root     51 r-----  REG   nsfs     3 4026532537 net:[4026532537]
> tmp_ipv4 114075 root     52 r-----  REG   nsfs     3 4026534889 net:[4026534889]
> tmp_ipv4 114075 root     53 rw----  TCP sockfs    10     101075 state=listen laddr=10.0.254.1:7035                                                  4026534889
> tmp_ipv4 114075 root     54 r-----  REG   nsfs     3 4026535051 net:[4026535051]
> tmp_ipv4 114075 root     55 rw----  TCP sockfs    10     101088 state=listen laddr=10.0.254.1:7036                                                  4026534970
> tmp_ipv4 114075 root     56 rw----  TCP sockfs    10     101101 state=listen laddr=10.0.254.1:7037                                                  4026535051
> tmp_ipv4 114075 root     57 r-----  REG   nsfs     3 4026535213 net:[4026535213]
> tmp_ipv4 114075 root     58 rw----  TCP sockfs    10     101114 state=listen laddr=10.0.254.1:7038                                                  4026535132
> tmp_ipv4 114075 root     59 rw----  TCP sockfs    10     101127 state=listen laddr=10.0.254.1:7039                                                  4026535213
> tmp_ipv4 114075 root     60 r-----  REG   nsfs     3 4026532537 net:[4026532537]
> tmp_ipv4 114075 root     61 r-----  REG   nsfs     3 4026535294 net:[4026535294]
> tmp_ipv4 114075 root     62 rw----  TCP sockfs    10     101140 state=listen laddr=10.0.254.1:7040                                                  4026535294
[..]

Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com>