revert community patches

This commit is contained in:
hugel 2025-04-17 09:41:02 +08:00
parent 67c63ba874
commit 616e358798
3 changed files with 15 additions and 197 deletions

View File

@ -1,60 +0,0 @@
From f991ef78af15a001c4acfcb42abca9ce3dce8fbe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= <thomas@t-8ch.de>
Date: Sat, 5 Nov 2022 02:21:27 +0100
Subject: [PATCH] libblkid: ext: add checksum support
Reference:https://github.com/util-linux/util-linux/commit/f991ef78af15a001c4acfcb42abca9ce3dce8fbe
Conflict:NA
---
libblkid/src/superblocks/ext.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/libblkid/src/superblocks/ext.c b/libblkid/src/superblocks/ext.c
index 1c799429..885fec27 100644
--- a/libblkid/src/superblocks/ext.c
+++ b/libblkid/src/superblocks/ext.c
@@ -19,6 +19,7 @@
#include <time.h>
#include "superblocks.h"
+#include "crc32c.h"
struct ext2_super_block {
uint32_t s_inodes_count;
@@ -74,7 +75,8 @@ struct ext2_super_block {
uint16_t s_mmp_interval;
uint64_t s_mmp_block;
uint32_t s_raid_stripe_width;
- uint32_t s_reserved[163];
+ uint32_t s_reserved[162];
+ uint32_t s_checksum;
} __attribute__((packed));
/* magic string */
@@ -102,6 +104,7 @@ struct ext2_super_block {
#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
+#define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM 0x0400
/* for s_feature_incompat */
#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
@@ -148,9 +151,14 @@ static struct ext2_super_block *ext_get_super(
struct ext2_super_block *es;
es = (struct ext2_super_block *)
- blkid_probe_get_buffer(pr, EXT_SB_OFF, 0x200);
+ blkid_probe_get_buffer(pr, EXT_SB_OFF, sizeof(struct ext2_super_block));
if (!es)
return NULL;
+ if (le32_to_cpu(es->s_feature_ro_compat) & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) {
+ uint32_t csum = crc32c(~0, es, offsetof(struct ext2_super_block, s_checksum));
+ if (!blkid_probe_verify_csum(pr, csum, le32_to_cpu(es->s_checksum)))
+ return NULL;
+ }
if (fc)
*fc = le32_to_cpu(es->s_feature_compat);
if (fi)
--
2.33.0

View File

@ -1,128 +0,0 @@
From 483c9f38e377ff0b009f546a2c4ee91a1d61588c Mon Sep 17 00:00:00 2001
From: Krister Johansen <kjlx@templeofstupid.com>
Date: Mon, 18 Nov 2024 12:35:22 -0800
Subject: [PATCH] libblkid: fix spurious ext superblock checksum mismatches
Reads of ext superblocks can race with updates. If libblkid observes a
checksum mismatch, re-read the superblock with O_DIRECT in order to get
a consistent view of its contents. Only if the O_DIRECT read fails the
checksum should it be reported to have failed.
This fixes a problem where devices that were named by filesystem label
failed to be found when systemd attempted to mount them on boot. The
problem was caused by systemd-udevd using libblkid. If a read of a
superblock resulted in a checksum mismatch, udev will remove the
by-label links which result in the mount call failing to find the
device. The checksum mismatch that was triggering the problem was
spurious, and when we use O_DIRECT, or even perform a subsequent retry,
the superblock is correctly read. This resulted in a failure to mount
/boot in one out of every 2,000 or so attempts in our environment.
e2fsprogs fixed[1] an identical version of this bug that afflicted
resize2fs during online grow operations when run from cloud-init. The
fix there was also to use O_DIRECT in order to read the superblock.
This patch uses a similar approach: read the superblock with O_DIRECT in
the case where a bad checksum is detected.
[1] https://lore.kernel.org/linux-ext4/20230609042239.GA1436857@mit.edu/
Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>
Reference:https://github.com/util-linux/util-linux/commit/483c9f38e377ff0b009f546a2c4ee91a1d61588c
Conflict:context adapt
---
libblkid/src/blkidP.h | 5 +++++
libblkid/src/probe.c | 27 +++++++++++++++++++++++++++
libblkid/src/superblocks/ext.c | 22 ++++++++++++++++++++--
3 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/libblkid/src/blkidP.h b/libblkid/src/blkidP.h
index af949c0..37d8b67 100644
--- a/libblkid/src/blkidP.h
+++ b/libblkid/src/blkidP.h
@@ -412,6 +412,11 @@ extern unsigned char *blkid_probe_get_buffer(blkid_probe pr,
__attribute__((nonnull))
__attribute__((warn_unused_result));
+extern const unsigned char *blkid_probe_get_buffer_direct(blkid_probe pr,
+ uint64_t off, uint64_t len)
+ __attribute__((nonnull))
+ __attribute__((warn_unused_result));
+
extern unsigned char *blkid_probe_get_sector(blkid_probe pr, unsigned int sector)
__attribute__((nonnull))
__attribute__((warn_unused_result));
diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c
index 0e716b5..1b41498 100644
--- a/libblkid/src/probe.c
+++ b/libblkid/src/probe.c
@@ -717,6 +717,33 @@ unsigned char *blkid_probe_get_buffer(blkid_probe pr, uint64_t off, uint64_t len
return real_off ? bf->data + (real_off - bf->off + bias) : bf->data + bias;
}
+/*
+ * This is blkid_probe_get_buffer with the read done as an O_DIRECT operation.
+ * Note that @off is offset within probing area, the probing area is defined by
+ * pr->off and pr->size.
+ */
+const unsigned char *blkid_probe_get_buffer_direct(blkid_probe pr, uint64_t off, uint64_t len)
+{
+ const unsigned char *ret = NULL;
+ int flags, rc, olderrno;
+
+ flags = fcntl(pr->fd, F_GETFL);
+ rc = fcntl(pr->fd, F_SETFL, flags | O_DIRECT);
+ if (rc) {
+ DBG(LOWPROBE, ul_debug("fcntl F_SETFL failed to set O_DIRECT"));
+ errno = 0;
+ return NULL;
+ }
+ ret = blkid_probe_get_buffer(pr, off, len);
+ olderrno = errno;
+ rc = fcntl(pr->fd, F_SETFL, flags);
+ if (rc) {
+ DBG(LOWPROBE, ul_debug("fcntl F_SETFL failed to clear O_DIRECT"));
+ errno = olderrno;
+ }
+ return ret;
+}
+
/**
* blkid_probe_reset_buffers:
* @pr: prober
diff --git a/libblkid/src/superblocks/ext.c b/libblkid/src/superblocks/ext.c
index bf73896..a765cf1 100644
--- a/libblkid/src/superblocks/ext.c
+++ b/libblkid/src/superblocks/ext.c
@@ -156,8 +156,26 @@ static struct ext2_super_block *ext_get_super(
return NULL;
if (le32_to_cpu(es->s_feature_ro_compat) & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) {
uint32_t csum = crc32c(~0, es, offsetof(struct ext2_super_block, s_checksum));
- if (!blkid_probe_verify_csum(pr, csum, le32_to_cpu(es->s_checksum)))
- return NULL;
+ /*
+ * A read of the superblock can race with other updates to the
+ * same superblock. In the unlikely event that this occurs and
+ * we see a checksum failure, re-read the superblock with
+ * O_DIRECT to ensure that it's consistent. If it _still_ fails
+ * then declare a checksum mismatch.
+ */
+ if (!blkid_probe_verify_csum(pr, csum, le32_to_cpu(es->s_checksum))) {
+ if (blkid_probe_reset_buffers(pr))
+ return NULL;
+
+ es = (struct ext2_super_block *)
+ blkid_probe_get_buffer_direct(pr, EXT_SB_OFF, sizeof(struct ext2_super_block));
+ if (!es)
+ return NULL;
+
+ csum = crc32c(~0, es, offsetof(struct ext2_super_block, s_checksum));
+ if (!blkid_probe_verify_csum(pr, csum, le32_to_cpu(es->s_checksum)))
+ return NULL;
+ }
}
if (fc)
*fc = le32_to_cpu(es->s_feature_compat);
--
2.33.0

View File

@ -3,7 +3,7 @@
Name: util-linux
Version: 2.37.2
Release: 41
Release: 42
Summary: A random collection of Linux utilities
License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain
URL: https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git
@ -161,14 +161,12 @@ Patch6139: backport-more-make-sure-we-have-data-on-stderr.patch
Patch6140: backport-libblkid-apfs-validate-checksums.patch
Patch6141: backport-sys-utils-setpriv-fix-potential-memory-leak.patch
Patch6142: backport-sys-utils-save_adjtime-fix-memory-leak.patch
Patch6143: backport-libblkid-ext-add-checksum-support.patch
Patch6144: backport-libblkid-fix-spurious-ext-superblock-checksum-mismat.patch
Patch6145: backport-libblkid-fix-potential-memory-leaks.patch
Patch6146: backport-sys-utils-fix-add-NULL-check-for-mnt_fs_get_target-r.patch
Patch6147: backport-sulogin-fix-POSIX-locale-use.patch
Patch6148: backport-setpriv.c-fix-memory-leak-in-parse_groups-function.patch
Patch6149: backport-whereis-avoid-accessing-uninitialized-memory.patch
Patch6150: backport-dmesg-fix-notime-use.patch
Patch6143: backport-libblkid-fix-potential-memory-leaks.patch
Patch6144: backport-sys-utils-fix-add-NULL-check-for-mnt_fs_get_target-r.patch
Patch6145: backport-sulogin-fix-POSIX-locale-use.patch
Patch6146: backport-setpriv.c-fix-memory-leak-in-parse_groups-function.patch
Patch6147: backport-whereis-avoid-accessing-uninitialized-memory.patch
Patch6148: backport-dmesg-fix-notime-use.patch
Patch9000: Add-check-to-resolve-uname26-version-test-failed.patch
Patch9001: SKIPPED-no-root-permissions-test.patch
@ -548,6 +546,14 @@ fi
%{_mandir}/man8/{swapoff.8*,swapon.8*,switch_root.8*,umount.8*,wdctl.8.gz,wipefs.8*,zramctl.8*}
%changelog
* Thu Apr 17 2025 hugel <gengqihu2@h-partners.com> - 2.37.2-42
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:revert community patches
[del] backport-libblkid-ext-add-checksum-support.patch
[del] backport-libblkid-fix-spurious-ext-superblock-checksum-mismat.patch
* Fri Apr 11 2025 zhangting <dev03303@linx-info.com> - 2.37.2-41
- Type:bugfix
- ID:NA