From 925fc78f0ab49b7e05b3e37d6917ab6396ac20ce0becfd1f596105a174de2753 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 3 May 2016 14:15:10 +0000 Subject: [PATCH] - dmidecode-01-add-no-sysfs-option-description-to-h-output.patch: Add "--no-sysfs" option description to -h output. - dmidecode-02-fix-no-smbios-nor-dmi-entry-point-found-on-smbios3.patch: Fix 'No SMBIOS nor DMI entry point found' on SMBIOS3. - dmidecode-03-let-read_file-return-the-actual-data-size.patch: Let read_file return the actual data size. - dmidecode-04-use-read_file-to-read-the-dmi-table-from-sysfs.patch: Use read_file() to read the DMI table from sysfs. https://savannah.nongnu.org/bugs/?46176 - dmidecode-05-use-dword-for-structure-table-maximum-size-in-smbios3.patch: Use DWORD for Structure table maximum size in SMBIOS3. - dmidecode-06-hide-irrelevant-fixup-message.patch: Hide irrelevant fixup message. http://savannah.nongnu.org/support/?109024 OBS-URL: https://build.opensuse.org/package/show/Base:System/dmidecode?expand=0&rev=35 --- ...sysfs-option-description-to-h-output.patch | 22 +++++ ...nor-dmi-entry-point-found-on-smbios3.patch | 44 +++++++++ ...ead_file-return-the-actual-data-size.patch | 90 +++++++++++++++++++ ...ile-to-read-the-dmi-table-from-sysfs.patch | 67 ++++++++++++++ ...ucture-table-maximum-size-in-smbios3.patch | 29 ++++++ ...ode-06-hide-irrelevant-fixup-message.patch | 49 ++++++++++ dmidecode.changes | 18 ++++ dmidecode.spec | 14 ++- 8 files changed, 332 insertions(+), 1 deletion(-) create mode 100644 dmidecode-01-add-no-sysfs-option-description-to-h-output.patch create mode 100644 dmidecode-02-fix-no-smbios-nor-dmi-entry-point-found-on-smbios3.patch create mode 100644 dmidecode-03-let-read_file-return-the-actual-data-size.patch create mode 100644 dmidecode-04-use-read_file-to-read-the-dmi-table-from-sysfs.patch create mode 100644 dmidecode-05-use-dword-for-structure-table-maximum-size-in-smbios3.patch create mode 100644 dmidecode-06-hide-irrelevant-fixup-message.patch diff --git a/dmidecode-01-add-no-sysfs-option-description-to-h-output.patch b/dmidecode-01-add-no-sysfs-option-description-to-h-output.patch new file mode 100644 index 0000000..8f54639 --- /dev/null +++ b/dmidecode-01-add-no-sysfs-option-description-to-h-output.patch @@ -0,0 +1,22 @@ +From: Roy Franz +Date: Thu, 1 Oct 2015 08:41:43 +0200 +Subject: Add "--no-sysfs" option description to -h output +Git-commit: 33b5aafc6ee6b5de9f2526fb1cf4b14d1e16e4f0 + +A description of --no-sysfs was not added to the output of "-h" when +the feature was added, so add it now. + +--- + dmiopt.c | 1 + + 1 file changed, 1 insertion(+) + +--- dmidecode-3.0.orig/dmiopt.c 2016-05-03 16:05:03.135840902 +0200 ++++ dmidecode-3.0/dmiopt.c 2016-05-03 16:05:04.199850803 +0200 +@@ -314,6 +314,7 @@ void print_help(void) + " -u, --dump Do not decode the entries\n" + " --dump-bin FILE Dump the DMI data to a binary file\n" + " --from-dump FILE Read the DMI data from a binary file\n" ++ " --no-sysfs Do not attempt to read DMI data from sysfs files\n" + " -V, --version Display the version and exit\n"; + + printf("%s", help); diff --git a/dmidecode-02-fix-no-smbios-nor-dmi-entry-point-found-on-smbios3.patch b/dmidecode-02-fix-no-smbios-nor-dmi-entry-point-found-on-smbios3.patch new file mode 100644 index 0000000..e343478 --- /dev/null +++ b/dmidecode-02-fix-no-smbios-nor-dmi-entry-point-found-on-smbios3.patch @@ -0,0 +1,44 @@ +From: Xie XiuQi +Date: Wed, 21 Oct 2015 15:12:50 +0200 +Subject: Fix 'No SMBIOS nor DMI entry point found' on SMBIOS3 +Git-commit: bf7bad24ce141dab5b5acc3ffb98ce5fe4a8e0f9 + +address_from_efi may return a SMBIOS or SMBIOS3 format entry +point, so add this condition. + +--- + AUTHORS | 1 + + dmidecode.c | 12 ++++++++++-- + 2 files changed, 11 insertions(+), 2 deletions(-) + +--- dmidecode-3.0.orig/AUTHORS 2016-05-03 16:05:03.118840743 +0200 ++++ dmidecode-3.0/AUTHORS 2016-05-03 16:05:07.803884342 +0200 +@@ -19,6 +19,7 @@ Jarod Wilson + Anton Arapov + Roy Franz + Tyler Bell ++Xie XiuQi + + MANY THANKS TO (IN CHRONOLOGICAL ORDER) + Werner Heuser +--- dmidecode-3.0.orig/dmidecode.c 2016-05-03 16:05:03.118840743 +0200 ++++ dmidecode-3.0/dmidecode.c 2016-05-03 16:05:07.804884352 +0200 +@@ -4864,8 +4864,16 @@ int main(int argc, char * const argv[]) + goto exit_free; + } + +- if (smbios_decode(buf, opt.devmem, 0)) +- found++; ++ if (memcmp(buf, "_SM3_", 5) == 0) ++ { ++ if (smbios3_decode(buf, opt.devmem, 0)) ++ found++; ++ } ++ else if (memcmp(buf, "_SM_", 4) == 0) ++ { ++ if (smbios_decode(buf, opt.devmem, 0)) ++ found++; ++ } + goto done; + + memory_scan: diff --git a/dmidecode-03-let-read_file-return-the-actual-data-size.patch b/dmidecode-03-let-read_file-return-the-actual-data-size.patch new file mode 100644 index 0000000..a799c48 --- /dev/null +++ b/dmidecode-03-let-read_file-return-the-actual-data-size.patch @@ -0,0 +1,90 @@ +From: Jean Delvare +Date: Mon, 2 Nov 2015 09:45:26 +0100 +Subject: Let read_file return the actual data size +Git-commit: de9a74e1c60210bee229fcf55b1678a99d1b44dd + +Let read_file return the actual data size to the caller. This gives +the caller the possibility to check that the data size is as expected +and large enough for the purpose, and report to the user if not. + +--- + dmidecode.c | 4 +++- + util.c | 11 +++++++---- + util.h | 2 +- + 3 files changed, 11 insertions(+), 6 deletions(-) + +--- dmidecode-3.0.orig/dmidecode.c 2016-05-03 16:05:07.804884352 +0200 ++++ dmidecode-3.0/dmidecode.c 2016-05-03 16:05:09.139896776 +0200 +@@ -4748,6 +4748,7 @@ int main(int argc, char * const argv[]) + int ret = 0; /* Returned value */ + int found = 0; + off_t fp; ++ size_t size; + int efi; + u8 *buf; + +@@ -4817,8 +4818,9 @@ int main(int argc, char * const argv[]) + * contain one of several types of entry points, so read enough for + * the largest one, then determine what type it contains. + */ ++ size = 0x20; + if (!(opt.flags & FLAG_NO_SYSFS) +- && (buf = read_file(0x20, SYS_ENTRY_FILE)) != NULL) ++ && (buf = read_file(&size, SYS_ENTRY_FILE)) != NULL) + { + if (!(opt.flags & FLAG_QUIET)) + printf("Getting SMBIOS data from sysfs.\n"); +--- dmidecode-3.0.orig/util.c 2016-05-03 16:05:03.085840436 +0200 ++++ dmidecode-3.0/util.c 2016-05-03 16:05:09.139896776 +0200 +@@ -94,10 +94,11 @@ int checksum(const u8 *buf, size_t len) + * needs to be freed by the caller. + * This provides a similar usage model to mem_chunk() + * +- * Returns pointer to buffer of max_len bytes, or NULL on error ++ * Returns pointer to buffer of max_len bytes, or NULL on error, and ++ * sets max_len to the length actually read. + * + */ +-void *read_file(size_t max_len, const char *filename) ++void *read_file(size_t *max_len, const char *filename) + { + int fd; + size_t r2 = 0; +@@ -115,7 +116,7 @@ void *read_file(size_t max_len, const ch + return(NULL); + } + +- if ((p = malloc(max_len)) == NULL) ++ if ((p = malloc(*max_len)) == NULL) + { + perror("malloc"); + return NULL; +@@ -123,7 +124,7 @@ void *read_file(size_t max_len, const ch + + do + { +- r = read(fd, p + r2, max_len - r2); ++ r = read(fd, p + r2, *max_len - r2); + if (r == -1) + { + if (errno != EINTR) +@@ -140,6 +141,8 @@ void *read_file(size_t max_len, const ch + while (r != 0); + + close(fd); ++ *max_len = r2; ++ + return p; + } + +--- dmidecode-3.0.orig/util.h 2016-05-03 16:05:03.085840436 +0200 ++++ dmidecode-3.0/util.h 2016-05-03 16:05:09.139896776 +0200 +@@ -25,7 +25,7 @@ + #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) + + int checksum(const u8 *buf, size_t len); +-void *read_file(size_t len, const char *filename); ++void *read_file(size_t *len, const char *filename); + void *mem_chunk(off_t base, size_t len, const char *devmem); + int write_dump(size_t base, size_t len, const void *data, const char *dumpfile, int add); + u64 u64_range(u64 start, u64 end); diff --git a/dmidecode-04-use-read_file-to-read-the-dmi-table-from-sysfs.patch b/dmidecode-04-use-read_file-to-read-the-dmi-table-from-sysfs.patch new file mode 100644 index 0000000..c2a4c16 --- /dev/null +++ b/dmidecode-04-use-read_file-to-read-the-dmi-table-from-sysfs.patch @@ -0,0 +1,67 @@ +From: Jean Delvare +Date: Mon, 2 Nov 2015 09:45:31 +0100 +Subject: dmidecode: Use read_file() to read the DMI table from sysfs +Git-commit: 364055211b1956539c6a6268e111e244e1292c8c +References: https://savannah.nongnu.org/bugs/?46176 + +We shouldn't use mem_chunk() to read the DMI table from sysfs. This +will fail for SMBIOS v3 implementations which specify a maximum length +for the table rather than its exact length. The kernel will trim the +table to the actual length, so the DMI file will be shorter than the +length announced in entry point. + +read_file() fits the bill in this case, as it deals with end of file +nicely. + +This also helps with corrupted DMI tables, as the kernel will not +export the part of the table that it wasn't able to parse, effectively +trimming it. + +This fixes bug #46176: +https://savannah.nongnu.org/bugs/?46176 +Unexpected end of file error + +--- + dmidecode.c | 29 +++++++++++++++++++++-------- + 1 file changed, 21 insertions(+), 8 deletions(-) + +--- dmidecode-3.0.orig/dmidecode.c 2016-05-03 16:05:09.139896776 +0200 ++++ dmidecode-3.0/dmidecode.c 2016-05-03 16:05:10.336907916 +0200 +@@ -4521,16 +4521,29 @@ static void dmi_table(off_t base, u32 le + printf("\n"); + } + +- /* +- * When we are reading the DMI table from sysfs, we want to print +- * the address of the table (done above), but the offset of the +- * data in the file is 0. When reading from /dev/mem, the offset +- * in the file is the address. +- */ + if (flags & FLAG_NO_FILE_OFFSET) +- base = 0; ++ { ++ /* ++ * When reading from sysfs, the file may be shorter than ++ * announced. For SMBIOS v3 this is expcted, as we only know ++ * the maximum table size, not the actual table size. For older ++ * implementations (and for SMBIOS v3 too), this would be the ++ * result of the kernel truncating the table on parse error. ++ */ ++ size_t size = len; ++ buf = read_file(&size, devmem); ++ if (!(opt.flags & FLAG_QUIET) && num && size != (size_t)len) ++ { ++ printf("Wrong DMI structures length: %u bytes " ++ "announced, only %lu bytes available.\n", ++ len, (unsigned long)size); ++ } ++ len = size; ++ } ++ else ++ buf = mem_chunk(base, len, devmem); + +- if ((buf = mem_chunk(base, len, devmem)) == NULL) ++ if (buf == NULL) + { + fprintf(stderr, "Table is unreachable, sorry." + #ifndef USE_MMAP diff --git a/dmidecode-05-use-dword-for-structure-table-maximum-size-in-smbios3.patch b/dmidecode-05-use-dword-for-structure-table-maximum-size-in-smbios3.patch new file mode 100644 index 0000000..ad6bb6e --- /dev/null +++ b/dmidecode-05-use-dword-for-structure-table-maximum-size-in-smbios3.patch @@ -0,0 +1,29 @@ +From: Xie XiuQi +Date: Mon, 1 Feb 2016 09:30:31 +0100 +Subject: Use DWORD for Structure table maximum size in SMBIOS3 +Git-commit: ab02b117511230e46bbef7febbd854b9c832c13c + +0Ch DWORD "Structure table maximum size" + +Maximum size of SMBIOS Structure Table, pointed to by +the Structure Table Address, in bytes. The actual size is +guaranteed to be less or equal to the maximum size. + +Signed-off-by: Xie XiuQi +Signed-off-by: Jean Delvare + +--- + dmidecode.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- dmidecode-3.0.orig/dmidecode.c 2016-05-03 16:05:10.336907916 +0200 ++++ dmidecode-3.0/dmidecode.c 2016-05-03 16:05:11.533919057 +0200 +@@ -4612,7 +4612,7 @@ static int smbios3_decode(u8 *buf, const + } + + dmi_table(((off_t)offset.h << 32) | offset.l, +- WORD(buf + 0x0C), 0, ver, devmem, flags | FLAG_STOP_AT_EOT); ++ DWORD(buf + 0x0C), 0, ver, devmem, flags | FLAG_STOP_AT_EOT); + + if (opt.flags & FLAG_DUMP_BIN) + { diff --git a/dmidecode-06-hide-irrelevant-fixup-message.patch b/dmidecode-06-hide-irrelevant-fixup-message.patch new file mode 100644 index 0000000..ebc48e6 --- /dev/null +++ b/dmidecode-06-hide-irrelevant-fixup-message.patch @@ -0,0 +1,49 @@ +From: Jean Delvare +Date: Tue, 3 May 2016 15:32:21 +0200 +Subject: dmidecode: Hide irrelevant fixup message +Git-commit: cff11afa886a0147d734b650755d232b5e7f2099 +References: http://savannah.nongnu.org/support/?109024 + +Only display the message about type 34 length fixup if the entry in +question is going to be displayed. Otherwise it's only confusing. + +This fixes bug #109024: +http://savannah.nongnu.org/support/?109024 + +Fixes: 3f70b3515d91 ("dmidecode: Fix up invalid DMI type 34 structure length") + +--- + dmidecode.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +--- dmidecode-3.0.orig/dmidecode.c 2016-05-03 16:05:11.533919057 +0200 ++++ dmidecode-3.0/dmidecode.c 2016-05-03 16:05:13.223934786 +0200 +@@ -2946,7 +2946,7 @@ static void dmi_64bit_memory_error_addre + * first 5 characters of the device name to be trimmed. It's easy to + * check and fix, so do it, but warn. + */ +-static void dmi_fixup_type_34(struct dmi_header *h) ++static void dmi_fixup_type_34(struct dmi_header *h, int display) + { + u8 *p = h->data; + +@@ -2954,7 +2954,9 @@ static void dmi_fixup_type_34(struct dmi + if (h->length == 0x10 + && is_printable(p + 0x0B, 0x10 - 0x0B)) + { +- printf("Invalid entry length (%u). Fixed up to %u.\n", 0x10, 0x0B); ++ if (!(opt.flags & FLAG_QUIET) && display) ++ printf("Invalid entry length (%u). Fixed up to %u.\n", ++ 0x10, 0x0B); + h->length = 0x0B; + } + } +@@ -4443,7 +4445,7 @@ static void dmi_table_decode(u8 *buf, u3 + + /* Fixup a common mistake */ + if (h.type == 34) +- dmi_fixup_type_34(&h); ++ dmi_fixup_type_34(&h, display); + + /* look for the next handle */ + next = data + h.length; diff --git a/dmidecode.changes b/dmidecode.changes index 7419bde..75e3867 100644 --- a/dmidecode.changes +++ b/dmidecode.changes @@ -1,3 +1,21 @@ +------------------------------------------------------------------- +Tue May 3 14:10:41 UTC 2016 - jdelvare@suse.de + +- dmidecode-01-add-no-sysfs-option-description-to-h-output.patch: + Add "--no-sysfs" option description to -h output. +- dmidecode-02-fix-no-smbios-nor-dmi-entry-point-found-on-smbios3.patch: + Fix 'No SMBIOS nor DMI entry point found' on SMBIOS3. +- dmidecode-03-let-read_file-return-the-actual-data-size.patch: + Let read_file return the actual data size. +- dmidecode-04-use-read_file-to-read-the-dmi-table-from-sysfs.patch: + Use read_file() to read the DMI table from sysfs. + https://savannah.nongnu.org/bugs/?46176 +- dmidecode-05-use-dword-for-structure-table-maximum-size-in-smbios3.patch: + Use DWORD for Structure table maximum size in SMBIOS3. +- dmidecode-06-hide-irrelevant-fixup-message.patch: + Hide irrelevant fixup message. + http://savannah.nongnu.org/support/?109024 + ------------------------------------------------------------------- Thu Sep 3 10:57:15 CEST 2015 - jdelvare@suse.de diff --git a/dmidecode.spec b/dmidecode.spec index 17465cb..bbbf12e 100644 --- a/dmidecode.spec +++ b/dmidecode.spec @@ -1,7 +1,7 @@ # # spec file for package dmidecode # -# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -28,6 +28,12 @@ Source1: http://download.savannah.gnu.org/releases/%{name}/%{name}-%{vers # would be, but tarball is signed by someone else without signatures. # https://savannah.nongnu.org/project/memberlist-gpgkeys.php?group=dmidecode # Source2: %{name}.keyring +Patch1: dmidecode-01-add-no-sysfs-option-description-to-h-output.patch +Patch2: dmidecode-02-fix-no-smbios-nor-dmi-entry-point-found-on-smbios3.patch +Patch3: dmidecode-03-let-read_file-return-the-actual-data-size.patch +Patch4: dmidecode-04-use-read_file-to-read-the-dmi-table-from-sysfs.patch +Patch5: dmidecode-05-use-dword-for-structure-table-maximum-size-in-smbios3.patch +Patch6: dmidecode-06-hide-irrelevant-fixup-message.patch Provides: pmtools:%{_sbindir}/dmidecode Obsoletes: pmtools < 20071117 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -50,6 +56,12 @@ the BIOS told it to. %prep %setup -q +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 +%patch6 -p1 %build make CFLAGS="%{optflags}" %{?_smp_mflags}