From 520742f47cd6a80309741d74573832855e7105fb2f59ffb589d1327809746390 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 27 Apr 2023 10:57:57 +0000 Subject: [PATCH] Fix a potential regression: - use-read_file-to-read-from-dump.patch: Fix an old harmless bug which would prevent root from using the --from-dump option since the latest security fixes. OBS-URL: https://build.opensuse.org/package/show/Base:System/dmidecode?expand=0&rev=71 --- dmidecode.changes | 8 ++++ dmidecode.spec | 2 + use-read_file-to-read-from-dump.patch | 58 +++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 use-read_file-to-read-from-dump.patch diff --git a/dmidecode.changes b/dmidecode.changes index 08a3ce4..8f5652d 100644 --- a/dmidecode.changes +++ b/dmidecode.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Thu Apr 27 10:55:57 UTC 2023 - Jean Delvare + +Fix a potential regression: +- use-read_file-to-read-from-dump.patch: Fix an old harmless bug + which would prevent root from using the --from-dump option since + the latest security fixes. + ------------------------------------------------------------------- Mon Apr 3 10:04:57 UTC 2023 - Jean Delvare diff --git a/dmidecode.spec b/dmidecode.spec index 1af3b31..325a04c 100644 --- a/dmidecode.spec +++ b/dmidecode.spec @@ -29,6 +29,7 @@ Source1: http://download.savannah.gnu.org/releases/%{name}/%{name}-%{vers Source2: %{name}.keyring Patch1: arm-use-alignment-workaround.patch Patch2: dmioem-hpe-oem-record-237-firmware-change.patch +Patch3: use-read_file-to-read-from-dump.patch Provides: pmtools:%{_sbindir}/dmidecode Obsoletes: pmtools < 20071117 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -53,6 +54,7 @@ the BIOS told it to. %setup -q %patch1 -p1 %patch2 -p1 +%patch3 -p1 %build CFLAGS="%{optflags}" make %{?_smp_mflags} diff --git a/use-read_file-to-read-from-dump.patch b/use-read_file-to-read-from-dump.patch new file mode 100644 index 0000000..cd1cb93 --- /dev/null +++ b/use-read_file-to-read-from-dump.patch @@ -0,0 +1,58 @@ +From c76ddda0ba0aa99a55945e3290095c2ec493c892 Mon Sep 17 00:00:00 2001 +From: Jean Delvare +Date: Wed, 26 Apr 2023 15:44:27 +0200 +Subject: [PATCH] Consistently use read_file() when reading from a dump file + +Use read_file() instead of mem_chunk() to read the entry point from a +dump file. This is faster, and consistent with how we then read the +actual DMI table from that dump file. + +This made no functional difference so far, which is why it went +unnoticed for years. But now that a file type check was added to the +mem_chunk() function, we must stop using it to read from regular +files. + +This will again allow root to use the --from-dump option. + +Signed-off-by: Jean Delvare +Tested-by: Jerry Hoemann + +diff --git a/dmidecode.c b/dmidecode.c +index 54f59c163daf..52ddbf1a51bd 100644 +--- a/dmidecode.c ++++ b/dmidecode.c +@@ -6025,17 +6025,25 @@ int main(int argc, char * const argv[]) + pr_comment("dmidecode %s", VERSION); + + /* Read from dump if so instructed */ ++ size = 0x20; + if (opt.flags & FLAG_FROM_DUMP) + { + if (!(opt.flags & FLAG_QUIET)) + pr_info("Reading SMBIOS/DMI data from file %s.", + opt.dumpfile); +- if ((buf = mem_chunk(0, 0x20, opt.dumpfile)) == NULL) ++ if ((buf = read_file(0, &size, opt.dumpfile)) == NULL) + { + ret = 1; + goto exit_free; + } + ++ /* Truncated entry point can't be processed */ ++ if (size < 0x20) ++ { ++ ret = 1; ++ goto done; ++ } ++ + if (memcmp(buf, "_SM3_", 5) == 0) + { + if (smbios3_decode(buf, opt.dumpfile, 0)) +@@ -6059,7 +6067,6 @@ 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(0, &size, SYS_ENTRY_FILE)) != NULL) + {