]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
7 hours agodocs: findmnt: clarify that --target returns one filesystem master
Karel Zak [Tue, 14 Jul 2026 12:48:39 +0000 (14:48 +0200)] 
docs: findmnt: clarify that --target returns one filesystem

The --target option identifies the filesystem for a given path, and a
file always resides on exactly one filesystem. Document that --target
returns at most one entry and skips over-mounted entries.

Addresses: https://github.com/util-linux/util-linux/issues/4424
Signed-off-by: Karel Zak <kzak@redhat.com>
7 hours agoMerge branch 'fix-target' of https://github.com/dengbo11/util-linux
Karel Zak [Tue, 14 Jul 2026 12:46:01 +0000 (14:46 +0200)] 
Merge branch 'fix-target' of https://github.com/dengbo11/util-linux

* 'fix-target' of https://github.com/dengbo11/util-linux:
  findmnt: skip shadowed entries when matching by --target

9 hours agoMerge branch 'PR/lslocks-test-fix' of https://github.com/karelzak/util-linux-work
Karel Zak [Tue, 14 Jul 2026 10:39:27 +0000 (12:39 +0200)] 
Merge branch 'PR/lslocks-test-fix' of https://github.com/karelzak/util-linux-work

* 'PR/lslocks-test-fix' of https://github.com/karelzak/util-linux-work:
  tests: lslocks filter, workaround duplicate lines in output

11 hours agoMerge branch 'update_zh_CN_po' of https://github.com/cgoesche/util-linux-fork
Karel Zak [Tue, 14 Jul 2026 09:16:29 +0000 (11:16 +0200)] 
Merge branch 'update_zh_CN_po' of https://github.com/cgoesche/util-linux-fork

* 'update_zh_CN_po' of https://github.com/cgoesche/util-linux-fork:
  po: update zn_CN.po (from translationproject.org)

33 hours agoloopdev: initialize nr to avoid uninitialized use in debug [coverity: CID 490831]
Karel Zak [Mon, 13 Jul 2026 10:41:43 +0000 (12:41 +0200)] 
loopdev: initialize nr to avoid uninitialized use in debug [coverity: CID 490831]

Signed-off-by: Karel Zak <kzak@redhat.com>
33 hours agolibblkid: dos: fix 32-bit overflow in partition start/size [coverity: CID 503517...
Karel Zak [Mon, 13 Jul 2026 10:38:57 +0000 (12:38 +0200)] 
libblkid: dos: fix 32-bit overflow in partition start/size [coverity: CID 503517, 503518]

Signed-off-by: Karel Zak <kzak@redhat.com>
33 hours agochmem: check ul_path_readf_s32() return value [coverity: CID 504055]
Karel Zak [Mon, 13 Jul 2026 10:35:39 +0000 (12:35 +0200)] 
chmem: check ul_path_readf_s32() return value [coverity: CID 504055]

Signed-off-by: Karel Zak <kzak@redhat.com>
33 hours agochcpu: check ul_path_readf_s32() return value [coverity: CID 504056]
Karel Zak [Mon, 13 Jul 2026 10:32:59 +0000 (12:32 +0200)] 
chcpu: check ul_path_readf_s32() return value [coverity: CID 504056]

Signed-off-by: Karel Zak <kzak@redhat.com>
33 hours agolscpu: check ul_path_readf_s32() return value [coverity: CID 504058]
Karel Zak [Mon, 13 Jul 2026 10:29:57 +0000 (12:29 +0200)] 
lscpu: check ul_path_readf_s32() return value [coverity: CID 504058]

Signed-off-by: Karel Zak <kzak@redhat.com>
34 hours agolscpu: add NULL guards for RISC-V ISA functions [coverity: CID 503785]
Karel Zak [Mon, 13 Jul 2026 10:15:16 +0000 (12:15 +0200)] 
lscpu: add NULL guards for RISC-V ISA functions [coverity: CID 503785]

Signed-off-by: Karel Zak <kzak@redhat.com>
34 hours agoagetty: check ioctl() return value [coverity: CID 503786]
Karel Zak [Mon, 13 Jul 2026 10:09:34 +0000 (12:09 +0200)] 
agetty: check ioctl() return value [coverity: CID 503786]

Signed-off-by: Karel Zak <kzak@redhat.com>
34 hours agoagetty: check fcntl() return value [coverity: CID 503788]
Karel Zak [Mon, 13 Jul 2026 10:07:25 +0000 (12:07 +0200)] 
agetty: check fcntl() return value [coverity: CID 503788]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 days agofindmnt: skip shadowed entries when matching by --target
dengbo [Thu, 25 Jun 2026 13:52:16 +0000 (21:52 +0800)] 
findmnt: skip shadowed entries when matching by --target

The previous approach filtered shadowed entries in match_func() using
mnt_table_over_fs() with is_defined_match(COL_TARGET) as the trigger.
This was fragile because COL_TARGET matching is also enabled by other
code paths (source/target swap fallback in get_next_fs(), poll_match()
swap logic, and positional arguments).

Replace with the standard mountinfo iteration pattern: read
/proc/self/mountinfo backward (MNT_ITER_BACKWARD), stop at the first
match (FL_FIRSTONLY), and disable source/target swapping
(FL_NOSWAPMATCH). Since later mounts appear later in mountinfo,
backward iteration naturally finds the visible (topmost) filesystem
for the given target path.

Fixes https://github.com/util-linux/util-linux/issues/4424

4 days agopo: update zn_CN.po (from translationproject.org)
Christian Goeschel Ndjomouo [Fri, 10 Jul 2026 00:53:55 +0000 (20:53 -0400)] 
po: update zn_CN.po (from translationproject.org)

Closes: #4474
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
5 days agobuild-sys: add --disable-lsclocks to configure
Karel Zak [Thu, 9 Jul 2026 14:50:55 +0000 (16:50 +0200)] 
build-sys: add --disable-lsclocks to configure

Addresses: https://github.com/util-linux/util-linux/issues/4472
Signed-off-by: Karel Zak <kzak@redhat.com>
5 days agoMerge branch 'PR/libblkid-vfs' of https://github.com/karelzak/util-linux-work
Karel Zak [Thu, 9 Jul 2026 14:44:20 +0000 (16:44 +0200)] 
Merge branch 'PR/libblkid-vfs' of https://github.com/karelzak/util-linux-work

* 'PR/libblkid-vfs' of https://github.com/karelzak/util-linux-work:
  lib/sysfs: add VFS parameter to sysfs_devno_is_dm_*()
  lib/procfs: use VFS dispatch for read and close
  lib/path: add VFS support
  vfs: add FILE* stream support to the VFS abstraction layer
  vfs: move mode2flags() to include/vfs.h as ul_mode_to_flags()
  wipefs: use blkid_probe_open_device()
  libblkid: use blkid_probe_open_device() in evaluate and verify
  libblkid: add blkid_probe_open_device()
  libblkid: use VFS I/O operations in probe
  libblkid: add blkid_probe_set_vfs() for pluggable I/O
  include: add VFS I/O abstraction layer
  all-io: rename read_all/write_all to ul_read_all/ul_write_all

5 days agoMerge branch 'PR/chrt-skip-policy' of https://github.com/karelzak/util-linux-work
Karel Zak [Thu, 9 Jul 2026 10:27:55 +0000 (12:27 +0200)] 
Merge branch 'PR/chrt-skip-policy' of https://github.com/karelzak/util-linux-work

* 'PR/chrt-skip-policy' of https://github.com/karelzak/util-linux-work:
  tests: (chrt) improve skip_policy with runtime probe

5 days agolib/sysfs: add VFS parameter to sysfs_devno_is_dm_*()
Karel Zak [Tue, 30 Jun 2026 15:30:33 +0000 (17:30 +0200)] 
lib/sysfs: add VFS parameter to sysfs_devno_is_dm_*()

Add const struct ul_vfs_ops *vfs parameter to sysfs_devno_is_dm_hidden()
and sysfs_devno_is_dm_private() so the internal sysfs reads go through
VFS dispatch.

Wire pr->vfs in libblkid probe.c and topology/sysfs.c callers.
Non-library callers pass NULL.

Addresses: https://github.com/util-linux/util-linux/issues/4308
Signed-off-by: Karel Zak <kzak@redhat.com>
5 days agolib/procfs: use VFS dispatch for read and close
Karel Zak [Tue, 30 Jun 2026 15:17:31 +0000 (17:17 +0200)] 
lib/procfs: use VFS dispatch for read and close

Pass VFS ops from path_cxt to read_procfs_file() and use
ul_vfs_close() in procfs_process_get_data_for().

Addresses: https://github.com/util-linux/util-linux/issues/4308
Signed-off-by: Karel Zak <kzak@redhat.com>
5 days agolib/path: add VFS support
Karel Zak [Tue, 30 Jun 2026 15:08:53 +0000 (17:08 +0200)] 
lib/path: add VFS support

Add ul_path_refer_vfs() to set a borrowed VFS ops pointer on
path_cxt. Replace direct I/O in the read/write/fopen paths with
VFS dispatch:

 - ul_path_read(): ul_vfs_read_all + ul_vfs_close
 - ul_path_write_string(): ul_vfs_write_all + ul_vfs_close
 - ul_path_write_s64/u64(): ul_vfs_write_all + ul_vfs_close
 - ul_path_fopen(): ul_vfs_fdopen (fopencookie when VFS set)

Addresses: https://github.com/util-linux/util-linux/issues/4308
Signed-off-by: Karel Zak <kzak@redhat.com>
5 days agovfs: add FILE* stream support to the VFS abstraction layer
Karel Zak [Tue, 30 Jun 2026 15:02:16 +0000 (17:02 +0200)] 
vfs: add FILE* stream support to the VFS abstraction layer

Add vfs_fopen callback in struct ul_vfs_ops for callers who want
full control over stream creation.

Add ul_vfs_fdopen() that wraps an existing fd into a FILE* using
fopencookie() with VFS callbacks, or falls back to fdopen().

Add ul_vfs_fopen() that tries vfs_fopen first, then opens via
vfs_open and wraps with fopencookie, then falls back to fopen().

The fopencookie path is gated on __GLIBC__. On non-glibc systems,
ul_vfs_fdopen() falls back to plain fdopen().

Addresses: https://github.com/util-linux/util-linux/issues/4308
Signed-off-by: Karel Zak <kzak@redhat.com>
5 days agovfs: move mode2flags() to include/vfs.h as ul_mode_to_flags()
Karel Zak [Tue, 30 Jun 2026 14:53:56 +0000 (16:53 +0200)] 
vfs: move mode2flags() to include/vfs.h as ul_mode_to_flags()

Move the fopen-style mode string to open(2) flags parser from
lib/path.c to include/vfs.h for reuse across the project,
especially in the upcoming ul_vfs_fopen() helper.

Addresses: https://github.com/util-linux/util-linux/issues/4308
Signed-off-by: Karel Zak <kzak@redhat.com>
5 days agowipefs: use blkid_probe_open_device()
Karel Zak [Tue, 30 Jun 2026 13:52:08 +0000 (15:52 +0200)] 
wipefs: use blkid_probe_open_device()

Convert wipefs new_probe() to use blkid_probe_open_device() instead
of open() + blkid_probe_set_device(). The flags argument allows
passing the open mode directly.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 days agolibblkid: use blkid_probe_open_device() in evaluate and verify
Karel Zak [Tue, 30 Jun 2026 13:40:46 +0000 (15:40 +0200)] 
libblkid: use blkid_probe_open_device() in evaluate and verify

Convert evaluate.c and verify.c to use blkid_probe_open_device()
instead of open() + blkid_probe_set_device(). This makes these
internal callers VFS-aware and simplifies fd ownership.

Clean up verify.c error paths with dev_err/dev_free labels.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 days agolibblkid: add blkid_probe_open_device()
Karel Zak [Tue, 30 Jun 2026 13:18:25 +0000 (15:18 +0200)] 
libblkid: add blkid_probe_open_device()

Add a convenience function that opens a device and assigns it to
the probe, using VFS operations if previously set. This enables
the composable pattern:

  blkid_new_probe()
  → blkid_probe_set_vfs()
  → blkid_probe_open_device()

Refactor blkid_new_probe_from_filename() to use it internally.

Addresses: https://github.com/util-linux/util-linux/issues/4308
Signed-off-by: Karel Zak <kzak@redhat.com>
5 days agolibblkid: use VFS I/O operations in probe
Karel Zak [Tue, 30 Jun 2026 12:47:19 +0000 (14:47 +0200)] 
libblkid: use VFS I/O operations in probe

Replace all direct I/O syscalls in the probe path with ul_vfs_*
dispatch functions that route through the pluggable VFS layer when
set, falling back to real syscalls otherwise.

Add ul_vfs_copy() to include/vfs.h for cloning VFS ops structs.

Changed call sites:
 - read_buffer(): lseek + read
 - is_sector_readable(): lseek + read, changed signature to take
   blkid_probe instead of bare fd
 - blkid_probe_set_device(): close
 - blkid_do_wipe(): lseek + write_all + fsync
 - blkid_free_probe(): close + free(pr->vfs)
 - blkid_clone_probe(): allocate private VFS copy via ul_vfs_copy()

Addresses: https://github.com/util-linux/util-linux/issues/4308
Signed-off-by: Karel Zak <kzak@redhat.com>
5 days agolibblkid: add blkid_probe_set_vfs() for pluggable I/O
Karel Zak [Tue, 30 Jun 2026 12:38:56 +0000 (14:38 +0200)] 
libblkid: add blkid_probe_set_vfs() for pluggable I/O

Add public API to set custom VFS I/O operations on a blkid probe.
This allows callers (e.g., systemd fibers) to replace standard
read/write/lseek/open/close/fsync with custom implementations.

The ops struct is copied into a private allocation owned by the
probe. NULL function pointers fall back to standard syscalls.
Passing NULL resets to defaults.

New public symbol: blkid_probe_set_vfs()
New struct in public header: struct ul_vfs_ops (with include guard
shared with include/vfs.h)

Addresses: https://github.com/util-linux/util-linux/issues/4308
Signed-off-by: Karel Zak <kzak@redhat.com>
5 days agoinclude: add VFS I/O abstraction layer
Karel Zak [Tue, 30 Jun 2026 12:20:50 +0000 (14:20 +0200)] 
include: add VFS I/O abstraction layer

Add include/vfs.h with struct ul_vfs_ops — a pluggable I/O operations
table with function pointers matching POSIX signatures (read, write,
open, close, lseek, fsync). NULL function pointers fall back to real
syscalls. The size field enables forward/backward compatible struct
evolution.

Refactor include/all-io.h to use VFS dispatch internally:
  - ul_write_all() and ul_read_all() become macros calling
    __write_all(NULL, ...) and __read_all(NULL, ...)
  - New ul_vfs_write_all() and ul_vfs_read_all() macros pass
    through a VFS ops struct for custom I/O

Addresses: https://github.com/util-linux/util-linux/issues/4308
Signed-off-by: Karel Zak <kzak@redhat.com>
5 days agoall-io: rename read_all/write_all to ul_read_all/ul_write_all
Karel Zak [Tue, 30 Jun 2026 11:27:59 +0000 (13:27 +0200)] 
all-io: rename read_all/write_all to ul_read_all/ul_write_all

Add ul_ namespace prefix to all helper functions in all-io.h:

  write_all()      → ul_write_all()
  read_all()       → ul_read_all()
  read_all_alloc() → ul_read_all_alloc()
  fwrite_all()     → ul_fwrite_all()
  sendfile_all()   → ul_sendfile_all()

This is a mechanical rename with no logic changes, preparing
for the VFS I/O abstraction layer.

Addresses: https://github.com/util-linux/util-linux/issues/4308
Signed-off-by: Karel Zak <kzak@redhat.com>
5 days agotests: lslocks filter, workaround duplicate lines in output
Karel Zak [Thu, 9 Jul 2026 10:09:14 +0000 (12:09 +0200)] 
tests: lslocks filter, workaround duplicate lines in output

Duplicate lines have been observed in lslocks output on ppc64le
(kernel 7.0). The root cause is unknown. No duplication path has
been found in the lslocks code itself.

Wrap lslocks calls in do_lslocks() helper that deduplicates
consecutive identical lines via uniq. If duplicates are detected,
warn and mark the test as KNOWN FAILED.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 days agomount: fix grammar and typo in X-mount.idmap documentation
Karel Zak [Wed, 8 Jul 2026 12:03:43 +0000 (14:03 +0200)] 
mount: fix grammar and typo in X-mount.idmap documentation

Apply grammar improvements from PR #4400 (field order change
intentionally omitted as the current order matches the code).
Also fix a GUID -> GID typo in the example.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 days agotests: (chrt) improve skip_policy with runtime probe
Karel Zak [Wed, 8 Jul 2026 11:57:12 +0000 (13:57 +0200)] 
tests: (chrt) improve skip_policy with runtime probe

The skip_policy function relied solely on "chrt --max" output to
detect kernel support for scheduling policies.  This is unreliable
for SCHED_EXT where sched_get_priority_max() returns 0 even on
kernels without CONFIG_SCHED_CLASS_EXT, causing the test to fail
with EINVAL instead of skipping gracefully.

Rework skip_policy to accept optional chrt probe arguments and
verify actual kernel support by attempting to set the policy on
the chrt process itself (--pid 0).  Cache "chrt --max" output once
at startup to avoid repeated execution.

Additionally, filter the platform-dependent runtime parameter from
do_chrt output unless --sched-runtime was explicitly used.  This
removes the need for kernel version gating on the basic batch and
other subtests, allowing them to run on all kernel versions.

Fixes: https://github.com/util-linux/util-linux/issues/4429
Signed-off-by: Karel Zak <kzak@redhat.com>
6 days agolibmount: add Since tag to mnt_table_parse_utab()
Karel Zak [Wed, 8 Jul 2026 10:29:30 +0000 (12:29 +0200)] 
libmount: add Since tag to mnt_table_parse_utab()

Signed-off-by: Karel Zak <kzak@redhat.com>
6 days agoMerge branch 'PR/libmount-utab-api' of https://github.com/karelzak/util-linux-work
Karel Zak [Wed, 8 Jul 2026 10:28:12 +0000 (12:28 +0200)] 
Merge branch 'PR/libmount-utab-api' of https://github.com/karelzak/util-linux-work

* 'PR/libmount-utab-api' of https://github.com/karelzak/util-linux-work:
  libmount: add mnt_table_parse_utab()

6 days agoMerge branch 'branch-02' of https://github.com/Leefancy/util-linux
Karel Zak [Wed, 8 Jul 2026 10:21:38 +0000 (12:21 +0200)] 
Merge branch 'branch-02' of https://github.com/Leefancy/util-linux

* 'branch-02' of https://github.com/Leefancy/util-linux:
  sfdisk: validate partition number is positive

6 days agosetpriv: improve securebits list formatting in man page
Karel Zak [Wed, 8 Jul 2026 10:13:36 +0000 (12:13 +0200)] 
setpriv: improve securebits list formatting in man page

Signed-off-by: Karel Zak <kzak@redhat.com>
6 days agoMerge branch 'new-securebits' of https://github.com/Skyb0rg007/util-linux
Karel Zak [Wed, 8 Jul 2026 10:05:10 +0000 (12:05 +0200)] 
Merge branch 'new-securebits' of https://github.com/Skyb0rg007/util-linux

* 'new-securebits' of https://github.com/Skyb0rg007/util-linux:
  setpriv: add new securebits

6 days agoMerge branch 'use_libmnt_eject' of https://github.com/cgoesche/util-linux-fork
Karel Zak [Wed, 8 Jul 2026 09:58:33 +0000 (11:58 +0200)] 
Merge branch 'use_libmnt_eject' of https://github.com/cgoesche/util-linux-fork

* 'use_libmnt_eject' of https://github.com/cgoesche/util-linux-fork:
  eject: use libmount context API for umount

6 days agoMerge branch 'col-cur-col-underflow' of https://github.com/aizu-m/util-linux
Karel Zak [Wed, 8 Jul 2026 09:28:22 +0000 (11:28 +0200)] 
Merge branch 'col-cur-col-underflow' of https://github.com/aizu-m/util-linux

* 'col-cur-col-underflow' of https://github.com/aizu-m/util-linux:
  col: guard c_width sign before size_t cast in BS branch
  col: fix cur_col underflow on backspace over a wide char

6 days agosfdisk: validate partition number is positive
lijian [Tue, 7 Jul 2026 08:56:51 +0000 (16:56 +0800)] 
sfdisk: validate partition number is positive

Signed-off-by: lijian <lijian01@kylinos.cn>
7 days agosetpriv: add new securebits
Skye Soss [Wed, 1 Jul 2026 02:35:16 +0000 (21:35 -0500)] 
setpriv: add new securebits

Modifies setpriv to support the securebits `no_cap_ambient_raise`,
`exec_restrict_file`, `exec_deny_interactive`, and each of their
`_locked` variants.

The NO_CAP_AMBIENT_RAISE securebit was added in Linux 4.3, and the
EXEC_RESTRICT_FILE and EXEC_DENY_INTERACTIVE securebits were added in
Linux 6.14.

Signed-off-by: Skye Soss <skye@soss.website>
7 days agocol: guard c_width sign before size_t cast in BS branch
Aizal Khan [Tue, 7 Jul 2026 10:14:38 +0000 (15:44 +0530)] 
col: guard c_width sign before size_t cast in BS branch

Signed-off-by: Aizal Khan <aizumusheer2@gmail.com>
7 days agoMerge branch 'feat/4117-agetty-no-login-message' of https://github.com/mvanhorn/util...
Karel Zak [Tue, 7 Jul 2026 09:19:07 +0000 (11:19 +0200)] 
Merge branch 'feat/4117-agetty-no-login-message' of https://github.com/mvanhorn/util-linux

* 'feat/4117-agetty-no-login-message' of https://github.com/mvanhorn/util-linux:
  agetty: clarify nologin message and skip login wait under --chroot
  agetty: handle systems without a shell or /bin/login

7 days agoMerge branch 'fix/4468' of https://github.com/echoechoin/util-linux
Karel Zak [Tue, 7 Jul 2026 09:10:23 +0000 (11:10 +0200)] 
Merge branch 'fix/4468' of https://github.com/echoechoin/util-linux

* 'fix/4468' of https://github.com/echoechoin/util-linux:
  dmesg: treat EAGAIN from /dev/kmsg as EOF, not an error

7 days agoMerge branch 'iso9660-root-dir-oob' of https://github.com/aizu-m/util-linux
Karel Zak [Tue, 7 Jul 2026 08:36:33 +0000 (10:36 +0200)] 
Merge branch 'iso9660-root-dir-oob' of https://github.com/aizu-m/util-linux

* 'iso9660-root-dir-oob' of https://github.com/aizu-m/util-linux:
  libblkid: (iso9660) fix out-of-bounds read of root dir record

7 days agosfdisk: fix memory leak in sfdisk_print_partition()
lijian [Tue, 7 Jul 2026 08:20:24 +0000 (10:20 +0200)] 
sfdisk: fix memory leak in sfdisk_print_partition()

The function fdisk_partition_to_string() dynamically allocates memory
for the returned string, but sfdisk_print_partition() never frees it.

[karelzak@redhat.com: fix code style]

Addresses: https://github.com/util-linux/util-linux/pull/4459
Signed-off-by: lijian <lijian01@kylinos.cn>
Signed-off-by: Karel Zak <kzak@redhat.com>
7 days agodmesg: treat EAGAIN from /dev/kmsg as EOF, not an error
WanBingjiang [Tue, 7 Jul 2026 02:45:29 +0000 (10:45 +0800)] 
dmesg: treat EAGAIN from /dev/kmsg as EOF, not an error

Fixes: https://github.com/util-linux/util-linux/issues/4468
9 days agolibblkid: (iso9660) fix out-of-bounds read of root dir record
Aizal Khan [Sun, 5 Jul 2026 08:22:43 +0000 (13:52 +0530)] 
libblkid: (iso9660) fix out-of-bounds read of root dir record

root_len comes from the on-disk root directory record (rdr+10) and was only rejected when zero. The extent is then mapped for min(root_len, 2048) bytes and the first record is validated by reading rootdata[0], rootdata[32], rootdata[33] and isonum_731(rootdata+2). blkid_probe_get_buffer() only rounds a request up to io_size when the rounded region still fits the probing area, so a root extent sitting in the final partial io_size block of a crafted image returns a buffer of exactly root_len bytes. With root_len between 1 and 33 and rootdata[0] >= 34, the validation reads offsets 32/33 past that buffer. Reject an extent too small to hold the 34-byte record, which the surrounding comment already assumes.

Signed-off-by: Aizal Khan <aizumusheer2@gmail.com>
10 days agoagetty: clarify nologin message and skip login wait under --chroot
Matt Van Horn [Sat, 4 Jul 2026 03:48:16 +0000 (20:48 -0700)] 
agetty: clarify nologin message and skip login wait under --chroot

Address review notes from Karel: reword DEFAULT_NOLOGIN_MESSAGE so it
tells the user a keypress re-checks for the login program, and skip
wait_for_login_program() when --chroot is used since the path check
would test the wrong root. Update the man page accordingly.

Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
11 days agoeject: use libmount context API for umount
Christian Goeschel Ndjomouo [Thu, 25 Jun 2026 16:23:04 +0000 (12:23 -0400)] 
eject: use libmount context API for umount

libmount provides a context API that can be used to replace
the fork+exec code pattern needed to leverage umount(8).
This does not only simplify the code base but also removes
the concern for signal handling due to a wait(2) call, avoids
forking and allocating additional system resources, reduces
security management and makes the code more consistent as other
functions were already using some libmount functionalities.

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
13 days agocol: fix cur_col underflow on backspace over a wide char
Aizal Khan [Wed, 1 Jul 2026 13:21:41 +0000 (18:51 +0530)] 
col: fix cur_col underflow on backspace over a wide char

The BS handler in handle_not_graphic() subtracts the last stored
character's width from lns->cur_col (a size_t) and only guards against
cur_col == 0. When the last graphic character is double-width and the
column was reset by CR then advanced by a single space, cur_col is 1 and
cur_col -= 2 wraps to SIZE_MAX. That feeds l_max_col and the stored
c_column, so flush_line() sizes count[] as l_max_col + 1 (== 0) and then
memsets sizeof(size_t) * l_max_col bytes and indexes count[SIZE_MAX] --
an out-of-bounds write reachable from stdin under a UTF-8 locale. Clamp
the subtraction so the column cannot go below zero.

Signed-off-by: Aizal Khan <aizumusheer2@gmail.com>
13 days agolibmount: add mnt_table_parse_utab()
Karel Zak [Wed, 1 Jul 2026 10:49:25 +0000 (12:49 +0200)] 
libmount: add mnt_table_parse_utab()

Add new public API to parse the utab file into a table. The utab path
and format are private library details; this function hides them from
callers. NULL as filename is recommended to let the library determine
the correct path.

This is needed by systemd for incremental fanotify-based mount
monitoring, where utab needs to be parsed independently of the full
mountinfo/listmount rescan path.

Signed-off-by: Karel Zak <kzak@redhat.com>
13 days agomeson: do not check-build disabled targets
WanBingjiang [Wed, 1 Jul 2026 02:27:58 +0000 (10:27 +0800)] 
meson: do not check-build disabled targets

Signed-off-by: WanBingjiang <wanbingjiang@webray.com.cn>
13 days agotests: build test_child_create only with prctl.h
WanBingjiang [Wed, 1 Jul 2026 02:13:48 +0000 (10:13 +0800)] 
tests: build test_child_create only with prctl.h

Aligned to Meson fix: 1dd0fd9

Signed-off-by: WanBingjiang <wanbingjiang@webray.com.cn>
2 weeks agolibsmartcols: reject large interval repetition bounds in filter regex
Karel Zak [Tue, 30 Jun 2026 10:49:26 +0000 (12:49 +0200)] 
libsmartcols: reject large interval repetition bounds in filter regex

ERE interval expressions like {,32232} cause glibc regcomp() to
allocate gigabytes for the NFA, triggering OOM even on tiny inputs.
The existing consecutive-quantifier and nested-group checks do not
catch this pattern.

Scan numbers inside {...} and reject any bound exceeding
SCOLS_FILTER_MAX_REPCNT (1024). Document the new limit in
scols-filter(5).

Addresses: https://oss-fuzz.com/testcase-detail/6017673394454528
Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agoMerge branch 'fix/configure' of https://github.com/echoechoin/util-linux
Karel Zak [Tue, 30 Jun 2026 10:06:47 +0000 (12:06 +0200)] 
Merge branch 'fix/configure' of https://github.com/echoechoin/util-linux

* 'fix/configure' of https://github.com/echoechoin/util-linux:
  build-sys: require lastlog.h for liblastlog2

2 weeks agoMerge branch 'unshare/map-auto-regression' of https://github.com/arachsys-prs/util...
Karel Zak [Tue, 30 Jun 2026 10:01:40 +0000 (12:01 +0200)] 
Merge branch 'unshare/map-auto-regression' of https://github.com/arachsys-prs/util-linux

* 'unshare/map-auto-regression' of https://github.com/arachsys-prs/util-linux:
  unshare: Fix --map-auto regression

2 weeks agoMerge branch 'execFreeAddErrPath' of https://github.com/mi4r/util-linux
Karel Zak [Tue, 30 Jun 2026 09:57:15 +0000 (11:57 +0200)] 
Merge branch 'execFreeAddErrPath' of https://github.com/mi4r/util-linux

* 'execFreeAddErrPath' of https://github.com/mi4r/util-linux:
  disk-utils: fix memory leak in execute function

2 weeks agoMerge branch 'fix/2205' of https://github.com/echoechoin/util-linux
Karel Zak [Tue, 30 Jun 2026 08:42:48 +0000 (10:42 +0200)] 
Merge branch 'fix/2205' of https://github.com/echoechoin/util-linux

* 'fix/2205' of https://github.com/echoechoin/util-linux:
  hexdump: stop after stdout write errors

2 weeks agoMerge branch 'PR/libmount-utab-uniqid' of https://github.com/karelzak/util-linux...
Karel Zak [Tue, 30 Jun 2026 08:37:06 +0000 (10:37 +0200)] 
Merge branch 'PR/libmount-utab-uniqid' of https://github.com/karelzak/util-linux-work

* 'PR/libmount-utab-uniqid' of https://github.com/karelzak/util-linux-work:
  tests: (mount) strip UNIQID= from utab in special test
  libmount: merge utab into listmount-based tables
  libmount: use uniq_id for target mount verification
  libmount: add mnt_fs_fetch_ids() and populate uniq_id for utab
  libmount: fix missing space after UNIQID= in utab
  libmount: copy uniq_id in mnt_copy_fs()

2 weeks agobuild-sys: require lastlog.h for liblastlog2
WanBingjiang [Tue, 30 Jun 2026 06:59:45 +0000 (14:59 +0800)] 
build-sys: require lastlog.h for liblastlog2

Signed-off-by: WanBingjiang <wanbingjiang@webray.com.cn>
2 weeks agounshare: Fix --map-auto regression
Chris Webb [Mon, 29 Jun 2026 15:37:27 +0000 (15:37 +0000)] 
unshare: Fix --map-auto regression

Commit 07935158 fixed an unshare --user bug which wasted a UID/GID when
--map-auto was used with --map-root-user. This bug meant that, for example,
a user with a single extra UID and GID delegated to them in /etc/subuid
and /etc/subgid would not get that user or group mapped at all if they
attempted unshare -r --map-auto.

Two years later, commit b64b769b added unshare --map-subids to identity-map
subuids and subgids into a user namespace, but incorrectly removed a
load-bearing 'else if' in passing, and reintroduced the original bug.

Ironically, map->inner != -1 for an identity mapping, so the 'if' vs
'else if' change has no effect on the --map-subids option; it only breaks
--map-auto.

Fix the unshare -r --map-auto behaviour again.

Signed-off-by: Chris Webb <chris@arachsys.com>
2 weeks agodisk-utils: fix memory leak in execute function
Tigran Sogomonian [Mon, 29 Jun 2026 12:52:06 +0000 (15:52 +0300)] 
disk-utils: fix memory leak in execute function

Dynamic memory, referenced by 'argv', is allocated by calling function
'xstrdup' and lost when function returns.

Found by the static analyzer Svace.

Signed-off-by: Tigran Sogomonian <tsogomonian@astralinux.ru>
2 weeks agodocs: add CLAUDE.md pointing to AGENTS.md
Karel Zak [Mon, 29 Jun 2026 12:12:56 +0000 (14:12 +0200)] 
docs: add CLAUDE.md pointing to AGENTS.md

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agodocs: remove obsolete historical readme files, update AUTHORS
Karel Zak [Mon, 29 Jun 2026 12:08:01 +0000 (14:08 +0200)] 
docs: remove obsolete historical readme files, update AUTHORS

Remove Documentation files that are leftovers from when various
utilities were standalone projects:

  cal.txt               - algorithm notes
  col.txt               - old Berkeley README
  getopt_changelog.txt  - old standalone changelog
  getopt.txt            - old standalone README
  modems-with-agetty.txt - modem setup (covered in agetty.8)
  pg.txt                - old standalone README
  poeigl.txt            - old init/getty/login changelog
  rfkill.readme         - old standalone project README

Add missing author credits to AUTHORS:

  agetty:  W.Z. Venema, Peter Orbaek
  login:   Michael Glad, Peter Orbaek
  pg:      Gunnar Ritter

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agodocs: remove obsolete hwclock.txt
Karel Zak [Mon, 29 Jun 2026 12:01:37 +0000 (14:01 +0200)] 
docs: remove obsolete hwclock.txt

Three-line description that adds nothing beyond what the man page provides.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agodocs: remove obsolete mount.txt, update AUTHORS
Karel Zak [Mon, 29 Jun 2026 11:58:35 +0000 (13:58 +0200)] 
docs: remove obsolete mount.txt, update AUTHORS

Move mount/umount original authors (Doug Quale, H.J. Lu,
Rick Sladkey, Stephen Tweedie) to the AUTHORS file. Remove
the obsolete Documentation/mount.txt with its pre-libmount
developer notes.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agodocs: integrate release-schedule.txt into HOWTO-CONTRIBUTING.md
Karel Zak [Mon, 29 Jun 2026 11:56:25 +0000 (13:56 +0200)] 
docs: integrate release-schedule.txt into HOWTO-CONTRIBUTING.md

Move the release schedule and RC cadence information into the
HOWTO-CONTRIBUTING.md file. Drop the "Release criteria" section
as tests should always pass regardless of release status.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agodocs: replace howto-*.txt with HOWTO-*.md and add AGENTS.md
Karel Zak [Mon, 29 Jun 2026 11:54:10 +0000 (13:54 +0200)] 
docs: replace howto-*.txt with HOWTO-*.md and add AGENTS.md

Replace the eight Documentation/howto-*.txt files with four consolidated
markdown documents:

  HOWTO-BUILDING.md     - compilation and build system internals
  HOWTO-CONTRIBUTING.md - contribution guidelines and PR workflow
  HOWTO-HACKING.md      - usage functions, man pages, debugging
  HOWTO-TESTING.md      - test framework, env variables, fuzz targets

Add AGENTS.md to the project root with AI-specific coding guidance
(code style pitfalls, return conventions, memory management, commit
message format) and links to the new documentation files.

Rename 00-about-docs.txt to 00-about-docs.md with updated references.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agotests: (mount) strip UNIQID= from utab in special test
Karel Zak [Thu, 25 Jun 2026 13:18:52 +0000 (15:18 +0200)] 
tests: (mount) strip UNIQID= from utab in special test

The sed pattern 'ID=[[:digit:]]* ' also matches the ID= part inside
UNIQID=, causing mangled output. Strip UNIQID= first.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolibmount: merge utab into listmount-based tables
Karel Zak [Thu, 25 Jun 2026 12:52:21 +0000 (14:52 +0200)] 
libmount: merge utab into listmount-based tables

Extract utab merge logic from __mnt_table_parse_mountinfo() into a
shared mnt_table_merge_utab() function and call it at the end of
mnt_table_fetch_listmount(). This makes userspace mount options
(x-systemd.*, user=, etc.) available when the mount table is obtained
via listmount/statmount syscalls.

The merge sets user_optstr directly (instead of the combined optstr)
to avoid conflicts with lazy statmount() which populates kernel
options on demand.

Add mnt_table_disable_useropts() public API to allow callers to skip
utab merging when only kernel-side data is needed.

Use the new API in findmnt --kernel=listmount to keep backward
compatible behavior (kernel-only data); users who want userspace
options can use --mtab.

Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit c839a9ac8fed409c332c94ec69ddc11aea97ae80)

2 weeks agolibmount: use uniq_id for target mount verification
Karel Zak [Thu, 25 Jun 2026 10:32:46 +0000 (12:32 +0200)] 
libmount: use uniq_id for target mount verification

Prefer the unique mount ID (STATX_MNT_ID_UNIQUE) over the old mount ID
when verifying that a mount landed on the expected target in
mnt_context_reopen_target_fd(). Fall back to the old ID when uniq_id is
not available.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolibmount: add mnt_fs_fetch_ids() and populate uniq_id for utab
Karel Zak [Thu, 25 Jun 2026 10:32:31 +0000 (12:32 +0200)] 
libmount: add mnt_fs_fetch_ids() and populate uniq_id for utab

Add mnt_fs_fetch_ids() helper that fetches mount IDs from the kernel
via statx(). It prefers STATX_MNT_ID_UNIQUE and falls back to the old
STATX_MNT_ID on older kernels. Accepts an optional fd argument; when
fd < 0 it falls back to path-based lookup via fs->target.

Use it in hook_create_mount() (new mount API) with fd_tree for robust
fd-based ID, and in hook_mount() (legacy mount(2)) after
reopen_target_fd with fd_target when available.

This ensures utab entries contain UNIQID, which is needed for reliable
utab merging with listmount-based tables.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolibmount: fix missing space after UNIQID= in utab
Karel Zak [Thu, 25 Jun 2026 10:17:13 +0000 (12:17 +0200)] 
libmount: fix missing space after UNIQID= in utab

The fprintf format for UNIQID= was missing a trailing space separator,
causing the field to run into the next field (e.g.,
"UNIQID=2147492389SRC=tmpfs").

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolibmount: copy uniq_id in mnt_copy_fs()
Karel Zak [Thu, 25 Jun 2026 10:17:02 +0000 (12:17 +0200)] 
libmount: copy uniq_id in mnt_copy_fs()

The mnt_copy_fs() function copies all filesystem entry fields but
missed uniq_id, causing the unique mount ID to be lost when fs entries
are duplicated (e.g., for utab updates).

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agohexdump: stop after stdout write errors
WanBingjiang [Thu, 25 Jun 2026 11:08:53 +0000 (19:08 +0800)] 
hexdump: stop after stdout write errors

Stop the display loop once stdout reports an error. Otherwise hexdump keeps formatting and writing after the output stream has already failed, which can loop for a long time on errors such as ENOSPC.

Save the errno from the first stdout error before cleanup can overwrite it. Report that saved error from hexdump itself and bypass close_stdout_atexit, as ferror() only preserves the stream error state and does not recover the original errno.

Add a regression test that writes hexdump output to /dev/full and checks that the command fails with the ENOSPC write error.

Addresses: https://github.com/util-linux/util-linux/issues/2205

Signed-off-by: WanBingjiang <wanbingjiang@webray.com.cn>
2 weeks agobitops: avoid macro redefinition on macOS
Karel Zak [Thu, 25 Jun 2026 13:11:19 +0000 (15:11 +0200)] 
bitops: avoid macro redefinition on macOS

Newer macOS SDKs provide htobe16/htole16/be16toh/etc. via
<sys/endian.h>. Skip our OSSwap-based definitions when that
header is available to avoid -Wmacro-redefined errors.

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

* 'refactor_chcpu' of https://github.com/cgoesche/util-linux-fork:
  tests: (chcpu) test partial success chcpu code
  tests: (chcpu) adjust expected output files
  chcpu: remove unsused system headers
  chcpu: improve error handling in cpu_set_dispatch() and cpu_rescan()
  chcpu: make usage() output translator friendly
  chcpu: handle ul_path_readf_s32() errors
  chcpu: fix persistent partial success exit code
  chcpu: minor code fixes
  chcpu: re-enable warning message if last CPU is being disabled
  chcpu: refactor to introduce context struct

2 weeks agotests: (chcpu) test partial success chcpu code
Christian Goeschel Ndjomouo [Thu, 25 Jun 2026 00:29:08 +0000 (20:29 -0400)] 
tests: (chcpu) test partial success chcpu code

2 weeks agotests: (chcpu) adjust expected output files
Christian Goeschel Ndjomouo [Thu, 11 Jun 2026 22:24:46 +0000 (18:24 -0400)] 
tests: (chcpu) adjust expected output files

2 weeks agochcpu: remove unsused system headers
Christian Goeschel Ndjomouo [Mon, 1 Jun 2026 23:23:18 +0000 (19:23 -0400)] 
chcpu: remove unsused system headers

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2 weeks agochcpu: improve error handling in cpu_set_dispatch() and cpu_rescan()
Christian Goeschel Ndjomouo [Mon, 1 Jun 2026 23:13:35 +0000 (19:13 -0400)] 
chcpu: improve error handling in cpu_set_dispatch() and cpu_rescan()

Let's stay consistent with the function contract and return -1 and
print a warning with warn[x]() in case of failure.

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2 weeks agochcpu: make usage() output translator friendly
Christian Goeschel Ndjomouo [Mon, 1 Jun 2026 23:05:50 +0000 (19:05 -0400)] 
chcpu: make usage() output translator friendly

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2 weeks agochcpu: handle ul_path_readf_s32() errors
Christian Goeschel Ndjomouo [Mon, 1 Jun 2026 23:02:45 +0000 (19:02 -0400)] 
chcpu: handle ul_path_readf_s32() errors

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2 weeks agochcpu: fix persistent partial success exit code
Christian Goeschel Ndjomouo [Mon, 1 Jun 2026 21:53:28 +0000 (17:53 -0400)] 
chcpu: fix persistent partial success exit code

Previously, cpu_enable() and cpu_configure() compared the number
of fails with ctx->maxcpus and if equal it returned -1, which
culminated over to an exit code of 1 (failure). Otherwise, if
there were fails but less than ctx->maxcpus the fucntions return
code 1 would result in an exit code 64 indicating partial success.

Since ctx->maxcpus describes the maximum number of CPUs supported
by the kernel, in practice, this failure mode isn't really useful
as it means that a user would need to fail the configuration of
every possible CPU. This is why chcpu(8) almost always returns 64.

It is better to store the actual amount of requested CPUs and then
compare the amount of fails to it and provide more meaningful exit
codes.

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2 weeks agochcpu: minor code fixes
Christian Goeschel Ndjomouo [Mon, 1 Jun 2026 21:24:43 +0000 (17:24 -0400)] 
chcpu: minor code fixes

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2 weeks agochcpu: re-enable warning message if last CPU is being disabled
Christian Goeschel Ndjomouo [Mon, 1 Jun 2026 20:29:20 +0000 (16:29 -0400)] 
chcpu: re-enable warning message if last CPU is being disabled

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2 weeks agochcpu: refactor to introduce context struct
Christian Goeschel Ndjomouo [Mon, 1 Jun 2026 19:36:04 +0000 (15:36 -0400)] 
chcpu: refactor to introduce context struct

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2 weeks agohwclock, rtcwake: hint about uninitialized RTC on EINVAL
Karel Zak [Wed, 24 Jun 2026 11:29:16 +0000 (13:29 +0200)] 
hwclock, rtcwake: hint about uninitialized RTC on EINVAL

Some RTC drivers (e.g., rtc-nxp-bbnsm) return EINVAL from
RTC_RD_TIME when the hardware time counter has never been
initialized. Print a hint so users know the likely cause rather
than just seeing "Invalid argument".

Addresses: https://github.com/util-linux/util-linux/pull/4376

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agohwclock: fix typo RTC_RD_NAME -> RTC_RD_TIME in error message
Karel Zak [Wed, 24 Jun 2026 11:27:04 +0000 (13:27 +0200)] 
hwclock: fix typo RTC_RD_NAME -> RTC_RD_TIME in error message

Addresses: https://github.com/util-linux/util-linux/pull/4376

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agocfdisk: handle SIGHUP to avoid busy-loop on terminal loss
Karel Zak [Wed, 24 Jun 2026 11:22:12 +0000 (13:22 +0200)] 
cfdisk: handle SIGHUP to avoid busy-loop on terminal loss

When the controlling terminal disappears (e.g., a web terminal
session is closed), the kernel sends SIGHUP. Without handling it,
cfdisk's getch() returns ERR in a tight loop, causing 100% CPU
usage indefinitely.

Register SIGHUP with the existing sig_handler_die() so that all
loops exit via the existing sig_die checks.

Addresses: https://github.com/util-linux/util-linux/pull/4385

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agoMerge branch 'PR/libsmartcols-fuzz-fix' of https://github.com/karelzak/util-linux...
Karel Zak [Wed, 24 Jun 2026 10:58:17 +0000 (12:58 +0200)] 
Merge branch 'PR/libsmartcols-fuzz-fix' of https://github.com/karelzak/util-linux-work

* 'PR/libsmartcols-fuzz-fix' of https://github.com/karelzak/util-linux-work:
  libsmartcols: reject pathological regex patterns in filter
  libsmartcols: harden filter parser against fuzzer issues
  libsmartcols: fix memory leak in filter reset
  libsmartcols: fix SEGV in filter_compile_param()
  OSS-Fuzz: Add new fuzzers targets libsmartcols

2 weeks agomeson: add compile test for scandirat()
Karel Zak [Wed, 24 Jun 2026 09:56:34 +0000 (11:56 +0200)] 
meson: add compile test for scandirat()

The link-only has_function() check is not sufficient on macOS where
scandirat() may exist in the SDK but is gated behind availability
annotations (e.g. macOS 26.4+). When the deployment target is older,
clang emits -Wunguarded-availability-new which -Werror turns into a
build failure.

Add a compile+link verification after the bulk function check to
detect this and disable HAVE_SCANDIRAT when the function is not
actually usable.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agofdisk: clean up dead code in resize_partition()
lijian [Wed, 24 Jun 2026 09:26:41 +0000 (11:26 +0200)] 
fdisk: clean up dead code in resize_partition()

Remove unused variables 'pa', 'next', 'tb' and their corresponding
fdisk_unref_partition()/fdisk_unref_table() calls in the cleanup
path -- all three are initialized to NULL and never reassigned.

[kzak@redhat.com: - fix identification, remove also 'tb']

Signed-off-by: lijian <lijian01@kylinos.cn>
Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolibsmartcols: reject pathological regex patterns in filter
Karel Zak [Tue, 23 Jun 2026 14:21:39 +0000 (16:21 +0200)] 
libsmartcols: reject pathological regex patterns in filter

Consecutive ERE quantifiers (e.g. a++, a**) and nested group
repetitions (e.g. (a+)+) cause glibc regcomp() to allocate gigabytes
for the NFA, triggering OOM on small inputs.

Reject such patterns in filter_compile_param() before they reach
regcomp(), and limit regex pattern size to SCOLS_FILTER_MAX_REGSZ (256
bytes). Document all filter expression limits in scols-filter(5).

Addresses: https://github.com/util-linux/util-linux/pull/4436
Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolibsmartcols: harden filter parser against fuzzer issues
Karel Zak [Tue, 23 Jun 2026 09:52:30 +0000 (11:52 +0200)] 
libsmartcols: harden filter parser against fuzzer issues

Reject non-param nodes in filter_compile_param() to prevent
type confusion when the parser passes an expression node as
a regex operand (heap-use-after-free / heap-buffer-overflow).

Limit filter expression size to SCOLS_FILTER_MAX_EXPRSZ to prevent
pathological inputs from causing unbounded memory growth in the parser
(OOM).

Addresses: https://github.com/util-linux/util-linux/pull/4430
Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolibsmartcols: fix memory leak in filter reset
Karel Zak [Tue, 23 Jun 2026 09:07:30 +0000 (11:07 +0200)] 
libsmartcols: fix memory leak in filter reset

When parsing fails, filter params allocated during parsing but never
incorporated into the AST tree remain on the fltr->params list. The
reset_filter() only freed the tree via fltr->root, leaving orphaned
params leaked.

Add filter_free_params() to drain any remaining params from the list
during filter reset.

Addresses: https://github.com/util-linux/util-linux/pull/4430
Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolibsmartcols: fix SEGV in filter_compile_param()
Karel Zak [Mon, 22 Jun 2026 08:41:51 +0000 (10:41 +0200)] 
libsmartcols: fix SEGV in filter_compile_param()

The val union in filter_param can hold different types (str, num, fnum,
boolean). When a non-string param (e.g. a number) is used as a regex
operand, the numeric value gets reinterpreted as a pointer through
val.str. A small number like 2 becomes pointer 0x2, which passes the
existing NULL check but crashes in regcomp().

Add a type check to reject non-string params before accessing val.str.

Addresses: https://github.com/util-linux/util-linux/pull/4430
Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agoOSS-Fuzz: Add new fuzzers targets libsmartcols
Arthur Chan [Wed, 17 Jun 2026 19:24:46 +0000 (20:24 +0100)] 
OSS-Fuzz: Add new fuzzers targets libsmartcols

[kzak@redhat.com: - fix indention]

Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
3 weeks agoMerge branch 'PR/libfdisk-gpt-oom-fix' of https://github.com/karelzak/util-linux...
Karel Zak [Tue, 23 Jun 2026 10:05:52 +0000 (12:05 +0200)] 
Merge branch 'PR/libfdisk-gpt-oom-fix' of https://github.com/karelzak/util-linux-work

* 'PR/libfdisk-gpt-oom-fix' of https://github.com/karelzak/util-linux-work:
  libfdisk: fix OOM on GPT with huge partition entries array