From 4c1825e9756f252e783163a572d2a2623b62f096 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 23 Oct 2025 11:58:46 +0200 Subject: [PATCH] mount: improve --all documentation - libblkid: Fix probe_ioctl_tp assigning BLKGETDISKSEQ as physical - libblkid: use snprintf() instead of sprintf() Resolves: RHEL-119786 RHEL-121120 RHEL-123170 --- 0016-mount-improve-all-documentation.patch | 43 ++++++++++++++ ...be_ioctl_tp-assigning-BLKGETDISKSEQ-.patch | 53 +++++++++++++++++ ...lkid-use-snprintf-instead-of-sprintf.patch | 59 +++++++++++++++++++ util-linux.spec | 7 +++ 4 files changed, 162 insertions(+) create mode 100644 0016-mount-improve-all-documentation.patch create mode 100644 0017-libblkid-Fix-probe_ioctl_tp-assigning-BLKGETDISKSEQ-.patch create mode 100644 0018-libblkid-use-snprintf-instead-of-sprintf.patch diff --git a/0016-mount-improve-all-documentation.patch b/0016-mount-improve-all-documentation.patch new file mode 100644 index 0000000..1268ec5 --- /dev/null +++ b/0016-mount-improve-all-documentation.patch @@ -0,0 +1,43 @@ +From 7e8aba77423013481fa2965ad80c7fe7aece8497 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 22 Oct 2025 10:53:15 +0200 +Subject: mount: improve --all documentation + +Add notes to the --all option description: +- Historical context: mount -a was originally designed for init scripts +- Modern usage: systemd-based distributions use systemd units instead +- Swap handling: swap entries in fstab are silently ignored, use swapon -a + +Addresses: https://issues.redhat.com/browse/RHEL-119786 +Signed-off-by: Karel Zak +--- + sys-utils/mount.8.adoc | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/sys-utils/mount.8.adoc b/sys-utils/mount.8.adoc +index ba8b45a2a..de2461f8a 100644 +--- a/sys-utils/mount.8.adoc ++++ b/sys-utils/mount.8.adoc +@@ -303,7 +303,9 @@ The *mount* command does not pass all command-line options to the **/sbin/mount. + Command-line options available for the *mount* command are: + + *-a*, *--all*:: +-Mount all filesystems (of the given types) mentioned in _fstab_ (except for those whose line contains the *noauto* keyword). The filesystems are mounted following their order in _fstab_. The *mount* command compares filesystem source, target (and fs root for bind mount or btrfs) to detect already mounted filesystems. The kernel table with already mounted filesystems is cached during *mount --all*. This means that all duplicated _fstab_ entries will be mounted. ++Mount all filesystems (of the given types) mentioned in _fstab_ (except for those whose line contains the *noauto* keyword). This option was originally designed for use in init scripts. Note that many modern systemd-based distributions do not use *mount -a* on boot and instead mount filesystems in a more sophisticated way using systemd units. +++ ++The filesystems are mounted following their order in _fstab_. The *mount* command compares filesystem source, target (and fs root for bind mount or btrfs) to detect already mounted filesystems. The kernel table with already mounted filesystems is cached during *mount --all*. This means that all duplicated _fstab_ entries will be mounted. + + + The correct functionality depends on _/proc_ (to detect already mounted filesystems) and on _/sys_ (to evaluate filesystem tags like UUID= or LABEL=). It's strongly recommended to mount _/proc_ and _/sys_ filesystems before *mount -a* is executed, or keep /proc and /sys at the beginning of _fstab_. + + +@@ -311,6 +313,8 @@ The option *--all* is possible to use for remount operation too. In this case al + + + Since version 2.35 it is possible to use the command line option *-o* to alter mount options from _fstab_ (see also *--options-mode*). + + ++Note that swap entries in _fstab_ are silently ignored by *mount -a*. Use *swapon -a* to enable swap devices and files. See *swapon*(8). +++ + Note that it is a bad practice to use *mount -a* for _fstab_ checking. The recommended solution is *findmnt --verify*. + + *-B*, *--bind*:: +-- +2.51.0 + diff --git a/0017-libblkid-Fix-probe_ioctl_tp-assigning-BLKGETDISKSEQ-.patch b/0017-libblkid-Fix-probe_ioctl_tp-assigning-BLKGETDISKSEQ-.patch new file mode 100644 index 0000000..d2b638d --- /dev/null +++ b/0017-libblkid-Fix-probe_ioctl_tp-assigning-BLKGETDISKSEQ-.patch @@ -0,0 +1,53 @@ +From 9121e301959fb977642c1bab81525fed08629c1c Mon Sep 17 00:00:00 2001 +From: Sam Fink +Date: Wed, 17 Sep 2025 10:04:51 -0400 +Subject: libblkid: Fix probe_ioctl_tp assigning BLKGETDISKSEQ as physical + sector size + +Fix issue introduced by PR#2908 in probe_ioctl_tp where the BLKGETDISKSEQ ioctl +result is incorrectly assigned to the topology with +blkid_topology_set_physical_sector_size instead of blkid_topology_set_diskseq. + +This issue was observed while using a Debian 13 container on a RHEL 9.4 host +attempting to format a volume. The physical sector size was incorrectly +reported as 3. This issue also presents with the fdisk command, +which also uses this library to resolve physical sector size of devices. + +Example fdisk output: +root@r94p121-PA:~ # fdisk --list /dev/sdb +Disk /dev/sdb: 90 GiB, 96636764160 bytes, 188743680 sectors +Units: sectors of 1 * 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 3 bytes +I/O size (minimum/optimal): 512 bytes / 3 bytes + +Strace of relevant ioctls: +ioctl(3, BLKALIGNOFF, [0]) = 0 +ioctl(3, BLKIOMIN, [512]) = 0 +ioctl(3, BLKIOOPT, [0]) = 0 +ioctl(3, BLKPBSZGET, [512]) = 0 +ioctl(3, BLKGETDISKSEQ, [3]) = 0 +ioctl(3, BLKSSZGET, [512]) = 0 + +Addresses: https://issues.redhat.com/browse/RHEL-123170 + +(cherry picked from commit 6fbde1c7db838e22b109e2e58eaa51b086758bc6) +--- + libblkid/src/topology/ioctl.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libblkid/src/topology/ioctl.c b/libblkid/src/topology/ioctl.c +index 7b15c9e9a..e95d67739 100644 +--- a/libblkid/src/topology/ioctl.c ++++ b/libblkid/src/topology/ioctl.c +@@ -46,7 +46,7 @@ static int probe_ioctl_tp(blkid_probe pr, + + if (ioctl(pr->fd, BLKGETDISKSEQ, &u64) == -1) + return 1; +- if (blkid_topology_set_physical_sector_size(pr, u64)) ++ if (blkid_topology_set_diskseq(pr, u64)) + return -1; + + return 0; +-- +2.51.0 + diff --git a/0018-libblkid-use-snprintf-instead-of-sprintf.patch b/0018-libblkid-use-snprintf-instead-of-sprintf.patch new file mode 100644 index 0000000..a07d04a --- /dev/null +++ b/0018-libblkid-use-snprintf-instead-of-sprintf.patch @@ -0,0 +1,59 @@ +From e00af23ce51151a5a2e7b207dbe8d1bc715e4bd1 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 6 Oct 2025 15:04:24 +0200 +Subject: libblkid: use snprintf() instead of sprintf() + +Replace sprintf() calls with snprintf() to ensure proper bounds +checking when formatting strings. + +In encode.c, the check now validates snprintf() return value instead +of pre-checking buffer size, providing more robust error handling. + +In probe.c, snprintf() is used with proper size calculation based on +remaining buffer space. + +Addresses: https://issues.redhat.com/browse/RHEL-121120 + +Signed-off-by: Karel Zak +(cherry picked from commit 041380f4ca7244df624bf7efdb5e27fdd3144175) +--- + libblkid/src/encode.c | 6 ++++-- + libblkid/src/probe.c | 4 ++-- + 2 files changed, 6 insertions(+), 4 deletions(-) + +diff --git a/libblkid/src/encode.c b/libblkid/src/encode.c +index 8213873ee..4b83f6690 100644 +--- a/libblkid/src/encode.c ++++ b/libblkid/src/encode.c +@@ -191,9 +191,11 @@ int blkid_encode_string(const char *str, char *str_enc, size_t len) + j += seqlen; + i += (seqlen-1); + } else if (str[i] == '\\' || !is_whitelisted(str[i], NULL)) { +- if (len-j < 4) ++ int rc; ++ ++ rc = snprintf(&str_enc[j], len-j, "\\x%02x", (unsigned char) str[i]); ++ if (rc != 4) + goto err; +- sprintf(&str_enc[j], "\\x%02x", (unsigned char) str[i]); + j += 4; + } else { + if (len-j < 1) +diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c +index 76905e197..cd45bcdf7 100644 +--- a/libblkid/src/probe.c ++++ b/libblkid/src/probe.c +@@ -1972,8 +1972,8 @@ static void blkid_probe_log_csum_mismatch(blkid_probe pr, size_t n, const void * + int hex_size = min(sizeof(csum_hex), n * 2); + + for (int i = 0; i < hex_size; i+=2) { +- sprintf(&csum_hex[i], "%02X", ((const unsigned char *) csum)[i / 2]); +- sprintf(&expected_hex[i], "%02X", ((const unsigned char *) expected)[i / 2]); ++ snprintf(&csum_hex[i], sizeof(csum_hex) - i, "%02X", ((const unsigned char *) csum)[i / 2]); ++ snprintf(&expected_hex[i], sizeof(expected_hex) - i, "%02X", ((const unsigned char *) expected)[i / 2]); + } + + ul_debug( +-- +2.51.0 + diff --git a/util-linux.spec b/util-linux.spec index d6686f2..1c6b764 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -128,6 +128,13 @@ Patch13: 0013-libfdisk-improve-collision-reporting.patch Patch14: 0014-libfdisk-dos-ignore-incomplete-EBR-for-non-wholedisk.patch # RHEL- - wall: always use utmp as fallback Patch15: 0015-wall-always-use-utmp-as-fallback.patch +# RHEL-119786 - mount: improve --all documentation +Patch16: 0016-mount-improve-all-documentation.patch +# RHEL-123170 - libblkid: Fix probe_ioctl_tp assigning BLKGETDISKSEQ as physical +Patch17: 0017-libblkid-Fix-probe_ioctl_tp-assigning-BLKGETDISKSEQ-.patch +# RHEL-121120 - libblkid: use snprintf() instead of sprintf() +Patch18: 0018-libblkid-use-snprintf-instead-of-sprintf.patch + %description The util-linux package contains a large variety of low-level system