]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
18 hours agoMerge branch 'PR/lsfd-mkfds-enosys' of https://github.com/karelzak/util-linux-work master
Karel Zak [Tue, 16 Jun 2026 12:36:22 +0000 (14:36 +0200)] 
Merge branch 'PR/lsfd-mkfds-enosys' of https://github.com/karelzak/util-linux-work

* 'PR/lsfd-mkfds-enosys' of https://github.com/karelzak/util-linux-work:
  tests: handle ENOSYS in multiplexing syscall tests

21 hours agolibmount: add mount ID verification and man page TOCTOU note
Karel Zak [Wed, 27 May 2026 10:38:16 +0000 (12:38 +0200)] 
libmount: add mount ID verification and man page TOCTOU note

Verify mount ID after re-opening the target fd to ensure the mount
landed on the expected target.  The expected ID is set from fd_tree
in hook_create_mount() (new mount API only).

Add WARNING to mount.8 about the inherent TOCTOU limitation of the
legacy mount(2) syscall for non-superuser mounts.

Signed-off-by: Karel Zak <kzak@redhat.com>
21 hours agolibmount: use fd_target in hook_idmap for move_mount()
Karel Zak [Wed, 27 May 2026 10:21:02 +0000 (12:21 +0200)] 
libmount: use fd_target in hook_idmap for move_mount()

Use the pinned fd_target with MOVE_MOUNT_T_EMPTY_PATH for restricted
users instead of string-based move_mount().  Re-open the target fd
after mount to point to the mounted filesystem root.

Signed-off-by: Karel Zak <kzak@redhat.com>
21 hours agolibmount: restrict X-mount.subdir for non-root to Linux >= 6.15
Karel Zak [Wed, 27 May 2026 10:20:06 +0000 (12:20 +0200)] 
libmount: restrict X-mount.subdir for non-root to Linux >= 6.15

The old-kernel subdir path uses namespace unsharing and string-based
move_mount() which is unsafe for restricted users (TOCTOU).  The safe
detached subdir open requires Linux >= 6.15.

Signed-off-by: Karel Zak <kzak@redhat.com>
21 hours agolibmount: use fd-based fchownat/chmod in hook_owner
Karel Zak [Tue, 16 Jun 2026 09:15:19 +0000 (11:15 +0200)] 
libmount: use fd-based fchownat/chmod in hook_owner

Replace path-based lchown()/chmod() with fd-based operations in the
X-mount.{owner,group,mode} post-mount hook.

For restricted users the fd_target is pinned in prepare_target() and
re-opened after mount in hook_attach_target() to point to the mounted
filesystem root.  For root a local O_PATH fd is opened.  Ownership is
changed via fchownat(fd, "", ..., AT_EMPTY_PATH), mode via
/proc/self/fd/N.

This prevents TOCTOU attacks where an ancestor directory is swapped
between mount and the chmod/chown operations.

CVE-2026-53612

Reported-by: Xinyao Hu <ctf_0x01@foxmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
21 hours agolibmount: ignore X-mount.nocanonicalize for restricted users
Karel Zak [Wed, 27 May 2026 09:12:17 +0000 (11:12 +0200)] 
libmount: ignore X-mount.nocanonicalize for restricted users

Paths must always be canonicalized in restricted (non-root) mode to
ensure safe target resolution before fd pinning.

Signed-off-by: Karel Zak <kzak@redhat.com>
21 hours agolibmount: add fd_target to context for TOCTOU prevention
Karel Zak [Tue, 16 Jun 2026 09:13:54 +0000 (11:13 +0200)] 
libmount: add fd_target to context for TOCTOU prevention

Add a pinned O_PATH target fd to libmnt_context with lazy-open getter
mnt_context_get_target_fd() and mnt_context_close_target_fd().

The fd is opened via ul_open_no_symlinks() (RESOLVE_NO_SYMLINKS) to
reject symlinks at any path component.  The fd is closed on context
reset.

CVE-2026-53613

Signed-off-by: Karel Zak <kzak@redhat.com>
22 hours agolibmount: fix SUID bypass via LIBMOUNT_FORCE_MOUNT2 and legacy mount path
Karel Zak [Tue, 16 Jun 2026 08:58:32 +0000 (10:58 +0200)] 
libmount: fix SUID bypass via LIBMOUNT_FORCE_MOUNT2 and legacy mount path

Use safe_getenv() for LIBMOUNT_FORCE_MOUNT2 to ignore the variable
in SUID context, consistent with LIBMOUNT_FSTAB and other sensitive
environment variables.

Additionally, refuse multi-step mount(2) sequences (bind+remount and
propagation) for restricted (non-root) users in the legacy mount path.
The two-step approach has a window between syscalls where security
flags (nosuid, noexec, ...) are not yet applied.  The new mount API
handles this atomically.

CVE-2026-53614

Reported-by: Xinyao Hu <ctf_0x01@foxmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
22 hours agolibblkid: fix use-after-free in nested partition probing
Karel Zak [Thu, 7 May 2026 10:50:48 +0000 (12:50 +0200)] 
libblkid: fix use-after-free in nested partition probing

The partitions list stores partitions in a contiguous array grown by
reallocarray(). When the array is reallocated to a new address, all
existing blkid_partition pointers (tab->parent, ls->next_parent, local
parent variables in nested probers) become dangling.

Fix this by changing the storage from an array of structs to an array
of pointers, where each partition is individually allocated via
calloc(). This makes all blkid_partition pointers stable across
reallocations -- only the pointer array itself may move, which is
harmless since no code caches pointers into the pointer array.

This eliminates the need for callers to re-fetch parent pointers after
every blkid_partlist_add_partition() call.

Reported-by: Thai Duong <thaidn@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
22 hours agoMerge branch 'unshare-comment-fix' of https://github.com/crbednarz/util-linux
Karel Zak [Tue, 16 Jun 2026 08:49:23 +0000 (10:49 +0200)] 
Merge branch 'unshare-comment-fix' of https://github.com/crbednarz/util-linux

* 'unshare-comment-fix' of https://github.com/crbednarz/util-linux:
  Remove documentation for removed args on unshare.c's map_ids_from_child

22 hours agoMerge branch 'PR/asciidoctor-utf8-encoding' of https://github.com/karelzak/util-linux...
Karel Zak [Tue, 16 Jun 2026 08:46:06 +0000 (10:46 +0200)] 
Merge branch 'PR/asciidoctor-utf8-encoding' of https://github.com/karelzak/util-linux-work

* 'PR/asciidoctor-utf8-encoding' of https://github.com/karelzak/util-linux-work:
  asciidoctor: fix encoding error for non-ASCII translations

22 hours agoMerge branch 'PR/mkswap-fstat' of https://github.com/karelzak/util-linux-work
Karel Zak [Tue, 16 Jun 2026 08:45:19 +0000 (10:45 +0200)] 
Merge branch 'PR/mkswap-fstat' of https://github.com/karelzak/util-linux-work

* 'PR/mkswap-fstat' of https://github.com/karelzak/util-linux-work:
  mkswap: use fd-based operations to avoid TOCTOU in open_device()

22 hours agoMerge branch 'PR/libmount-fanotify-overflow' of https://github.com/karelzak/util...
Karel Zak [Tue, 16 Jun 2026 08:41:25 +0000 (10:41 +0200)] 
Merge branch 'PR/libmount-fanotify-overflow' of https://github.com/karelzak/util-linux-work

* 'PR/libmount-fanotify-overflow' of https://github.com/karelzak/util-linux-work:
  libmount: detect fanotify queue overflow in monitor

22 hours agoMerge branch 'PR/setpriv-examples' of https://github.com/karelzak/util-linux-work
Karel Zak [Tue, 16 Jun 2026 08:34:36 +0000 (10:34 +0200)] 
Merge branch 'PR/setpriv-examples' of https://github.com/karelzak/util-linux-work

* 'PR/setpriv-examples' of https://github.com/karelzak/util-linux-work:
  docs: setpriv: improve EXAMPLES section

23 hours agotests: handle ENOSYS in multiplexing syscall tests
Karel Zak [Tue, 16 Jun 2026 07:24:40 +0000 (09:24 +0200)] 
tests: handle ENOSYS in multiplexing syscall tests

On ppc64le, __NR_select is defined at compile time, so test_mkfds -W
lists "select" as available. However, the kernel returns ENOSYS at
runtime. The helper process prints its PID, then calls select() which
fails immediately with ENOSYS. This creates a race where the bash
script's kill -0 liveness check can succeed while the process is
still dying, causing lsfd to run against a dead process and produce
wrong output.

Exit with EXIT_ENOSYS (23) instead of EXIT_FAILURE when the
multiplexer syscall returns ENOSYS. This applies to both
DEFUN_WAIT_EVENT_SELECT and DEFUN_WAIT_EVENT_POLL macros.

In the bash test, check the wait exit code for 23 after the coproc
finishes and skip the subtest cleanly.

Signed-off-by: Karel Zak <kzak@redhat.com>
35 hours agoRemove documentation for removed args on unshare.c's map_ids_from_child
crbednarz [Mon, 15 Jun 2026 19:54:22 +0000 (12:54 -0700)] 
Remove documentation for removed args on unshare.c's map_ids_from_child

43 hours agolibmount: detect fanotify queue overflow in monitor
Karel Zak [Mon, 15 Jun 2026 11:15:01 +0000 (13:15 +0200)] 
libmount: detect fanotify queue overflow in monitor

When the fanotify event queue overflows under sustained mount churn,
the kernel sends a FAN_Q_OVERFLOW event. The fanotify_next_fs() function
did not check for this, causing it to access invalid memory (the
overflow event carries no fanotify_event_info_mnt payload) and silently
drop the overflow notification. The consumer never learned that events
were lost, so its mount-unit view could permanently diverge from the
kernel.

Detect FAN_Q_OVERFLOW, discard the remaining buffered events (they are
unreliable after an overflow), and return -EOVERFLOW so the caller can
perform a full rescan.

Signed-off-by: Karel Zak <kzak@redhat.com>
44 hours agoMerge branch 'lslogins-lastlog2-overflow' of https://github.com/aizu-m/util-linux
Karel Zak [Mon, 15 Jun 2026 10:49:49 +0000 (12:49 +0200)] 
Merge branch 'lslogins-lastlog2-overflow' of https://github.com/aizu-m/util-linux

* 'lslogins-lastlog2-overflow' of https://github.com/aizu-m/util-linux:
  lslogins: bound lastlog2 tty/host copy to destination size

44 hours agolscpu: remove unnecessary braces around single-line if body
Karel Zak [Mon, 15 Jun 2026 10:35:29 +0000 (12:35 +0200)] 
lscpu: remove unnecessary braces around single-line if body

Signed-off-by: Karel Zak <kzak@redhat.com>
44 hours agoMerge branch 'master' of https://github.com/ZephyrLi-pro/util-linux-c
Karel Zak [Mon, 15 Jun 2026 10:35:01 +0000 (12:35 +0200)] 
Merge branch 'master' of https://github.com/ZephyrLi-pro/util-linux-c

* 'master' of https://github.com/ZephyrLi-pro/util-linux-c:
  lscpu: add RISC-V MMU column support
  lscpu: show RISC-V MMU mode
  lscpu: free cputype ISA string

44 hours agoMerge branch 'pr/vriabchun/Fix-incorrect-fd-check' of https://github.com/Frankenween...
Karel Zak [Mon, 15 Jun 2026 10:27:44 +0000 (12:27 +0200)] 
Merge branch 'pr/vriabchun/Fix-incorrect-fd-check' of https://github.com/Frankenween/util-linux

* 'pr/vriabchun/Fix-incorrect-fd-check' of https://github.com/Frankenween/util-linux:
  nsenter: Fix invalid fd check in enter_namespaces

44 hours agoMerge branch 'docs-cleanup' of https://github.com/Broken-Diamond/util-linux
Karel Zak [Mon, 15 Jun 2026 10:23:34 +0000 (12:23 +0200)] 
Merge branch 'docs-cleanup' of https://github.com/Broken-Diamond/util-linux

* 'docs-cleanup' of https://github.com/Broken-Diamond/util-linux:
  docs: Refine grammar and clarity in howto-pull-request.txt

45 hours agodocs: setpriv: improve EXAMPLES section
Karel Zak [Mon, 15 Jun 2026 09:54:11 +0000 (11:54 +0200)] 
docs: setpriv: improve EXAMPLES section

Clarify that setpriv is not a 1:1 replacement for su/runuser/sudo,
add --inh-caps=-all to the basic example, and provide additional
examples for environment reset and restrictive privilege dropping.

Fixes: https://github.com/util-linux/util-linux/issues/4402
Signed-off-by: Karel Zak <kzak@redhat.com>
45 hours agomkswap: use fd-based operations to avoid TOCTOU in open_device()
Karel Zak [Mon, 15 Jun 2026 09:36:10 +0000 (11:36 +0200)] 
mkswap: use fd-based operations to avoid TOCTOU in open_device()

Replace path-based stat()+chmod() with open() first, then fstat()
and fchmod() on the file descriptor. This eliminates the race window
between checking and modifying the file.

Also skip fchmod() when permissions are already 0600.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 days agolslogins: bound lastlog2 tty/host copy to destination size
aizu-m [Sun, 14 Jun 2026 07:43:26 +0000 (13:13 +0530)] 
lslogins: bound lastlog2 tty/host copy to destination size

get_lastlog2() copies the TTY and host strings read from the lastlog2
database into heap buffers of sizeof(ut_line)+1 and sizeof(ut_host)+1
bytes, but passed strlen(value)+1 as the mem2strcpy() limit. mem2strcpy()
zero-fills and copies that many bytes regardless of the destination, so a
database value longer than the field overflows the buffer. Cap the limit
to the destination field size, matching the wtmp and plain-lastlog paths
in the same function.

Signed-off-by: aizu-m <aizumusheer2@gmail.com>
5 days agolscpu: add RISC-V MMU column support
Zephyr Li [Fri, 12 Jun 2026 01:36:17 +0000 (09:36 +0800)] 
lscpu: add RISC-V MMU column support

Signed-off-by: Zephyr Li <fritchleybohrer@gmail.com>
5 days agolscpu: show RISC-V MMU mode
Zephyr Li [Thu, 11 Jun 2026 12:58:34 +0000 (20:58 +0800)] 
lscpu: show RISC-V MMU mode

Signed-off-by: Zephyr Li <fritchleybohrer@gmail.com>
5 days agolscpu: free cputype ISA string
Zephyr Li [Thu, 11 Jun 2026 12:48:46 +0000 (20:48 +0800)] 
lscpu: free cputype ISA string

Signed-off-by: Zephyr Li <fritchleybohrer@gmail.com>
6 days agodocs: Refine grammar and clarity in howto-pull-request.txt
Broken-Diamond [Wed, 10 Jun 2026 23:02:18 +0000 (17:02 -0600)] 
docs: Refine grammar and clarity in howto-pull-request.txt

Correct grammar and enhance clarity throughout the pull request instructions, ensuring consistency in language and formatting.

Signed-off-by: Mac Musser <mussemac652@gmail.com>
6 days agonsenter: Fix invalid fd check in enter_namespaces
Vladimir Riabchun [Wed, 10 Jun 2026 13:28:48 +0000 (15:28 +0200)] 
nsenter: Fix invalid fd check in enter_namespaces

When nsenter is executed with closed stdin, one pid_fd will be 0,
which is a valid file descriptor. But with current code namespace switch
is skipped, leading to incorrect results.

Fixes: f18be0ca5aa7 ("nsenter: use pidfd to enter target namespaces")
Signed-off-by: Vladimir Riabchun <vladimir.riabchun@virtuozzo.com>
6 days agofsck.minix: bound namelen guessed in get_dirsize
aizu-m [Wed, 10 Jun 2026 12:44:30 +0000 (18:14 +0530)] 
fsck.minix: bound namelen guessed in get_dirsize

get_dirsize() guesses the directory name length from the on-disk root
directory: it doubles a candidate size from 16 up to 512 looking for the
".." entry and sets namelen = size - 2. A crafted image whose first ".."
match lands at offset 514 yields namelen 510, well past MINIX_NAME_MAX
(255). check_file() then does xstrncpy(name_list[name_depth], name,
namelen) into rows of only MINIX_NAME_MAX + 1 bytes, writing out of
bounds past name_list.

Stop the scan once size - 2 would exceed MINIX_NAME_MAX so the guessed
namelen stays within the buffers, falling back to the magic-derived
default.

Signed-off-by: aizu-m <aizumusheer2@gmail.com>
6 days agoasciidoctor: fix encoding error for non-ASCII translations
Karel Zak [Wed, 10 Jun 2026 11:06:26 +0000 (13:06 +0200)] 
asciidoctor: fix encoding error for non-ASCII translations

File.read without an explicit encoding uses Ruby's default external
encoding, which depends on the system locale. On systems where it
resolves to US-ASCII (e.g. some Debian configurations), reading
translated man page files with non-ASCII content (such as Arabic)
fails with "source is either binary or contains invalid Unicode data".

Specify encoding: 'UTF-8' explicitly so the string is correctly
tagged regardless of locale.

Fixes: https://github.com/util-linux/util-linux/issues/4409
Signed-off-by: Karel Zak <kzak@redhat.com>
6 days agodocs: unshare: split --map-users/--map-groups into readable paragraphs
Karel Zak [Wed, 10 Jun 2026 09:09:03 +0000 (11:09 +0200)] 
docs: unshare: split --map-users/--map-groups into readable paragraphs

No text changes, only line breaks to improve readability.

Addresses: https://github.com/util-linux/util-linux/issues/3838
Signed-off-by: Karel Zak <kzak@redhat.com>
6 days agoMerge branch 'docs/3838-unshare-map-overlap' of https://github.com/mvanhorn/util...
Karel Zak [Wed, 10 Jun 2026 08:57:41 +0000 (10:57 +0200)] 
Merge branch 'docs/3838-unshare-map-overlap' of https://github.com/mvanhorn/util-linux

* 'docs/3838-unshare-map-overlap' of https://github.com/mvanhorn/util-linux:
  docs: clarify unshare --map-users/--map-groups overlap behavior (#3838)

6 days agofdisk: (resize) avoid redundant error on partnum failure
Karel Zak [Wed, 10 Jun 2026 08:52:44 +0000 (10:52 +0200)] 
fdisk: (resize) avoid redundant error on partnum failure

fdisk_ask_partnum() already prints its own diagnostics on failure,
so go directly to 'out' instead of 'err' which would print a
redundant "Could not resize partition" message with a meaningless
partition number.

Also removes the need for the i=0 initialization from the previous
commit, since 'i' is no longer used on the fdisk_ask_partnum()
error path.

Addresses: https://github.com/util-linux/util-linux/pull/4394
Signed-off-by: Karel Zak <kzak@redhat.com>
6 days agoMerge branch 'master-branch-5' of https://github.com/Leefancy/util-linux
Karel Zak [Wed, 10 Jun 2026 08:52:02 +0000 (10:52 +0200)] 
Merge branch 'master-branch-5' of https://github.com/Leefancy/util-linux

* 'master-branch-5' of https://github.com/Leefancy/util-linux:
  fix(resize_partition): initialize index to avoid undefined behavior

# Conflicts:
# disk-utils/fdisk.c

6 days agoMerge branch 'bsd-npartitions-clamp' of https://github.com/aizu-m/util-linux
Karel Zak [Wed, 10 Jun 2026 08:44:19 +0000 (10:44 +0200)] 
Merge branch 'bsd-npartitions-clamp' of https://github.com/aizu-m/util-linux

* 'bsd-npartitions-clamp' of https://github.com/aizu-m/util-linux:
  libfdisk: clamp out-of-range d_npartitions in bsd_readlabel

6 days agoMerge branch 'fix/setsid-bash-completion' of https://github.com/lzwind/util-linux
Karel Zak [Wed, 10 Jun 2026 08:42:51 +0000 (10:42 +0200)] 
Merge branch 'fix/setsid-bash-completion' of https://github.com/lzwind/util-linux

* 'fix/setsid-bash-completion' of https://github.com/lzwind/util-linux:
  bash-completion: fix setsid sub-command completion

6 days agoMerge branch 'PR/lsblk-tests-fix' of https://github.com/karelzak/util-linux-work
Karel Zak [Wed, 10 Jun 2026 07:48:50 +0000 (09:48 +0200)] 
Merge branch 'PR/lsblk-tests-fix' of https://github.com/karelzak/util-linux-work

* 'PR/lsblk-tests-fix' of https://github.com/karelzak/util-linux-work:
  tests: remove loop devices from lsblk bcachefs dump

6 days agoMerge branch 'PR/libmount-more-restrict' of https://github.com/karelzak/util-linux...
Karel Zak [Wed, 10 Jun 2026 07:47:21 +0000 (09:47 +0200)] 
Merge branch 'PR/libmount-more-restrict' of https://github.com/karelzak/util-linux-work

* 'PR/libmount-more-restrict' of https://github.com/karelzak/util-linux-work:
  build: warn when libmount udev support is disabled
  libmount: disable libblkid probing for non-root users
  libblkid: add blkid_evaluate_tag2() with flags
  umount: restrict non-root users to mountpoint paths only

6 days agoMerge branch 'PR/lsfd-multiplexing-fix' of https://github.com/karelzak/util-linux...
Karel Zak [Wed, 10 Jun 2026 07:43:10 +0000 (09:43 +0200)] 
Merge branch 'PR/lsfd-multiplexing-fix' of https://github.com/karelzak/util-linux-work

* 'PR/lsfd-multiplexing-fix' of https://github.com/karelzak/util-linux-work:
  tests: fix lsfd/mkfds-multiplexing coproc PID handling

7 days agolibfdisk: clamp out-of-range d_npartitions in bsd_readlabel
aizu-m [Tue, 9 Jun 2026 19:24:04 +0000 (00:54 +0530)] 
libfdisk: clamp out-of-range d_npartitions in bsd_readlabel

d_npartitions is a uint16 partition count read straight from an on-disk
BSD disklabel. bsd_readlabel() warns when it is larger than
BSD_MAXPARTITIONS but leaves the value untouched, so the bogus count
survives into the rest of the label handling.

bsd_dkcksum() walks the label up to &lp->d_partitions[d_npartitions]
when the label is written back. d_partitions[] holds 16 entries
(256 bytes); a crafted disklabel can set the count to 65535 and push
that end pointer about 1 MB past the array, an out-of-bounds read.

Clamp the count to BSD_MAXPARTITIONS in the block that already emits the
warning, the same upper bound sun/sgi/gpt enforce on their arrays.

Signed-off-by: aizu-m <aizumusheer2@gmail.com>
7 days agoMerge branch 'libmount-subvolid-overflow' of https://github.com/aizu-m/util-linux
Karel Zak [Tue, 9 Jun 2026 13:09:05 +0000 (15:09 +0200)] 
Merge branch 'libmount-subvolid-overflow' of https://github.com/aizu-m/util-linux

* 'libmount-subvolid-overflow' of https://github.com/aizu-m/util-linux:
  libmount: fix subvolid buffer overflow in get_btrfs_fs_root

7 days agotests: remove loop devices from lsblk bcachefs dump
Karel Zak [Tue, 9 Jun 2026 13:03:04 +0000 (15:03 +0200)] 
tests: remove loop devices from lsblk bcachefs dump

The loop device infrastructure does not support sysfs dump-based data.
When lsblk runs with --sysroot, the ignore_empty() function calls
loopdev_has_backing_file() which operates on the real /dev/loopN
device rather than the sysroot data. This causes host-dependent test
results -- if the CI machine has a loop device with a backing file,
the device appears in the output despite having size 0 in the dump.

Remove loop0 and loop1 entries from the multi-devs-bcachefs sysfs
dump to avoid this false positive.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 days agobash-completion: fix setsid sub-command completion
Liu Zheng [Tue, 9 Jun 2026 11:09:16 +0000 (19:09 +0800)] 
bash-completion: fix setsid sub-command completion

The setsid completion used the old manual COMP_WORDS/COMP_CWORD pattern
and never delegated to the sub-command's own completion. When typing e.g.
"setsid -f rm -<Tab>", completion would show setsid options instead of rm
options.

Rewrite to use _init_completion and _command_offset, matching the pattern
used by unshare and other wrapper commands. This correctly detects where
the sub-command begins and delegates completion to it.

The sub-command detection loop explicitly enumerates known options via
NOARGOPTS/NOARGOPTS_SHORT (pipe-separated for regex matching), ensuring that
short options like -f, -c, -w are properly skipped rather than being treated
as the sub-command start.

Fixes: #4073
Signed-off-by: Liu Zheng <liuzheng@uniontech.com>
7 days agodocs: clarify unshare --map-users/--map-groups overlap behavior (#3838)
mvanhorn [Tue, 9 Jun 2026 10:03:29 +0000 (03:03 -0700)] 
docs: clarify unshare --map-users/--map-groups overlap behavior (#3838)

Signed-off-by: Matthew Van Horn <mvanhorn@gmail.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
7 days agoMerge branch 'fix/issue-4336-lsblk-id-link-width' of https://github.com/wyu71/util...
Karel Zak [Tue, 9 Jun 2026 08:49:31 +0000 (10:49 +0200)] 
Merge branch 'fix/issue-4336-lsblk-id-link-width' of https://github.com/wyu71/util-linux

* 'fix/issue-4336-lsblk-id-link-width' of https://github.com/wyu71/util-linux:
  lsblk: truncate long ID-LINK columns

7 days agobuild: warn when libmount udev support is disabled
Karel Zak [Tue, 2 Jun 2026 10:30:21 +0000 (12:30 +0200)] 
build: warn when libmount udev support is disabled

Non-root tag resolution (LABEL=, UUID=) in mount/umount depends on
udev support in libmount. Without it, suid mount/umount cannot
resolve tags for unprivileged users since direct device probing
is disabled for security reasons.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 days agolibmount: disable libblkid probing for non-root users
Karel Zak [Tue, 2 Jun 2026 10:27:15 +0000 (12:27 +0200)] 
libmount: disable libblkid probing for non-root users

Add noprobe flag to struct libmnt_cache that disables low-level
device probing via libblkid. When the mount context is restricted
(non-root user), the flag is set automatically on cache creation
and on externally provided caches.

With noprobe enabled:
 - read_from_blkid() is skipped (device I/O blocked)
 - mnt_resolve_tag() uses blkid_evaluate_tag2() with
   BLKID_EVALUATE_NOPROBE, so tags are resolved only via
   udev /dev/disk/by-* symlinks without device scanning

This minimizes the libblkid attack surface for suid mount/umount
binaries.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 days agolibblkid: add blkid_evaluate_tag2() with flags
Karel Zak [Tue, 2 Jun 2026 10:25:27 +0000 (12:25 +0200)] 
libblkid: add blkid_evaluate_tag2() with flags

Add blkid_evaluate_tag2() that accepts flags to control tag
evaluation behavior. The BLKID_EVALUATE_NOPROBE flag disables
low-level device scanning (evaluate_by_scan), while keeping
udev symlink-based evaluation (evaluate_by_udev) functional.

The original blkid_evaluate_tag() is now a thin wrapper around
the new function with flags=0.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 days agoumount: restrict non-root users to mountpoint paths only
Karel Zak [Mon, 1 Jun 2026 13:22:53 +0000 (15:22 +0200)] 
umount: restrict non-root users to mountpoint paths only

Non-root users should only specify mountpoints when calling umount.
Device names, tags (LABEL=, UUID=, etc.) and loop device resolution
are disabled for unprivileged users to avoid processing untrusted
input through tag resolution code paths before permission checks.

In umount.c, reject tag arguments and disable swapmatch for
restricted users. In libmount, skip source and loopdev swapmatch
lookups for restricted contexts as defense in depth.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 days agolibmount: fix subvolid buffer overflow in get_btrfs_fs_root
aizu-m [Tue, 9 Jun 2026 07:02:50 +0000 (12:32 +0530)] 
libmount: fix subvolid buffer overflow in get_btrfs_fs_root

8 days agotests: fix lsfd/mkfds-multiplexing coproc PID handling
Karel Zak [Mon, 8 Jun 2026 12:30:51 +0000 (14:30 +0200)] 
tests: fix lsfd/mkfds-multiplexing coproc PID handling

Bash automatically unsets the MKFDS_PID variable when the coproc
terminates. If the multiplexer syscall is not available at runtime
(e.g., select on ppc64le with kernel 6.18 returns ENOSYS despite
__NR_select being defined at compile time), the coproc exits
immediately and MKFDS_PID becomes empty, causing:

  wait: '': not a pid or valid job spec

Save MKFDS_PID to a regular variable (MKFDS_CPID) immediately after
starting the coproc.

Additionally, add a kill -0 liveness check after reading the PID to
detect when the multiplexer process died early (e.g., due to ENOSYS)
and skip the subtest cleanly.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 days agoMerge branch 'column_tests' of https://github.com/cgoesche/util-linux-fork
Karel Zak [Mon, 8 Jun 2026 12:19:34 +0000 (14:19 +0200)] 
Merge branch 'column_tests' of https://github.com/cgoesche/util-linux-fork

* 'column_tests' of https://github.com/cgoesche/util-linux-fork:
  column: remove remaining bitfield in struct member
  tests: (column) improve tests

8 days agoMerge branch 'chcpu_tests' of https://github.com/cgoesche/util-linux-fork
Karel Zak [Mon, 8 Jun 2026 12:10:04 +0000 (14:10 +0200)] 
Merge branch 'chcpu_tests' of https://github.com/cgoesche/util-linux-fork

* 'chcpu_tests' of https://github.com/cgoesche/util-linux-fork:
  tests: (chcpu) add missing tests
  chcpu: add a helper function to read the CPU 'online' bitmap
  chcpu: add --sysroot option

8 days agoman pages: avoid troff warning about undefined 'Aq' string
Karel Zak [Mon, 8 Jun 2026 11:41:26 +0000 (13:41 +0200)] 
man pages: avoid troff warning about undefined 'Aq' string

Asciidoctor's manpage backend places the .TH line (which references
\*(Aq for the apostrophe in "Programmer's Manual") before the .ds Aq
definition. This causes troff warning:

  name 'Aq' not defined [-w mac]

Replace "Programmer's Manual" with "Library Calls" to avoid the
apostrophe. This also aligns with man(7) convention for section 3
and is consistent with how other sections already avoid possessives
(e.g. "User Commands", "System Administration").

Reported-by: Bjarni Ingi Gislason <bjarniig@simnet.is>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 days agolastlog2: correct the grammar of an error message, and drop two periods
Benno Schulenberg [Thu, 4 Jun 2026 09:52:52 +0000 (11:52 +0200)] 
lastlog2: correct the grammar of an error message, and drop two periods

The grammar of a similar message forty lines down is correct.

And a period at the end of an error message is inconsistent.

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
8 days agolsmem: (usage) make an option description fit within 80 columns again
Benno Schulenberg [Thu, 4 Jun 2026 09:52:51 +0000 (11:52 +0200)] 
lsmem: (usage) make an option description fit within 80 columns again

Needed after recent commit 951862cc4a widened all option descriptions
by five columns.

CC: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
8 days agolsmem: (usage) list possible values for <when> like for the other <when>
Benno Schulenberg [Thu, 4 Jun 2026 09:52:50 +0000 (11:52 +0200)] 
lsmem: (usage) list possible values for <when> like for the other <when>

That is: use vertical bars between the values instead of commas and "or".

(Noticed because of the missing space before "always".)

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
10 days agocolumn: remove remaining bitfield in struct member
Christian Goeschel Ndjomouo [Sat, 6 Jun 2026 15:51:28 +0000 (11:51 -0400)] 
column: remove remaining bitfield in struct member

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
10 days agotests: (column) improve tests
Christian Goeschel Ndjomouo [Sat, 6 Jun 2026 15:50:06 +0000 (11:50 -0400)] 
tests: (column) improve tests

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
13 days agolibmount: (monitor) improve test output
Karel Zak [Wed, 3 Jun 2026 11:54:20 +0000 (13:54 +0200)] 
libmount: (monitor) improve test output

Ensure the output is not lost when redirecting stdout.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolsblk: truncate long ID-LINK columns
Wang Yu [Tue, 2 Jun 2026 12:57:43 +0000 (20:57 +0800)] 
lsblk: truncate long ID-LINK columns

The udev by-id link can be very long for some USB devices. Mark the ID
and ID-LINK columns as truncatable so extreme values do not stretch the
entire table.

Fixes #4336

Signed-off-by: Wang Yu <wangyu@uniontech.com>
2 weeks agotests: (chcpu) add missing tests
Christian Goeschel Ndjomouo [Sun, 31 May 2026 15:38:10 +0000 (11:38 -0400)] 
tests: (chcpu) add missing tests

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2 weeks agochcpu: add a helper function to read the CPU 'online' bitmap
Christian Goeschel Ndjomouo [Mon, 1 Jun 2026 18:04:48 +0000 (14:04 -0400)] 
chcpu: add a helper function to read the CPU 'online' bitmap

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2 weeks agochcpu: add --sysroot option
Christian Goeschel Ndjomouo [Fri, 29 May 2026 23:46:40 +0000 (19:46 -0400)] 
chcpu: add --sysroot option

This patch makes it possible to configure the CPUs on a Linux
system other than the one on which the chcpu command is called.
To achieve this users can simply define the root directory of
the sys/ directory with the --sysroot command line option. It
is also beneficial for regression tests, as these make use of
sysfs tar archive dumps.

To properly implement this new feature, the syspath initialization
had to be deferred until after all option arguments, especially
--sysroot, have been parsed, which simplified the path access check.

Along the way a small refactoring of the enable,disable,configure &
deconfigure option parsing had been done, more precisely the CPU list
option argument is now saved in a variable 'cpu_list_arg' to defer
the CPU list validity check until after all option arguments have
been parsed to simplify the logic. Lastly, getopt(3)'s 'optarg' variable
is used instead of argv[optind-1] to store the options argument, which
is more idiomatic and readable.

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2 weeks agoMerge branch 'PR/fstrim-dedup-fix' of https://github.com/karelzak/util-linux-work
Karel Zak [Tue, 2 Jun 2026 11:37:26 +0000 (13:37 +0200)] 
Merge branch 'PR/fstrim-dedup-fix' of https://github.com/karelzak/util-linux-work

* 'PR/fstrim-dedup-fix' of https://github.com/karelzak/util-linux-work:
  fstrim: resolve non-device sources to real block devices

2 weeks agoMerge branch 'PR/readprofile-no-popen' of https://github.com/karelzak/util-linux...
Karel Zak [Tue, 2 Jun 2026 11:34:40 +0000 (13:34 +0200)] 
Merge branch 'PR/readprofile-no-popen' of https://github.com/karelzak/util-linux-work

* 'PR/readprofile-no-popen' of https://github.com/karelzak/util-linux-work:
  readprofile: replace popen() with fork/exec for .gz map files

2 weeks agoMerge branch 'PR/hexdump-color-overflow' of https://github.com/karelzak/util-linux...
Karel Zak [Tue, 2 Jun 2026 11:34:00 +0000 (13:34 +0200)] 
Merge branch 'PR/hexdump-color-overflow' of https://github.com/karelzak/util-linux-work

* 'PR/hexdump-color-overflow' of https://github.com/karelzak/util-linux-work:
  tests: (hexdump) use arrays for OPTS and ADDRFMT
  hexdump: fix buffer overflow in color_cond()

2 weeks agoMerge branch 'PR/lscpu-arm-nooverwrite' of https://github.com/karelzak/util-linux...
Karel Zak [Tue, 2 Jun 2026 11:32:44 +0000 (13:32 +0200)] 
Merge branch 'PR/lscpu-arm-nooverwrite' of https://github.com/karelzak/util-linux-work

* 'PR/lscpu-arm-nooverwrite' of https://github.com/karelzak/util-linux-work:
  lscpu: set nooverwrite for Phytium ARM implementer
  lscpu: add nooverwrite flag for ARM implementer table
  lscpu: add find_implementer() for ARM implementer lookup

2 weeks agohardlink: preserve timestamps when reflinking files
Liu Zheng [Tue, 2 Jun 2026 06:26:28 +0000 (14:26 +0800)] 
hardlink: preserve timestamps when reflinking files

When using --reflink=always, the destination file gets the current
timestamp instead of preserving the original file's atime and mtime.
This differs from both hardlink behavior and "cp -p --reflink=always".

Add futimens() call after successful reflink to restore the original
timestamps from the target file's stat data.

Fixes #2340

2 weeks agofix(resize_partition): initialize index to avoid undefined behavior
Leefancy [Tue, 2 Jun 2026 02:59:54 +0000 (10:59 +0800)] 
fix(resize_partition): initialize index to avoid undefined behavior

Signed-off-by: Leefancy <lijian01@kylinos.cn>
2 weeks agoinclude/mountutils.h: fix LSMT_ROOT definition
Shubham Chakraborty [Sat, 30 May 2026 09:49:32 +0000 (11:49 +0200)] 
include/mountutils.h: fix LSMT_ROOT definition

Commit
ded434a63f3eee7fd7805b18d6c9bb912016c3c8 ("include/mount-api-utils:
add statmount and listmount") introduce a fallback definition for the
LSMT_ROOT defined, but a small typo makes this fallback definition
ineffective:

 #ifdef LSMT_ROOT
 # define LSMT_ROOT ...
 #endif

Should obviously have been:

 #ifndef LSMT_ROOT
 # define LSMT_ROOT ...
 #endif

Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
[Thomas: improve commit message]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2 weeks agoreadprofile: replace popen() with fork/exec for .gz map files
Karel Zak [Mon, 1 Jun 2026 09:23:57 +0000 (11:23 +0200)] 
readprofile: replace popen() with fork/exec for .gz map files

Security scanners repeatedly flag the popen("zcat %s", name) pattern
as a command injection vulnerability (CWE-78). While this is a false
positive -- readprofile is not installed with elevated privileges and
the filename comes from the user's own command line -- the reports are
a recurring nuisance.

The root cause is that popen() passes the command through /bin/sh,
which makes scanners flag it regardless of whether the input is
actually untrusted. Replace popen() with fork()/execlp() to invoke
zcat directly without shell interpretation. This eliminates the
shell from the execution path and silences the scanners without
adding any new dependencies.

Also use ul_endswith() for the .gz suffix check, and handle fdopen()
failure after fork to avoid fd leak and zombie process.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agotests: (hexdump) use arrays for OPTS and ADDRFMT
Karel Zak [Mon, 1 Jun 2026 11:52:33 +0000 (13:52 +0200)] 
tests: (hexdump) use arrays for OPTS and ADDRFMT

Convert OPTS and ADDRFMT from plain strings to bash arrays and use
proper "${…[@]}" expansion to fix shellcheck SC2090/SC2086 warnings
about unquoted variables containing quotes/backslashes.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agoMerge branch 'uclampset-conditional-flags' of https://github.com/1frn10/util-linux...
Karel Zak [Mon, 1 Jun 2026 11:40:05 +0000 (13:40 +0200)] 
Merge branch 'uclampset-conditional-flags' of https://github.com/1frn10/util-linux-fork

* 'uclampset-conditional-flags' of https://github.com/1frn10/util-linux-fork:
  uclampset: fix lost-update race in set_uclamp_one()

2 weeks agofstrim: resolve non-device sources to real block devices
Karel Zak [Thu, 28 May 2026 12:01:53 +0000 (14:01 +0200)] 
fstrim: resolve non-device sources to real block devices

When fstrim reads fstab entries (--fstab, --listed-in), bind mount
entries use directory paths as sources (e.g. /data/ssd/ldap) rather
than device names. Source de-duplication compares path strings, so
these never match the real device paths (e.g. /dev/mapper/foo),
causing the same filesystem to be trimmed multiple times.

Use statmount(STATMOUNT_SB_SOURCE) to resolve directory source paths
to their real block device before de-duplication. Fall back to the
original source when statmount() is unavailable.

Addresses: https://github.com/util-linux/util-linux/issues/857
Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agohexdump: fix buffer overflow in color_cond()
Karel Zak [Thu, 28 May 2026 14:09:20 +0000 (16:09 +0200)] 
hexdump: fix buffer overflow in color_cond()

Widen the color condition value from int (4 bytes) to int64_t (8 bytes)
to accommodate format strings with 8-byte conversion units (e.g.,
1/8 "%016x"). The memcpy() in color_cond() copies clr->range bytes
into a local variable, and for 8-byte units this overflows a 4-byte
int.

Also switch strtoul() to strtoll() in the color format parser to
correctly parse 64-bit values into the widened int64_t field.

Change hexdump_clr.range from int to size_t (a byte count should never
be negative), add a defensive guard against memcpy overflow in
color_cond(), and add an 8-byte color condition regression test.

Reported-by: Michał Majchrowicz (AFINE Team)
Reported-by: Marcin Wyczechowski (AFINE Team)
Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolscpu: set nooverwrite for Phytium ARM implementer
Karel Zak [Thu, 28 May 2026 10:04:32 +0000 (12:04 +0200)] 
lscpu: set nooverwrite for Phytium ARM implementer

The Phytium kernel provides model name in /proc/cpuinfo, prefer it
over the hardcoded table.

Addresses: https://github.com/util-linux/util-linux/pull/4362
Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolscpu: add nooverwrite flag for ARM implementer table
Karel Zak [Thu, 28 May 2026 10:03:28 +0000 (12:03 +0200)] 
lscpu: add nooverwrite flag for ARM implementer table

Add a nooverwrite flag to struct hw_impl. When set, vendor and model
name already provided by the kernel in /proc/cpuinfo are preserved
rather than being overwritten by the hardcoded lookup tables. The
tables serve as a fallback when the kernel does not provide the
information.

This approach keeps all implementer entries in the table, which is
also required for "lscpu --arm-id" to list all known vendors and
part IDs.

Addresses: https://github.com/util-linux/util-linux/pull/4362
Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agoMerge branch 'PR/libmount-no-symlinks' of https://github.com/karelzak/util-linux...
Karel Zak [Mon, 1 Jun 2026 10:15:53 +0000 (12:15 +0200)] 
Merge branch 'PR/libmount-no-symlinks' of https://github.com/karelzak/util-linux-work

* 'PR/libmount-no-symlinks' of https://github.com/karelzak/util-linux-work:
  loopdev: use openat2(RESOLVE_NO_SYMLINKS) for backing file
  lib/fileutils: add ul_open_no_symlinks()

2 weeks agoMerge branch 'PR/tests-tar-no-same-owner' of https://github.com/karelzak/util-linux...
Karel Zak [Mon, 1 Jun 2026 10:15:22 +0000 (12:15 +0200)] 
Merge branch 'PR/tests-tar-no-same-owner' of https://github.com/karelzak/util-linux-work

* 'PR/tests-tar-no-same-owner' of https://github.com/karelzak/util-linux-work:
  tests: use tar --no-same-owner for sysfs dump extraction

2 weeks agoMerge branch 'fix-remove-bits-bash-completion' of https://github.com/add-uos/util...
Karel Zak [Mon, 1 Jun 2026 10:06:39 +0000 (12:06 +0200)] 
Merge branch 'fix-remove-bits-bash-completion' of https://github.com/add-uos/util-linux

* 'fix-remove-bits-bash-completion' of https://github.com/add-uos/util-linux:
  fix: (bash-completion) remove --bit option from bits completion

2 weeks agofix: (bash-completion) remove --bit option from bits completion
zhanghongyuan [Mon, 1 Jun 2026 03:29:19 +0000 (11:29 +0800)] 
fix: (bash-completion) remove --bit option from bits completion

2 weeks agouclampset: fix lost-update race in set_uclamp_one()
Furkan Caliskan [Sun, 31 May 2026 08:36:58 +0000 (11:36 +0300)] 
uclampset: fix lost-update race in set_uclamp_one()

The function unconditionally sets both SCHED_FLAG_UTIL_CLAMP_MIN and
SCHED_FLAG_UTIL_CLAMP_MAX in sa.sched_flags regardless of which values
the user actually requested to change.

This creates a lost-update race: sched_getattr() fetches the current
clamp values, but between that call and sched_setattr(), another thread
may legitimately update the value we did not intend to touch. Because
both flags are always set, sched_setattr() forces the kernel to apply
the stale cached value, silently overwriting the concurrent update.

Fix by setting the flags conditionally.

Signed-off-by: Furkan Caliskan <frn1furkan10@gmail.com>
2 weeks agodmesg: fix off-by-one read buffer size
Brian Mak [Thu, 28 May 2026 19:08:04 +0000 (12:08 -0700)] 
dmesg: fix off-by-one read buffer size

PRINTK_MESSAGE_MAX is 2048 in the kernel. In a formatted record that is
exactly 2048 bytes, reading /proc/kmsg with a size of PRINTK_MESSAGE_MAX
- 1 (2047) will result in the read syscall returning -EINVAL.

We see such a case when using a large initrd, for which the kernel
outputs loading spinner characters, based on the size of the initrd. For
a large enough initrd, there will be enough spinner characters to create
several formatted records of size 2048.

We fix this by increasing the kmsg_buf size by 1, which increases the
size used by the read syscall to PRINTK_MESSAGE_MAX (2048).

Signed-off-by: Brian Mak <makb@juniper.net>
2 weeks agoMerge branch 'blockdev_tests' of https://github.com/cgoesche/util-linux-fork
Karel Zak [Thu, 28 May 2026 10:38:01 +0000 (12:38 +0200)] 
Merge branch 'blockdev_tests' of https://github.com/cgoesche/util-linux-fork

* 'blockdev_tests' of https://github.com/cgoesche/util-linux-fork:
  tests: (blockdev) add missing tests

# Conflicts:
# tests/commands.sh

2 weeks agolscpu: add find_implementer() for ARM implementer lookup
Karel Zak [Thu, 28 May 2026 10:01:01 +0000 (12:01 +0200)] 
lscpu: add find_implementer() for ARM implementer lookup

Refactor ARM implementer lookup into a dedicated find_implementer()
function and use it in is_arm() and arm_ids_decode() to simplify
the code and avoid open-coded linear searches.

Addresses: https://github.com/util-linux/util-linux/pull/4362
Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agofdisk: remove blank line
Karel Zak [Thu, 28 May 2026 09:44:13 +0000 (11:44 +0200)] 
fdisk: remove blank line

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agoMerge branch 'master-branch-5' of https://github.com/Leefancy/util-linux
Karel Zak [Thu, 28 May 2026 09:43:41 +0000 (11:43 +0200)] 
Merge branch 'master-branch-5' of https://github.com/Leefancy/util-linux

* 'master-branch-5' of https://github.com/Leefancy/util-linux:
  fdisk-list: fix memory leak when partition returns empty string

2 weeks agoMerge branch 'master-branch-4' of https://github.com/Leefancy/util-linux
Karel Zak [Thu, 28 May 2026 09:41:55 +0000 (11:41 +0200)] 
Merge branch 'master-branch-4' of https://github.com/Leefancy/util-linux

* 'master-branch-4' of https://github.com/Leefancy/util-linux:
  fdisk-list: fix memory leak in partition listing

2 weeks agoMerge branch 'blkzone_tests' of https://github.com/cgoesche/util-linux-fork
Karel Zak [Thu, 28 May 2026 09:26:57 +0000 (11:26 +0200)] 
Merge branch 'blkzone_tests' of https://github.com/cgoesche/util-linux-fork

* 'blkzone_tests' of https://github.com/cgoesche/util-linux-fork:
  tests: (blkzone) add missing tests
  blkzone: add missing newline in success message

2 weeks agotests: use tar --no-same-owner for sysfs dump extraction
Karel Zak [Thu, 28 May 2026 09:05:55 +0000 (11:05 +0200)] 
tests: use tar --no-same-owner for sysfs dump extraction

Use --no-same-owner when extracting sysfs dump tarballs so that
extracted files are owned by the current user rather than preserving
the original (often root) ownership from the archive.

This allows chmem tests to run without root since they only operate
on a local sysfs dump via --sysroot. The valid_zones file (0444 in
real sysfs) needs an explicit chmod u+w before the test can write
to it. Apply --no-same-owner to lsblk, lscpu, lsmem, and hardlink
tests for consistency.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agoMerge branch 'lsmem_aarch64_dump' of https://github.com/cgoesche/util-linux-fork
Karel Zak [Thu, 28 May 2026 09:10:10 +0000 (11:10 +0200)] 
Merge branch 'lsmem_aarch64_dump' of https://github.com/cgoesche/util-linux-fork

* 'lsmem_aarch64_dump' of https://github.com/cgoesche/util-linux-fork:
  tests: (lsmem) add aarch64 memory block layout dump

2 weeks agochmem: simplify have_mem_blk_zones()
Karel Zak [Thu, 28 May 2026 08:54:33 +0000 (10:54 +0200)] 
chmem: simplify have_mem_blk_zones()

Use ul_path_accessf() instead of manual ul_strconcat() + ul_path_access()
+ free(). This avoids a potential NULL dereference if ul_strconcat() fails
on memory allocation.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agoMerge branch 'chmem_tests' of https://github.com/cgoesche/util-linux-fork
Karel Zak [Thu, 28 May 2026 08:52:28 +0000 (10:52 +0200)] 
Merge branch 'chmem_tests' of https://github.com/cgoesche/util-linux-fork

* 'chmem_tests' of https://github.com/cgoesche/util-linux-fork:
  tests: (chmem) add tests for aarch64 16K 16G memory layout
  chmem: add helper function to sensibly detect the 'valid_zones' attribute
  tests: (chmem) add missing tests
  chmem: add a new --sysroot command line option

2 weeks agoloopdev: use openat2(RESOLVE_NO_SYMLINKS) for backing file
Karel Zak [Wed, 27 May 2026 13:15:22 +0000 (15:15 +0200)] 
loopdev: use openat2(RESOLVE_NO_SYMLINKS) for backing file

Use ul_open_no_symlinks() instead of open(O_NOFOLLOW) when
LOOPDEV_FL_NOFOLLOW is set.  O_NOFOLLOW only rejects symlinks at the
last path component, but TOCTOU attacks swap intermediate components.
openat2(RESOLVE_NO_SYMLINKS) rejects symlinks at any component.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolib/fileutils: add ul_open_no_symlinks()
Karel Zak [Wed, 27 May 2026 08:35:39 +0000 (10:35 +0200)] 
lib/fileutils: add ul_open_no_symlinks()

Add a helper that opens a path rejecting symlinks at any component,
not just the last one.  Uses openat2(RESOLVE_NO_SYMLINKS) when
available (Linux >= 5.6), falls back to open(O_NOFOLLOW).

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agoMerge branch 'PR/getino-op-types' of https://github.com/karelzak/util-linux-work
Karel Zak [Thu, 28 May 2026 08:14:29 +0000 (10:14 +0200)] 
Merge branch 'PR/getino-op-types' of https://github.com/karelzak/util-linux-work

* 'PR/getino-op-types' of https://github.com/karelzak/util-linux-work:
  getino: cleanup whitespace
  getino: rename GETINO_*_NAMESPACE to GETINO_NS_*
  getino: split operation type and namespace type

2 weeks agoMerge branch 'PR/libfdisk-gpt-entry-size' of https://github.com/karelzak/util-linux...
Karel Zak [Wed, 27 May 2026 12:21:50 +0000 (14:21 +0200)] 
Merge branch 'PR/libfdisk-gpt-entry-size' of https://github.com/karelzak/util-linux-work

* 'PR/libfdisk-gpt-entry-size' of https://github.com/karelzak/util-linux-work:
  libfdisk: fix use of on-disk sizeof_partition_entry in GPT