import crash-gcore-command-1.6.3-1.el8

This commit is contained in:
CentOS Sources 2022-05-10 03:07:53 -04:00 committed by Stepan Oksanichenko
parent 5976cdabf9
commit 8514795669
7 changed files with 260 additions and 21 deletions

View File

@ -1 +1 @@
ccea791bec2229bdf1d164bc6773d8ce5597024c SOURCES/crash-gcore-command-1.6.0.tar.gz
70f9352418f658080e988d5b7e7d3b4ce6a98f99 SOURCES/crash-gcore-command-1.6.3.tar.gz

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/crash-gcore-command-1.6.0.tar.gz
SOURCES/crash-gcore-command-1.6.3.tar.gz

View File

@ -0,0 +1,53 @@
From 4731ebf085fe6322ba8c7ca14918d3cab2186cf0 Mon Sep 17 00:00:00 2001
From: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
Date: Fri, 25 Feb 2022 04:45:37 -0500
Subject: [PATCH 1/3] coredump: use MEMBER_{OFFSET, SIZE} instead of
GCORE_{OFFSET, SIZE}
fill_auxv_note() and compat_fill_auxv_note() is called just once each
time gcore command is invoked because each process has just one
NT_AUXV. This means using MEMBER_{OFFSET, SIZE} is enough; using
GCORE_{OFFSET, SIZE} is overkill.
Signed-off-by: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
---
src/libgcore/gcore_coredump.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/libgcore/gcore_coredump.c b/src/libgcore/gcore_coredump.c
index 3d0c0fcce61e..6f57b21b62b6 100644
--- a/src/libgcore/gcore_coredump.c
+++ b/src/libgcore/gcore_coredump.c
@@ -930,11 +930,11 @@ fill_auxv_note(struct elf_note_info *info, struct task_context *tc,
ulong *auxv;
int i;
- auxv = (ulong *)GETBUF(GCORE_SIZE(mm_struct_saved_auxv));
+ auxv = (ulong *)GETBUF(MEMBER_SIZE("mm_struct", "saved_auxv"));
readmem(task_mm(tc->task, FALSE) +
- GCORE_OFFSET(mm_struct_saved_auxv), KVADDR, auxv,
- GCORE_SIZE(mm_struct_saved_auxv), "fill_auxv_note",
+ MEMBER_OFFSET("mm_struct", "saved_auxv"), KVADDR, auxv,
+ MEMBER_SIZE("mm_struct", "saved_auxv"), "fill_auxv_note",
gcore_verbose_error_handle());
i = 0;
@@ -956,11 +956,11 @@ compat_fill_auxv_note(struct elf_note_info *info,
uint32_t *auxv;
int i;
- auxv = (uint32_t *)GETBUF(GCORE_SIZE(mm_struct_saved_auxv));
+ auxv = (uint32_t *)GETBUF(MEMBER_SIZE("mm_struct", "saved_auxv"));
readmem(task_mm(tc->task, FALSE) +
- GCORE_OFFSET(mm_struct_saved_auxv), KVADDR, auxv,
- GCORE_SIZE(mm_struct_saved_auxv), "fill_auxv_note32",
+ MEMBER_OFFSET("mm_struct", "saved_auxv"), KVADDR, auxv,
+ MEMBER_SIZE("mm_struct", "saved_auxv"), "fill_auxv_note32",
gcore_verbose_error_handle());
i = 0;
--
2.30.2

View File

@ -0,0 +1,59 @@
From 6f4357340807f70bd1999f0b88435361c583f0b9 Mon Sep 17 00:00:00 2001
From: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
Date: Fri, 25 Feb 2022 04:51:06 -0500
Subject: [PATCH 2/3] gcore, defs: remove definitions and initializations for
saved_auxv entries of offset and size tables
saved_auxv entries of offset and size tables are now not used in the
source code by the previous commit. Let's remove definitions and
initializations for them.
Signed-off-by: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
---
src/gcore.c | 2 --
src/libgcore/gcore_defs.h | 2 --
2 files changed, 4 deletions(-)
diff --git a/src/gcore.c b/src/gcore.c
index 5b78d9980887..f86b15f8a9f6 100644
--- a/src/gcore.c
+++ b/src/gcore.c
@@ -371,7 +371,6 @@ static void gcore_offset_table_init(void)
GCORE_MEMBER_OFFSET_INIT(mm_struct_arg_end, "mm_struct", "arg_end");
GCORE_MEMBER_OFFSET_INIT(mm_struct_map_count, "mm_struct", "map_count");
GCORE_MEMBER_OFFSET_INIT(mm_struct_reserved_vm, "mm_struct", "reserved_vm");
- GCORE_MEMBER_OFFSET_INIT(mm_struct_saved_auxv, "mm_struct", "saved_auxv");
GCORE_MEMBER_OFFSET_INIT(mm_struct_saved_files, "mm_struct", "saved_files");
GCORE_MEMBER_OFFSET_INIT(mm_struct_context, "mm_struct", "context");
GCORE_MEMBER_OFFSET_INIT(pid_level, "pid", "level");
@@ -520,7 +519,6 @@ static void gcore_size_table_init(void)
{
GCORE_STRUCT_SIZE_INIT(i387_union, "i387_union");
GCORE_STRUCT_SIZE_INIT(mm_context_t, "mm_context_t");
- GCORE_MEMBER_SIZE_INIT(mm_struct_saved_auxv, "mm_struct", "saved_auxv");
GCORE_MEMBER_SIZE_INIT(mm_struct_saved_files, "mm_struct", "saved_files");
GCORE_MEMBER_SIZE_INIT(thread_struct_ds, "thread_struct", "ds");
GCORE_MEMBER_SIZE_INIT(thread_struct_es, "thread_struct", "es");
diff --git a/src/libgcore/gcore_defs.h b/src/libgcore/gcore_defs.h
index df87851d23a1..3233ea533ca0 100644
--- a/src/libgcore/gcore_defs.h
+++ b/src/libgcore/gcore_defs.h
@@ -1072,7 +1072,6 @@ struct gcore_offset_table
long mm_struct_arg_end;
long mm_struct_map_count;
long mm_struct_reserved_vm;
- long mm_struct_saved_auxv;
long mm_struct_saved_files;
long mm_struct_context;
long pid_level;
@@ -1148,7 +1147,6 @@ struct gcore_offset_table
struct gcore_size_table
{
long mm_context_t;
- long mm_struct_saved_auxv;
long mm_struct_saved_files;
long thread_struct_ds;
long thread_struct_es;
--
2.30.2

View File

@ -0,0 +1,128 @@
From 4cb65a0d9168778d120920418b968d05da10989f Mon Sep 17 00:00:00 2001
From: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
Date: Fri, 25 Feb 2022 04:59:48 -0500
Subject: [PATCH 3/3] gcore: fix memory allocation failure during processing
NT_AUXV note
For crash dumps generated using kernel-4.18.0-365.el8 or later on
CentOS stream 8, crash gcore command fails as follows:
crash> gcore -v 7 -f 128 10604
gcore: Opening file core.10604.test-dumpfilter ...
gcore: done.
gcore: Writing ELF header ...
gcore: done.
gcore: Retrieving and writing note information ...
gcore: zero-size memory allocation! (called from 7fd558ce1e05)
Failed.
This memory allocation failure occurs in fill_auxv_note() that creates
NT_AUXV note due to saved_auxv entries of size and offset tables are
somehow 0.
This is because during the merge of the upstream kernel commit
1c33bb0507508af24fd754dd7123bd8e997fab2f (x86/elf: Support a new ELF
aux vector AT_MINSIGSTKSZ), location of saved_auxv of struct mm_struct
has been moved as workaround in order to avoid kABI breakage.
Fix this by using RHEL-specific location for saved_auxv if there is
member rh_reserved_saved_auxv in struct mm_struct.
Signed-off-by: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
---
src/libgcore/gcore_coredump.c | 54 +++++++++++++++++++++++++++++------
1 file changed, 46 insertions(+), 8 deletions(-)
diff --git a/src/libgcore/gcore_coredump.c b/src/libgcore/gcore_coredump.c
index 6f57b21b62b6..c14cc116e951 100644
--- a/src/libgcore/gcore_coredump.c
+++ b/src/libgcore/gcore_coredump.c
@@ -18,6 +18,10 @@
static struct elf_note_info *elf_note_info_init(void);
+static void get_auxv_size_addr(struct task_context *tc,
+ size_t *size,
+ ulong *addr);
+
static void fill_prstatus_note(struct elf_note_info *info,
struct task_context *tc,
struct memelfnote *memnote);
@@ -923,18 +927,49 @@ compat_fill_prstatus_note(struct elf_note_info *info,
#endif /* GCORE_ARCH_COMPAT */
+static void get_auxv_size_addr(struct task_context *tc,
+ size_t *psize,
+ ulong *paddr)
+{
+ size_t size;
+ ulong addr;
+
+ if (MEMBER_EXISTS("mm_struct", "rh_reserved_saved_auxv")) {
+ ulong mm_rh;
+
+ size = MEMBER_SIZE("mm_struct_rh", "saved_auxv");
+ readmem(task_mm(tc->task, FALSE) + MEMBER_OFFSET("mm_struct", "mm_rh"),
+ KVADDR,
+ &mm_rh,
+ sizeof(mm_rh),
+ "mm_struct mm_rh",
+ gcore_verbose_error_handle());
+ addr = mm_rh + MEMBER_OFFSET("mm_struct_rh", "saved_auxv");
+ } else {
+ size = MEMBER_SIZE("mm_struct", "saved_auxv");
+ addr = task_mm(tc->task, FALSE) +
+ MEMBER_OFFSET("mm_struct", "saved_auxv");
+ }
+
+ *psize = size;
+ *paddr = addr;
+}
+
static void
fill_auxv_note(struct elf_note_info *info, struct task_context *tc,
struct memelfnote *memnote)
{
ulong *auxv;
+ ulong addr;
+ size_t size;
int i;
- auxv = (ulong *)GETBUF(MEMBER_SIZE("mm_struct", "saved_auxv"));
+ get_auxv_size_addr(tc, &size, &addr);
- readmem(task_mm(tc->task, FALSE) +
- MEMBER_OFFSET("mm_struct", "saved_auxv"), KVADDR, auxv,
- MEMBER_SIZE("mm_struct", "saved_auxv"), "fill_auxv_note",
+ auxv = (ulong *)GETBUF(size);
+
+ readmem(addr, KVADDR, auxv,
+ size, "fill_auxv_note",
gcore_verbose_error_handle());
i = 0;
@@ -954,13 +989,16 @@ compat_fill_auxv_note(struct elf_note_info *info,
struct memelfnote *memnote)
{
uint32_t *auxv;
+ ulong addr;
+ size_t size;
int i;
- auxv = (uint32_t *)GETBUF(MEMBER_SIZE("mm_struct", "saved_auxv"));
+ get_auxv_size_addr(tc, &size, &addr);
+
+ auxv = (uint32_t *)GETBUF(size);
- readmem(task_mm(tc->task, FALSE) +
- MEMBER_OFFSET("mm_struct", "saved_auxv"), KVADDR, auxv,
- MEMBER_SIZE("mm_struct", "saved_auxv"), "fill_auxv_note32",
+ readmem(addr, KVADDR, auxv,
+ size, "fill_auxv_note32",
gcore_verbose_error_handle());
i = 0;
--
2.30.2

View File

@ -1,11 +0,0 @@
--- crash-gcore-command-1.3.1/gcore.mk.orig
+++ crash-gcore-command-1.3.1/gcore.mk
@@ -102,7 +102,7 @@ gcore.so: gcore.c $(INCDIR)/defs.h
echo "gcore: architecture not supported"; \
else \
make -f gcore.mk $(GCORE_OFILES) && \
- gcc $(RPM_OPT_FLAGS) $(CFLAGS) $(TARGET_CFLAGS) $(COMMON_CFLAGS) $(ARCH_CFLAGS) -nostartfiles -shared -rdynamic $(GCORE_OFILES) -o $@ $< ; \
+ gcc $(RPM_OPT_FLAGS) $(CFLAGS) $(TARGET_CFLAGS) $(COMMON_CFLAGS) $(ARCH_CFLAGS) -nostartfiles -shared -rdynamic $(GCORE_OFILES) -Wl,-z,now -o $@ $< ; \
fi;
%.o: %.c $(INCDIR)/defs.h

View File

@ -1,14 +1,15 @@
#
# crash core analysis suite
#
%global reponame crash-gcore
Summary: Gcore extension module for the crash utility
Name: crash-gcore-command
Version: 1.6.0
Version: 1.6.3
Release: 1%{?dist}
License: GPLv2
Group: Development/Debuggers
Source: https://github.com/crash-utility/crash-extensions/blob/master/%{name}-%{version}.tar.gz
URL: https://crash-utility.github.io/extensions.html
Source: https://github.com/fujitsu/crash-gcore/archive/v%{version}/%{name}-%{version}.tar.gz
URL: https://github.com/fujitsu/crash-gcore
# Vendor: FUJITSU LIMITED
# Packager: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
ExclusiveOS: Linux
@ -16,23 +17,27 @@ ExclusiveArch: x86_64 %{ix86} arm aarch64 ppc64 ppc64le
Buildroot: %{_tmppath}/%{name}-root
BuildRequires: crash-devel >= 5.1.5, zlib-devel lzo-devel snappy-devel
Requires: crash >= 5.1.5
Patch0: rhel8_build.patch
Patch0: 0001-coredump-use-MEMBER_-OFFSET-SIZE-instead-of-GCORE_-O.patch
Patch1: 0002-gcore-defs-remove-definitions-and-initializations-fo.patch
Patch2: 0003-gcore-fix-memory-allocation-failure-during-processin.patch
%description
Command for creating a core dump file of a user-space task that was
running in a kernel dumpfile.
%prep
%setup -q -n %{name}-%{version}
%patch0 -p1 -b rhel8_build.patch
%setup -q -n %{reponame}-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%build
make -f gcore.mk
make CFLAGS="%{optflags} -Wl,-z,now" -C src -f gcore.mk
%install
rm -Rf $RPM_BUILD_ROOT
mkdir -p %{buildroot}%{_libdir}/crash/extensions/
cp %{_builddir}/%{name}-%{version}/gcore.so %{buildroot}%{_libdir}/crash/extensions/
cp %{_builddir}/%{reponame}-%{version}/src/gcore.so %{buildroot}%{_libdir}/crash/extensions/
%clean
rm -rf %{buildroot}
@ -44,6 +49,11 @@ rm -Rf $RPM_BUILD_ROOT
%doc COPYING
%changelog
* Mon Feb 28 2022 Lianbo Jiang <lijiang@redhat.com> - 1.6.3-1
- Rebase to upstream crash-gcore-command-1.6.3
- Fix memory allocation failure issue
- Resolves: rhbz#2054066
* Wed Dec 2 2020 Bhupesh Sharma <bhsharma@redhat.com> - 1.6.0-1
- Rebase crash-gcore-command to github upstream version crash-gcore-command-1.6.0
Resolves: rhbz#1903465