fix crash on fseek/ftell of stdout (27-2)

- add 0001-depmod-do-not-output-.bin-to-stdout.patch
  Resolves: rhbz#1808430

Signed-off-by: Yauheni Kaliuta <ykaliuta@fedoraproject.org>
This commit is contained in:
Yauheni Kaliuta 2020-03-25 09:55:48 +02:00
parent 1988940ee7
commit f1da57f289
2 changed files with 61 additions and 1 deletions

View File

@ -0,0 +1,53 @@
From 53b30aeba2dedae9f5558f560231d9462e063dfc Mon Sep 17 00:00:00 2001
From: Lucas De Marchi <lucas.demarchi@intel.com>
Date: Thu, 5 Mar 2020 13:33:10 -0800
Subject: [PATCH] depmod: do not output .bin to stdout
index_write() relies on fseek/ftell to manage the position to which we
are write and thus needs the file stream to support it.
Right now when trying to write the index to stdout we fail with:
depmod: tools/depmod.c:416: index_write: Assertion `initial_offset >= 0' failed.
Aborted (core dumped)
We have no interest in outputting our index to stdout, so just skip it
like is done with other indexes.
While at it, add/remove some newlines to improve readability.
Reported-by: Yanko Kaneti <yaneti@declera.com>
Fix: b866b2165ae6 ("Lookup aliases in the modules.builtin.modinfo")
---
tools/depmod.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/depmod.c b/tools/depmod.c
index fbbce10eb0db..875e31480818 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -2408,8 +2408,10 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)
struct index_node *idx;
struct kmod_list *l, *builtin = NULL;
- idx = index_create();
+ if (out == stdout)
+ return 0;
+ idx = index_create();
if (idx == NULL) {
ret = -ENOMEM;
goto fail;
@@ -2456,7 +2458,9 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)
if (count)
index_write(idx, out);
+
index_destroy(idx);
+
fail:
if (builtin)
kmod_module_unref_list(builtin);
--
2.25.0

View File

@ -1,6 +1,6 @@
Name: kmod Name: kmod
Version: 27 Version: 27
Release: 1%{?dist} Release: 2%{?dist}
Summary: Linux kernel module management utilities Summary: Linux kernel module management utilities
License: GPLv2+ License: GPLv2+
@ -9,6 +9,8 @@ Source0: https://www.kernel.org/pub/linux/utils/kernel/kmod/%{name}-%{version}.t
Source1: weak-modules Source1: weak-modules
Exclusiveos: Linux Exclusiveos: Linux
Patch01: 0001-depmod-do-not-output-.bin-to-stdout.patch
BuildRequires: gcc BuildRequires: gcc
BuildRequires: chrpath BuildRequires: chrpath
BuildRequires: zlib-devel BuildRequires: zlib-devel
@ -44,6 +46,7 @@ applications that wish to load or unload Linux kernel modules.
%prep %prep
%autosetup -p1 %autosetup -p1
%patch01 -p
%build %build
%configure \ %configure \
@ -104,6 +107,10 @@ install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_sbindir}/weak-modules
%{_libdir}/libkmod.so %{_libdir}/libkmod.so
%changelog %changelog
* Wed Mar 25 2020 Yauheni Kaliuta <ykaliuta@fedoraproject.org> - 27-2
- add 0001-depmod-do-not-output-.bin-to-stdout.patch
Resolves: rhbz#1808430
* Thu Feb 20 2020 Peter Robinson <pbrobinson@fedoraproject.org> - 27-1 * Thu Feb 20 2020 Peter Robinson <pbrobinson@fedoraproject.org> - 27-1
- New upstream v27 - New upstream v27