!142 [sync] PR-139: use checksum for jmicron
From: @openeuler-sync-bot Reviewed-by: @licunlong Signed-off-by: @licunlong
This commit is contained in:
commit
bdf463538d
32
backport-libblkid-cleanup-indentation.patch
Normal file
32
backport-libblkid-cleanup-indentation.patch
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
From c7471d8b3d4e796eee8ae041e5cbb55c5619318e Mon Sep 17 00:00:00 2001
|
||||||
|
From: Karel Zak <kzak@redhat.com>
|
||||||
|
Date: Wed, 19 Oct 2022 11:24:30 +0200
|
||||||
|
Subject: [PATCH] libblkid: cleanup indentation
|
||||||
|
|
||||||
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||||
|
---
|
||||||
|
libblkid/src/superblocks/jmicron_raid.c | 8 ++++----
|
||||||
|
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libblkid/src/superblocks/jmicron_raid.c b/libblkid/src/superblocks/jmicron_raid.c
|
||||||
|
index 9ef8cd3f8..ab2c829f0 100644
|
||||||
|
--- a/libblkid/src/superblocks/jmicron_raid.c
|
||||||
|
+++ b/libblkid/src/superblocks/jmicron_raid.c
|
||||||
|
@@ -17,10 +17,10 @@
|
||||||
|
#include "superblocks.h"
|
||||||
|
|
||||||
|
#define JM_SIGNATURE "JM"
|
||||||
|
-#define JM_MINOR_VERSION(_x) ((_x)->version & 0xFF)
|
||||||
|
-#define JM_MAJOR_VERSION(_x) ((_x)->version >> 8)
|
||||||
|
-#define JM_SPARES 2
|
||||||
|
-#define JM_MEMBERS 8
|
||||||
|
+#define JM_MINOR_VERSION(_x) ((_x)->version & 0xFF)
|
||||||
|
+#define JM_MAJOR_VERSION(_x) ((_x)->version >> 8)
|
||||||
|
+#define JM_SPARES 2
|
||||||
|
+#define JM_MEMBERS 8
|
||||||
|
|
||||||
|
struct jm_metadata {
|
||||||
|
int8_t signature[2]; /* 0x0 - 0x01 */
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
92
backport-libblkid-fix-jmicron-checksum-and-LE-to-CPU.patch
Normal file
92
backport-libblkid-fix-jmicron-checksum-and-LE-to-CPU.patch
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
From cb92f0d82ae634e46989d3dae673ae3f542f7dd9 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Karel Zak <kzak@redhat.com>
|
||||||
|
Date: Fri, 21 Oct 2022 18:11:59 +0200
|
||||||
|
Subject: [PATCH] libblkid: fix jmicron checksum and LE to CPU
|
||||||
|
|
||||||
|
- don't cast packed struct to uint16_t pointer, use temporary value
|
||||||
|
- calculate real count for the loop
|
||||||
|
- convert all to LE for checksum calculation (jm_to_cpu() ignores fillers)
|
||||||
|
|
||||||
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||||
|
---
|
||||||
|
libblkid/src/superblocks/jmicron_raid.c | 44 ++++++++++++++-----------
|
||||||
|
1 file changed, 25 insertions(+), 19 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libblkid/src/superblocks/jmicron_raid.c b/libblkid/src/superblocks/jmicron_raid.c
|
||||||
|
index ab2c829f0..580c38533 100644
|
||||||
|
--- a/libblkid/src/superblocks/jmicron_raid.c
|
||||||
|
+++ b/libblkid/src/superblocks/jmicron_raid.c
|
||||||
|
@@ -55,35 +55,38 @@ static void jm_to_cpu(struct jm_metadata *jm)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
- le16_to_cpu(jm->version);
|
||||||
|
- le16_to_cpu(jm->checksum);
|
||||||
|
- le32_to_cpu(jm->identity);
|
||||||
|
+ jm->version = le16_to_cpu(jm->version);
|
||||||
|
+ jm->checksum = le16_to_cpu(jm->checksum);
|
||||||
|
+ jm->identity = le32_to_cpu(jm->identity);
|
||||||
|
+ jm->segment.base = le32_to_cpu(jm->segment.base);
|
||||||
|
+ jm->segment.range = le32_to_cpu(jm->segment.range);
|
||||||
|
+ jm->segment.range2 = le16_to_cpu(jm->segment.range2);
|
||||||
|
|
||||||
|
- le32_to_cpu(jm->segment.base);
|
||||||
|
- le32_to_cpu(jm->segment.range);
|
||||||
|
- le16_to_cpu(jm->segment.range2);
|
||||||
|
-
|
||||||
|
- le16_to_cpu(jm->attribute);
|
||||||
|
+ jm->attribute = le16_to_cpu(jm->attribute);
|
||||||
|
|
||||||
|
for (i = 0; i < JM_SPARES; i++)
|
||||||
|
- le32_to_cpu(jm->spare[i]);
|
||||||
|
+ jm->spare[i] = le32_to_cpu(jm->spare[i]);
|
||||||
|
|
||||||
|
for (i = 0; i < JM_MEMBERS; i++)
|
||||||
|
- le32_to_cpu(jm->member[i]);
|
||||||
|
+ jm->member[i] = le32_to_cpu(jm->member[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int jm_checksum(struct jm_metadata *jm)
|
||||||
|
+static int jm_checksum(const struct jm_metadata *jm)
|
||||||
|
{
|
||||||
|
- size_t count = 64;
|
||||||
|
- char *buf = (char *) jm;
|
||||||
|
- uint16_t *p = (uint16_t *) buf, sum = 0;
|
||||||
|
+ size_t count = sizeof(*jm) / sizeof(uint16_t);
|
||||||
|
+ uint16_t sum = 0;
|
||||||
|
+ unsigned char *ptr = (unsigned char *) jm;
|
||||||
|
+
|
||||||
|
+ while (count--) {
|
||||||
|
+ uint16_t val;
|
||||||
|
|
||||||
|
- assert(count <= sizeof(struct jm_metadata));
|
||||||
|
+ memcpy(&val, ptr, sizeof(uint16_t));
|
||||||
|
+ sum += le16_to_cpu(val);
|
||||||
|
|
||||||
|
- while (count--)
|
||||||
|
- sum += *p++;
|
||||||
|
+ ptr += sizeof(uint16_t);
|
||||||
|
+ }
|
||||||
|
|
||||||
|
- return !sum || sum == 1;
|
||||||
|
+ return sum == 0 || sum == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int probe_jmraid(blkid_probe pr,
|
||||||
|
@@ -108,9 +111,12 @@ static int probe_jmraid(blkid_probe pr,
|
||||||
|
if (memcmp(jm->signature, JM_SIGNATURE, sizeof(JM_SIGNATURE) - 1) != 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
+ if (!jm_checksum(jm))
|
||||||
|
+ return 1;
|
||||||
|
+
|
||||||
|
jm_to_cpu(jm);
|
||||||
|
|
||||||
|
- if (!jm_checksum(jm))
|
||||||
|
+ if (jm->mode > 5)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (blkid_probe_sprintf_version(pr, "%u.%u",
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
122
backport-libblkid-use-checksum-for-jmicron.patch
Normal file
122
backport-libblkid-use-checksum-for-jmicron.patch
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
From cf68e2c897a29f8a3a1c8402574bbb49adf5a52a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Karel Zak <kzak@redhat.com>
|
||||||
|
Date: Wed, 19 Oct 2022 11:16:17 +0200
|
||||||
|
Subject: [PATCH] libblkid: use checksum for jmicron
|
||||||
|
|
||||||
|
Addresses: https://github.com/util-linux/util-linux/pull/1843
|
||||||
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||||
|
---
|
||||||
|
libblkid/src/superblocks/jmicron_raid.c | 83 ++++++++++++++++++++++---
|
||||||
|
1 file changed, 74 insertions(+), 9 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libblkid/src/superblocks/jmicron_raid.c b/libblkid/src/superblocks/jmicron_raid.c
|
||||||
|
index ca7986733..9ef8cd3f8 100644
|
||||||
|
--- a/libblkid/src/superblocks/jmicron_raid.c
|
||||||
|
+++ b/libblkid/src/superblocks/jmicron_raid.c
|
||||||
|
@@ -16,14 +16,75 @@
|
||||||
|
|
||||||
|
#include "superblocks.h"
|
||||||
|
|
||||||
|
+#define JM_SIGNATURE "JM"
|
||||||
|
+#define JM_MINOR_VERSION(_x) ((_x)->version & 0xFF)
|
||||||
|
+#define JM_MAJOR_VERSION(_x) ((_x)->version >> 8)
|
||||||
|
+#define JM_SPARES 2
|
||||||
|
+#define JM_MEMBERS 8
|
||||||
|
+
|
||||||
|
struct jm_metadata {
|
||||||
|
- int8_t signature[2];
|
||||||
|
- uint8_t minor_version;
|
||||||
|
- uint8_t major_version;
|
||||||
|
- uint16_t checksum;
|
||||||
|
-};
|
||||||
|
+ int8_t signature[2]; /* 0x0 - 0x01 */
|
||||||
|
|
||||||
|
-#define JM_SIGNATURE "JM"
|
||||||
|
+ uint16_t version; /* 0x03 - 0x04 JMicron version */
|
||||||
|
+
|
||||||
|
+ uint16_t checksum; /* 0x04 - 0x05 */
|
||||||
|
+ uint8_t filler[10];
|
||||||
|
+
|
||||||
|
+ uint32_t identity; /* 0x10 - 0x13 */
|
||||||
|
+
|
||||||
|
+ struct {
|
||||||
|
+ uint32_t base; /* 0x14 - 0x17 */
|
||||||
|
+ uint32_t range; /* 0x18 - 0x1B range */
|
||||||
|
+ uint16_t range2; /* 0x1C - 0x1D range2 */
|
||||||
|
+ } segment;
|
||||||
|
+
|
||||||
|
+ int8_t name[16]; /* 0x20 - 0x2F */
|
||||||
|
+
|
||||||
|
+ uint8_t mode; /* 0x30 RAID level */
|
||||||
|
+ uint8_t block; /* 0x31 stride size (2=4K, 3=8K, ...) */
|
||||||
|
+ uint16_t attribute; /* 0x32 - 0x33 */
|
||||||
|
+ uint8_t filler1[4];
|
||||||
|
+
|
||||||
|
+ uint32_t spare[JM_SPARES]; /* 0x38 - 0x3F */
|
||||||
|
+ uint32_t member[JM_MEMBERS]; /* 0x40 - 0x5F */
|
||||||
|
+
|
||||||
|
+ uint8_t filler2[0x20];
|
||||||
|
+} __attribute__ ((packed));
|
||||||
|
+
|
||||||
|
+static void jm_to_cpu(struct jm_metadata *jm)
|
||||||
|
+{
|
||||||
|
+ unsigned int i;
|
||||||
|
+
|
||||||
|
+ le16_to_cpu(jm->version);
|
||||||
|
+ le16_to_cpu(jm->checksum);
|
||||||
|
+ le32_to_cpu(jm->identity);
|
||||||
|
+
|
||||||
|
+ le32_to_cpu(jm->segment.base);
|
||||||
|
+ le32_to_cpu(jm->segment.range);
|
||||||
|
+ le16_to_cpu(jm->segment.range2);
|
||||||
|
+
|
||||||
|
+ le16_to_cpu(jm->attribute);
|
||||||
|
+
|
||||||
|
+ for (i = 0; i < JM_SPARES; i++)
|
||||||
|
+ le32_to_cpu(jm->spare[i]);
|
||||||
|
+
|
||||||
|
+ for (i = 0; i < JM_MEMBERS; i++)
|
||||||
|
+ le32_to_cpu(jm->member[i]);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int jm_checksum(struct jm_metadata *jm)
|
||||||
|
+{
|
||||||
|
+ size_t count = 64;
|
||||||
|
+ char *buf = (char *) jm;
|
||||||
|
+ uint16_t *p = (uint16_t *) buf, sum = 0;
|
||||||
|
+
|
||||||
|
+ assert(count <= sizeof(struct jm_metadata));
|
||||||
|
+
|
||||||
|
+ while (count--)
|
||||||
|
+ sum += *p++;
|
||||||
|
+
|
||||||
|
+ return !sum || sum == 1;
|
||||||
|
+}
|
||||||
|
|
||||||
|
static int probe_jmraid(blkid_probe pr,
|
||||||
|
const struct blkid_idmag *mag __attribute__((__unused__)))
|
||||||
|
@@ -46,8 +107,14 @@ static int probe_jmraid(blkid_probe pr,
|
||||||
|
|
||||||
|
if (memcmp(jm->signature, JM_SIGNATURE, sizeof(JM_SIGNATURE) - 1) != 0)
|
||||||
|
return 1;
|
||||||
|
+
|
||||||
|
+ jm_to_cpu(jm);
|
||||||
|
+
|
||||||
|
+ if (!jm_checksum(jm))
|
||||||
|
+ return 1;
|
||||||
|
+
|
||||||
|
if (blkid_probe_sprintf_version(pr, "%u.%u",
|
||||||
|
- jm->major_version, jm->minor_version) != 0)
|
||||||
|
+ JM_MAJOR_VERSION(jm), JM_MINOR_VERSION(jm)) != 0)
|
||||||
|
return 1;
|
||||||
|
if (blkid_probe_set_magic(pr, off, sizeof(jm->signature),
|
||||||
|
(unsigned char *) jm->signature))
|
||||||
|
@@ -61,5 +128,3 @@ const struct blkid_idinfo jmraid_idinfo = {
|
||||||
|
.probefunc = probe_jmraid,
|
||||||
|
.magics = BLKID_NONE_MAGIC
|
||||||
|
};
|
||||||
|
-
|
||||||
|
-
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
Name: util-linux
|
Name: util-linux
|
||||||
Version: 2.37.2
|
Version: 2.37.2
|
||||||
Release: 14
|
Release: 15
|
||||||
Summary: A random collection of Linux utilities
|
Summary: A random collection of Linux utilities
|
||||||
License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain
|
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
|
URL: https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git
|
||||||
@ -59,6 +59,9 @@ Patch6037: backport-libblkid-exfat-fix-divide-by-zero-coverity-scan.patch
|
|||||||
Patch6038: backport-llib-pty-session-split-PTY-and-signalfd-setup.patch
|
Patch6038: backport-llib-pty-session-split-PTY-and-signalfd-setup.patch
|
||||||
Patch6039: backport-script-fix-use-of-utempter.patch
|
Patch6039: backport-script-fix-use-of-utempter.patch
|
||||||
Patch6040: backport-logger-always-update-header-when-read-from-stdin.patch
|
Patch6040: backport-logger-always-update-header-when-read-from-stdin.patch
|
||||||
|
Patch6041: backport-libblkid-use-checksum-for-jmicron.patch
|
||||||
|
Patch6042: backport-libblkid-cleanup-indentation.patch
|
||||||
|
Patch6043: backport-libblkid-fix-jmicron-checksum-and-LE-to-CPU.patch
|
||||||
|
|
||||||
Patch9000: Add-check-to-resolve-uname26-version-test-failed.patch
|
Patch9000: Add-check-to-resolve-uname26-version-test-failed.patch
|
||||||
Patch9001: SKIPPED-no-root-permissions-test.patch
|
Patch9001: SKIPPED-no-root-permissions-test.patch
|
||||||
@ -429,6 +432,12 @@ fi
|
|||||||
%{_mandir}/man8/{swapoff.8*,swapon.8*,switch_root.8*,umount.8*,wdctl.8.gz,wipefs.8*,zramctl.8*}
|
%{_mandir}/man8/{swapoff.8*,swapon.8*,switch_root.8*,umount.8*,wdctl.8.gz,wipefs.8*,zramctl.8*}
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Mar 1 2023 zhangyao <zhangyao108@huawei.com> - 2.37.2-15
|
||||||
|
- Type:bugfix
|
||||||
|
- CVE:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC:use checksum for jmicron
|
||||||
|
|
||||||
* Tue Jan 31 2023 yangchenguang <yangchenguang@uniontech.com> - 2.37.2-14
|
* Tue Jan 31 2023 yangchenguang <yangchenguang@uniontech.com> - 2.37.2-14
|
||||||
- Type:bugfix
|
- Type:bugfix
|
||||||
- ID:NA
|
- ID:NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user