Compare commits

...

1 Commits
c8 ... c10

Author SHA1 Message Date
ec59492671 import OL crash-gcore-command-1.6.4-8.el10_0.1 2025-08-12 11:35:33 +00:00
14 changed files with 256 additions and 677 deletions

View File

@ -1 +1 @@
70f9352418f658080e988d5b7e7d3b4ce6a98f99 SOURCES/crash-gcore-command-1.6.3.tar.gz
2c15b78c28ef2e71307e826a5a7912346b4c4d2a SOURCES/crash-gcore-command-1.6.4.tar.gz

2
.gitignore vendored
View File

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

View File

@ -1,53 +0,0 @@
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,47 @@
From 62b8d5005eaa9014467db85cfe268e65c6679f4c Mon Sep 17 00:00:00 2001
From: Tao Liu <ltao@redhat.com>
Date: Mon, 4 Nov 2024 17:11:19 +1300
Subject: [PATCH 1/2] gcore: update set_context with upstream counterpart
With the introduction of upstream commit "Preparing for gdb stack unwind
support" [1], the function set_context() is added by a 3rd parameter. Without
this patch, the compiliation of gcore will fail.
The 3rd parameter of set_context() is used to sync the context of crash and
gdb, so gdb can hold the the value of registers of current crash's task
context, and gdb can output the stack unwinding for current task.
This have nothing to do with gcore, so simply set the 3rd parameter as FALSE.
[1]: https://github.com/lian-bo/crash/commit/d75d15d31b92f8882ccb15c960665e2c8a8d1c28
Signed-off-by: Tao Liu <ltao@redhat.com>
---
src/gcore.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/gcore.c b/src/gcore.c
index 47a9c0d..a79f69b 100644
--- a/src/gcore.c
+++ b/src/gcore.c
@@ -306,7 +306,7 @@ static void do_gcore(char *arg)
if (tc != CURRENT_CONTEXT()) {
gcore->orig_task = CURRENT_TASK();
- (void) set_context(tc->task, NO_PID);
+ (void) set_context(tc->task, NO_PID, FALSE);
}
snprintf(gcore->corename, CORENAME_MAX_SIZE + 1, "core.%lu.%s",
@@ -340,7 +340,7 @@ static void do_gcore(char *arg)
}
if (gcore->orig_task)
- (void)set_context(gcore->orig_task, NO_PID);
+ (void)set_context(gcore->orig_task, NO_PID, FALSE);
}
--
2.47.0

View File

@ -1,114 +0,0 @@
From 03f9360715731f18e4fdae7b30aa34b30dddcd57 Mon Sep 17 00:00:00 2001
From: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
Date: Sat, 26 Mar 2022 21:42:02 +0900
Subject: [PATCH 1/5] x86: Fix failure of collecting vsyscall mapping due to
change of enum type of vsyscall_mode
vsyscall mapping fails to get collected because the commit
bd49e16e3339 (x86/vsyscall: Add a new vsyscall=xonly mode) merged at
kernel v5.2-rc7 added constant XONLY to the anonymous enumeration type
of variable vsyscall_mode, which made the value of constant NONE
change from 1 to 2.
This commit fixes the issue by checking the value of constant NONE
using gdb's print command and typeof operator since there's no utility
function to handle such anonymous enumeration type currently in crash
utility.
Signed-off-by: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
---
src/libgcore/gcore_x86.c | 56 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 54 insertions(+), 2 deletions(-)
diff --git a/src/libgcore/gcore_x86.c b/src/libgcore/gcore_x86.c
index 08e573c741f6..f334a85d4240 100644
--- a/src/libgcore/gcore_x86.c
+++ b/src/libgcore/gcore_x86.c
@@ -41,6 +41,9 @@ struct gcore_x86_table
static struct gcore_x86_table gcore_x86_table;
struct gcore_x86_table *gxt = &gcore_x86_table;
+static void gdb_run_command(char *cmd, char *buf, size_t size);
+static int get_vsyscall_mode_none(void);
+
#ifdef X86_64
static ulong gcore_x86_64_get_old_rsp(int cpu);
static ulong gcore_x86_64_get_per_cpu__old_rsp(int cpu);
@@ -2367,6 +2370,54 @@ int gcore_is_arch_32bit_emulation(struct task_context *tc)
return FALSE;
}
+static void gdb_run_command(char *cmd, char *buf, size_t size)
+{
+ open_tmpfile();
+ if (!gdb_pass_through(cmd,
+ pc->tmpfile,
+ GNU_RETURN_ON_ERROR)) {
+ close_tmpfile();
+ error(FATAL, "gdb command failed: %s", cmd);
+ }
+ rewind(pc->tmpfile);
+ fgets(buf, size, pc->tmpfile);
+ close_tmpfile();
+}
+
+static int get_vsyscall_mode_none(void)
+{
+ static int none = -1;
+ char cmd[32], buf[BUFSIZE];
+ int i;
+
+ if (none != -1)
+ return none;
+
+ /*
+ * Variable vsyscall_mode is of anonymous enumeration
+ * type. Because there's no utility function in crash utility
+ * to get value of each constant in specified anonymous
+ * enumeration type, we have no choice but rely on gdb's print
+ * command in combination with typeof operator.
+ */
+ for (i = 0; i < 10; ++i) {
+ snprintf(cmd, sizeof(cmd), "p (typeof(vsyscall_mode))%d", i);
+ gdb_run_command(cmd, buf, sizeof(buf));
+ if (strstr(buf, "NONE"))
+ return none = i;
+ }
+
+ /*
+ * When the above logic doesn't work as expected, use 2, which
+ * is the value on the definition where vsyscall_mode was
+ * first introduced at the commit 3ae36655b97a (x86-64: Rework
+ * vsyscall emulation and add vsyscall= parameter).
+ */
+ none = 2;
+
+ return none;
+}
+
/**
* Return an address to gate_vma.
*/
@@ -2377,7 +2428,8 @@ ulong gcore_arch_get_gate_vma(void)
return 0UL;
if (symbol_exists("vsyscall_mode")) {
- enum { ENUMERATE, NONE } vsyscall_mode;
+ int vsyscall_mode;
+ int none = get_vsyscall_mode_none();
readmem(symbol_value("vsyscall_mode"),
KVADDR,
@@ -2386,7 +2438,7 @@ ulong gcore_arch_get_gate_vma(void)
"gcore_arch_get_gate_vma: vsyscall_mode",
gcore_verbose_error_handle());
- if (vsyscall_mode == NONE)
+ if (vsyscall_mode == none)
return 0UL;
}
--
2.37.1

View File

@ -0,0 +1,85 @@
From e03ff7341a9a624a46cea4e60ee097606b1687a8 Mon Sep 17 00:00:00 2001
From: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
Date: Sat, 23 Nov 2024 17:30:41 +0900
Subject: [PATCH] x86: fix the issue that core files for 64-bit tasks are
generated in the 32-bit format
Core files for 64-bit tasks are falsely generated in the 32-bit
formats.
The root cause of this issue is that location of saving register
values on kernel stacks is changed by the kernel commit
65c9cc9e2c14602d98f1ca61c51ac954e9529303 (x86/fred: Reserve space for
the FRED stack frame) in Linux kernel 6.9-rc1 to add some reserved
area for FRED feature and gcore doesn't take this into
consideration. Hence, the value of CS register retrieved from kernel
stacks based on the existing logic is wrong and thus checking
execution mode of a given task based on the value also works wrong.
To fix this issue, let's take the FRED feature into account. If FRED
data structure is defined, retrieve register values from the address
next to the reserved for the FRED feature.
This logic is borrowed from the commit
48764a14bc5856f0b0bb30685336c68b832154fc (x86_64: fix for adding
top_of_kernel_stack_padding for kernel stack) and the commit
196c4b79c13d1c0e6d7b21c8321eca07d3838d6a (X86 64: fix a regression
issue about kernel stack padding) of crash utility.
---
src/libgcore/gcore_x86.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/libgcore/gcore_x86.c b/src/libgcore/gcore_x86.c
index 3ddf510..4f43956 100644
--- a/src/libgcore/gcore_x86.c
+++ b/src/libgcore/gcore_x86.c
@@ -514,10 +514,11 @@ convert_from_fxsr(struct user_i387_ia32_struct *env, struct task_context *target
char *pt_regs_buf;
uint16_t ds;
struct machine_specific *ms = machdep->machspec;
+ ulong padding_size = VALID_SIZE(fred_frame) > 0 ? (2 * 8) : 0;
pt_regs_buf = GETBUF(SIZE(pt_regs));
- readmem(machdep->get_stacktop(target->task) - SIZE(pt_regs),
+ readmem(machdep->get_stacktop(target->task) - padding_size - SIZE(pt_regs),
KVADDR, pt_regs_buf, SIZE(pt_regs),
"convert_from_fxsr: regs",
gcore_verbose_error_handle());
@@ -1837,6 +1838,7 @@ static int genregs_get(struct task_context *target,
struct user_regs_struct active_regs;
const int active = is_task_active(target->task);
struct machine_specific *ms = machdep->machspec;
+ ulong padding_size = VALID_SIZE(fred_frame) > 0 ? (2 * 8) : 0;
BZERO(regs, sizeof(*regs));
@@ -1854,7 +1856,7 @@ static int genregs_get(struct task_context *target,
*/
pt_regs_buf = GETBUF(SIZE(pt_regs));
- readmem(machdep->get_stacktop(target->task) - SIZE(pt_regs), KVADDR,
+ readmem(machdep->get_stacktop(target->task) - padding_size - SIZE(pt_regs), KVADDR,
pt_regs_buf, SIZE(pt_regs), "genregs_get: pt_regs",
gcore_verbose_error_handle());
@@ -2188,6 +2190,7 @@ static int genregs_get32(struct task_context *target,
struct user_regs_struct *regs = (struct user_regs_struct *)buf;
char *pt_regs_buf;
ulonglong pt_regs_addr;
+ ulong padding_size = VALID_SIZE(fred_frame) > 0 ? (2 * 8) : 0;
if (is_task_active(target->task) && KVMDUMP_DUMPFILE()) {
get_regs_from_kvmdump_notes(target, regs);
@@ -2198,7 +2201,7 @@ static int genregs_get32(struct task_context *target,
pt_regs_buf = GETBUF(SIZE(pt_regs));
- pt_regs_addr = machdep->get_stacktop(target->task) - SIZE(pt_regs);
+ pt_regs_addr = machdep->get_stacktop(target->task) - padding_size - SIZE(pt_regs);
/*
* The commit 07b047fc2466249aff7cdb23fa0b0955a7a00d48
--
2.47.0

View File

@ -1,59 +0,0 @@
From 1ba701c1d7bd94cc5a02f51652712acdcbf0875c Mon Sep 17 00:00:00 2001
From: Vincent Whitchurch <vincent.whitchurch@axis.com>
Date: Tue, 21 Jun 2022 09:15:33 +0000
Subject: [PATCH 2/5] coredump: fix segmentation fault caused by type mismatch
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
crash gcore command on ARM sometimes results in segmentation fault:
crash> gcore -v 0
Segmentation fault (core dumped)
This is caused by type mismatch of a variable paddr in function
gcore_readmem_user() to hold a physical address, which is indicated by
the following warning message:
libgcore/gcore_coredump.c: In function gcore_readmem_user:
libgcore/gcore_coredump.c:85:26: warning: passing argument 2 of
uvtop_quiet from incompatible pointer type
[-Wincompatible-pointer-types]
if (!uvtop_quiet(addr, &paddr)) {
^~~~~~
libgcore/gcore_coredump.c:71:49: note: expected physaddr_t * {aka
long long unsigned int *} but argument is of type ulong * {aka long
unsigned int *}
static int uvtop_quiet(ulong vaddr, physaddr_t *paddr);
~~~~~~~~~~~~^~~~~
On ARM, long unsigned int has 4 byte length, while physaddr_t has 8
byte length. The mismatch causes overwriting of stack variables.
Fix this by changing the type of the variable paddr to physaddr_t.
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
---
src/libgcore/gcore_coredump.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/libgcore/gcore_coredump.c b/src/libgcore/gcore_coredump.c
index c14cc116e951..424b0a40a42b 100644
--- a/src/libgcore/gcore_coredump.c
+++ b/src/libgcore/gcore_coredump.c
@@ -78,7 +78,8 @@ readswap(ulonglong pte_val, char *buf, ulong len, ulonglong vaddr)
void gcore_readmem_user(ulong addr, void *buf, long size, char *type)
{
- ulong paddr, cnt;
+ physaddr_t paddr;
+ ulong cnt;
char *bufptr = buf;
while (size > 0) {
--
2.37.1

View File

@ -1,59 +0,0 @@
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

@ -1,66 +0,0 @@
From 8ff3de974aa9fdf8934797122dc55428ef571ab2 Mon Sep 17 00:00:00 2001
From: Vincent Whitchurch <vincent.whitchurch@axis.com>
Date: Tue, 21 Jun 2022 09:15:34 +0000
Subject: [PATCH 3/5] elf: fix warning message caused by type mismatch of
offset types
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Use loff_t consistently to fix these warnings on -m32 builds on 64-bit:
libgcore/gcore_coredump.c: In function writenote:
libgcore/gcore_coredump.c:701:58: warning: passing argument 3 of
gcore->elf->ops->write_note_header from incompatible pointer type
[-Wincompatible-pointer-types]
if (!gcore->elf->ops->write_note_header(gcore->elf, fp, foffset))
^~~~~~~
libgcore/gcore_coredump.c:701:58: note: expected off_t * {aka long
int *} but argument is of type loff_t * {aka long long int *}
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
---
src/libgcore/gcore_defs.h | 2 +-
src/libgcore/gcore_elf_struct.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/libgcore/gcore_defs.h b/src/libgcore/gcore_defs.h
index 3233ea533ca0..409678e1ad68 100644
--- a/src/libgcore/gcore_defs.h
+++ b/src/libgcore/gcore_defs.h
@@ -1232,7 +1232,7 @@ struct gcore_elf_operations
int (*write_section_header)(struct gcore_elf_struct *this, FILE *fp);
int (*write_program_header)(struct gcore_elf_struct *this, FILE *fp);
int (*write_note_header)(struct gcore_elf_struct *this, FILE *fp,
- off_t *offset);
+ loff_t *offset);
uint64_t (*get_e_phoff)(struct gcore_elf_struct *this);
uint64_t (*get_e_shoff)(struct gcore_elf_struct *this);
diff --git a/src/libgcore/gcore_elf_struct.c b/src/libgcore/gcore_elf_struct.c
index 2aca984cf90f..b31388aa7e28 100644
--- a/src/libgcore/gcore_elf_struct.c
+++ b/src/libgcore/gcore_elf_struct.c
@@ -141,7 +141,7 @@ static int elf64_write_program_header(struct gcore_elf_struct *this, FILE *fp)
}
static int elf64_write_note_header(struct gcore_elf_struct *this, FILE *fp,
- off_t *offset)
+ loff_t *offset)
{
Elf64_Nhdr *n = &((struct gcore_elf64_struct *)this)->nhdr;
@@ -314,7 +314,7 @@ static int elf32_write_program_header(struct gcore_elf_struct *this, FILE *fp)
}
static int elf32_write_note_header(struct gcore_elf_struct *this, FILE *fp,
- off_t *offset)
+ loff_t *offset)
{
Elf32_Nhdr *n = &((struct gcore_elf32_struct *)this)->nhdr;
--
2.37.1

View File

@ -1,128 +0,0 @@
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,53 +0,0 @@
From dbb542e10bfe1b2e21c7927bda9be1d301cfef65 Mon Sep 17 00:00:00 2001
From: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
Date: Fri, 17 Jun 2022 20:38:19 +0900
Subject: [PATCH 4/5] coredump: fix unexpected truncation of generated core
files
Core files generated by crash gcore command are sometimes unexpectedly
truncated. Then, we can get aware of this from the following warning
message output by gdb:
BFD: warning: /root/./core.1.systemd is truncated: expected core file size >= 43606016, found: 43597824
From the investigation, it turned out that this truncation is
occurring when there is no write() operation after the area skipped by
lseek(). Holes are generated only when there is write() operation.
To fix this issue, use ftruncate() to allocate holes explicitly.
Signed-off-by: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
---
src/libgcore/gcore_coredump.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/libgcore/gcore_coredump.c b/src/libgcore/gcore_coredump.c
index 424b0a40a42b..27086d91468b 100644
--- a/src/libgcore/gcore_coredump.c
+++ b/src/libgcore/gcore_coredump.c
@@ -331,6 +331,21 @@ void gcore_coredump(void)
}
progressf("done.\n");
+ /*
+ * Use ftruncate() to generate holes explicitly, or core file
+ * gets truncated if there is no write() operation after the
+ * area skipped by lseek().
+ */
+ if (fflush(gcore->fp))
+ error(FATAL, "%s: fflush: %s\n",
+ gcore->corename,
+ strerror(errno));
+
+ if (ftruncate(fileno(gcore->fp), ftell(gcore->fp)) < 0)
+ error(FATAL, "%s: ftruncate: %s\n",
+ gcore->corename,
+ strerror(errno));
+
gcore->flags |= GCF_SUCCESS;
}
--
2.37.1

View File

@ -1,43 +0,0 @@
From d2795659986dacc51e98a3d1dbc8b673582c20fe Mon Sep 17 00:00:00 2001
From: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
Date: Tue, 28 Jun 2022 03:54:46 +0900
Subject: [PATCH 5/5] gcore.mk: fix mismatch of _FILE_OFFSET_BITS when building
gcore.so
On arm and mips, while _FILE_OFFSET_BITS=64 is used when building
gcore.so by make extensions, it is not used by gcore.mk.
Fix this inconsistency by using _FILE_OFFSET_BITS=64 in gcore.mk on
arm and mips.
Signed-off-by: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
---
src/gcore.mk | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/gcore.mk b/src/gcore.mk
index 4af292b79c60..1fd4d84c2ded 100644
--- a/src/gcore.mk
+++ b/src/gcore.mk
@@ -32,7 +32,7 @@ endif
ifeq ($(shell arch), arm)
TARGET=ARM
- TARGET_CFLAGS=
+ TARGET_CFLAGS=-D_FILE_OFFSET_BITS=64
ARCH=SUPPORTED
endif
@@ -44,7 +44,7 @@ endif
ifeq ($(shell arch), mips)
TARGET=MIPS
- TARGET_CFLAGS=
+ TARGET_CFLAGS=-D_FILE_OFFSET_BITS=64
ARCH=SUPPORTED
endif
--
2.37.1

View File

@ -0,0 +1,59 @@
From 33f3c97f7d45c8bb1b43a8d551cb01a9873bb123 Mon Sep 17 00:00:00 2001
From: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
Date: Tue, 28 Feb 2023 03:59:16 -0500
Subject: [PATCH] coredump: fix building failure due to undefined macros
MAPLE_TREE_{COUNT,GATHER}
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
As of the commit 13794ace3830bf0274fe7b2e0e579ad72e31848f (coredump:
fix failure of executing gcore command due to introduction of maple
tree management on vma list), gcore.so fails to get built with the
following error messages with defs.h without maple tree API support:
libgcore/gcore_coredump.c:189:50: error: MAPLE_TREE_COUNT undeclared (first use in this function); did you mean RADIX_TREE_COUNT?
189 | entry_num = do_maple_tree(mm_mt, MAPLE_TREE_COUNT, NULL);
| ^~~~~~~~~~~~~~~~
| RADIX_TREE_COUNT
libgcore/gcore_coredump.c:189:50: note: each undeclared identifier is reported only once for each function it appears in
libgcore/gcore_coredump.c:191:38: error: MAPLE_TREE_GATHER undeclared (first use in this function); did you mean RADIX_TREE_GATHER?
191 | do_maple_tree(mm_mt, MAPLE_TREE_GATHER, entry_list);
| ^~~~~~~~~~~~~~~~~
| RADIX_TREE_GATHER
This is caused by the missing macros MAPLE_TREE_COUNT and
MAPLE_TREE_GATHER.
To fix the issue, define the two macros within crash gcore so that
build is successfully done expecting the resulting binary works well
when it is ran against new crash utility that has maple tree API
support.
Signed-off-by: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
---
src/libgcore/gcore_coredump.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/libgcore/gcore_coredump.c b/src/libgcore/gcore_coredump.c
index fa744d4..8eece96 100644
--- a/src/libgcore/gcore_coredump.c
+++ b/src/libgcore/gcore_coredump.c
@@ -128,6 +128,14 @@ void gcore_readmem_user(ulong addr, void *buf, long size, char *type)
}
}
+#if !defined(MAPLE_TREE_COUNT)
+#define MAPLE_TREE_COUNT (1)
+#endif
+
+#if !defined(MAPLE_TREE_GATHER)
+#define MAPLE_TREE_GATHER (4)
+#endif
+
ulong __attribute__((weak))
do_maple_tree(ulong root, int flag, struct list_pair *lp)
{
--
2.39.2

View File

@ -1,137 +1,100 @@
#
# crash core analysis suite
#
%global reponame crash-gcore
Summary: Gcore extension module for the crash utility
Name: crash-gcore-command
Version: 1.6.3
Release: 3%{?dist}
License: GPLv2
Group: Development/Debuggers
Source: https://github.com/fujitsu/crash-gcore/archive/v%{version}/%{name}-%{version}.tar.gz
Version: 1.6.4
Release: 8%{?dist}.1
License: GPL-2.0-only
Source0: 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
ExclusiveArch: x86_64 %{ix86} arm aarch64 ppc64 ppc64le
Buildroot: %{_tmppath}/%{name}-root
BuildRequires: crash-devel >= 5.1.5, zlib-devel lzo-devel snappy-devel
ExclusiveArch: aarch64 ppc64le x86_64
BuildRequires: crash-devel >= 5.1.5
BuildRequires: gcc
Requires: crash >= 5.1.5
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
Patch3: 0001-x86-Fix-failure-of-collecting-vsyscall-mapping-due-t.patch
Patch4: 0002-coredump-fix-segmentation-fault-caused-by-type-misma.patch
Patch5: 0003-elf-fix-warning-message-caused-by-type-mismatch-of-o.patch
Patch6: 0004-coredump-fix-unexpected-truncation-of-generated-core.patch
Patch7: 0005-gcore.mk-fix-mismatch-of-_FILE_OFFSET_BITS-when-buil.patch
Patch0: crash-gcore-1.6.4-coredump-fix-building-failure-due-to-undefined-macro.patch
Patch1: 0001-gcore-update-set_context-with-upstream-counterpart.patch
Patch2: 0001-x86-fix-the-issue-that-core-files-for-64-bit-tasks-a.patch
%description
Command for creating a core dump file of a user-space task that was
running in a kernel dumpfile.
running in a kernel dump file.
%prep
%setup -q -n %{reponame}-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%autosetup -n %{reponame}-%{version} -p1
%build
make CFLAGS="%{optflags} -Wl,-z,now" -C src -f gcore.mk
%make_build CFLAGS="%{optflags} -Wl,-z,now" -C src -f gcore.mk
%install
rm -Rf $RPM_BUILD_ROOT
mkdir -p %{buildroot}%{_libdir}/crash/extensions/
cp %{_builddir}/%{reponame}-%{version}/src/gcore.so %{buildroot}%{_libdir}/crash/extensions/
%clean
rm -rf %{buildroot}
rm -Rf $RPM_BUILD_ROOT
install -m 0755 -d %{buildroot}%{_libdir}/crash/extensions
install -m 0755 -t %{buildroot}%{_libdir}/crash/extensions %{_builddir}/%{reponame}-%{version}/src/gcore.so
%files
%defattr(-,root,root)
%dir %{_libdir}/crash
%dir %{_libdir}/crash/extensions
%{_libdir}/crash/extensions/gcore.so
%doc COPYING
%license COPYING
%changelog
* Fri Nov 18 2022 Lianbo Jiang <lijiang@redhat.com> - 1.6.3-3
- Update to upstream commit d2795659986d
- Resolves: rhbz#2119697
* Tue Aug 05 2025 Kevin Lyons <kevin.x.lyons@oracle.com> - 1.6.4-8.1
- x86: fix the issue that core files for 64-bit tasks are generated in the 32-bit format
- gcore: update set_context with upstream counterpart
* Tue Apr 12 2022 Tao Liu <ltao@redhat.com> - 1.6.3-2
- Rebase to upstream crash-gcore-command-1.6.3
- Fix memory allocation failure issue
- Resolves: rhbz#2060355
* Tue Oct 29 2024 Troy Dawson <tdawson@redhat.com> - 1.6.4-8
- Bump release for October 2024 mass rebuild:
Resolves: RHEL-64018
* 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
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 1.6.4-7
- Bump release for June 2024 mass rebuild
* Wed Jul 8 2020 Bhupesh Sharma <bhsharma@redhat.com> - 1.5.1-1
- Rebase crash-gcore-command to github upstream version crash-gcore-command-1.5.1
Resolves: rhbz#1851747
* Wed Apr 24 2024 Tao Liu <ltao@redhat.com> - 1.6.4-6
- Fix the hardening issue "FAIL: bind-now test because not linked with -Wl,-z,now"
- add gating.yaml
* Tue Jun 25 2019 Dave Anderson <anderson@redhat.com> - 1.3.1-4
- Fix "invalid structure size: pid_link"
Resolves: rhbz#1722726
* Wed Jan 24 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.6.4-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Tue Dec 4 2018 Dave Anderson <anderson@redhat.com> - 1.3.1-3
- Fix x86_64 "invalid structure member offset: thread_struct_fs"
Resolves: rhbz#1589019
- Fix arm64 "invalid structure member offset: thread_struct_fpsimd_state"
Resolves: rhbz#1625810
* Fri Jan 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.6.4-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Wed Sep 10 2018 Dave Anderson <anderson@redhat.com> - 1.3.1-2
- Address annocheck link issue
Resolves: rhbz#1630556
* Tue Sep 12 2023 HATAYAMA Daisuke <d.hatayama@fujitsu.com> - 1.6.4-3
- Migrate to SPDX license format
* Mon Aug 13 2018 Dave Anderson <anderson@redhat.com> - 1.3.1-1
- Bump release for mass rebuild
Resolves: rhbz#1615509
* Wed Jul 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.6.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
* Thu Nov 6 2014 Dave Anderson <anderson@redhat.com> - 1.3.1-0
- Rebase to 1.3.1 to address 32-bit x86 build error.
- Resolves: rhbz#1077311
* Wed Mar 1 2023 HATAYAMA Daisuke <d.hatayama@fujitsu.com> - 1.6.4-1
- coredump: fix building failure due to undefined macros MAPLE_TREE_{COUNT,GATHER}
* Tue Nov 4 2014 Dave Anderson <anderson@redhat.com> - 1.3.0-0
- Add aarch64 support
- Resolves: rhbz#1077311
- Add ppc64/ppc64le support
- Resolves: rhbz#1125485
* Wed Mar 1 2023 HATAYAMA Daisuke <d.hatayama@fujitsu.com> - 1.6.4-0
- Update to latest upstream release
* Fri Dec 27 2013 Daniel Mach <dmach@redhat.com> - 1.2.1-2
- Mass rebuild 2013-12-27
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.6.3-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Tue Jul 26 2022 HATAYAMA Daisuke <d.hatayama@fujitsu.com> - 1.6.3-2
- gcore.mk: fix mismatch of _FILE_OFFSET_BITS when building gcore.so
- coredump: fix unexpected truncation of generated core files
- elf: fix warning message caused by type mismatch of offset types
- coredump: fix segmentation fault caused by type mismatch
- x86: Fix failure of collecting vsyscall mapping due to change of enum type of vsyscall_mode
- gcore: fix memory allocation failure during processing NT_AUXV note
- gcore, defs: remove definitions and initializations for saved_auxv entries of offset and size tables
- coredump: use MEMBER_{OFFSET, SIZE} instead of GCORE_{OFFSET, SIZE}
* Tue Aug 20 2013 Dave Anderson <anderson@redhat.com> - 1.2.1-1
crash utility has added LZO and snappy compression in addition to zlib.
* Wed Jul 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.6.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Thu May 23 2013 HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com> - 1.2.1-0
Fixes for missing VDSO and vsyscall pages in core dump.
* Wed Jan 19 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.6.3-1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Wed Nov 21 2012 HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com> - 1.2-0
Support recent kernels around 3.6.
* Fri Dec 10 2021 HATAYAMA Daisuke <d.hatayama@fujitsu.com> - 1.6.3-0
- Update to latest upstream release
* Tue Jan 31 2012 Dave Anderson <anderson@redhat.com> - 1.0-3
Address Pkgwrangler/rpmlint issues.
Resolves: rbhz#692799
* Wed Jul 21 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.6.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Wed Jan 25 2012 Dave Anderson <anderson@redhat.com> - 1.0-2
Compile with RPM_OPT_FLAGS and fix warnings generated from using it.
Resolves: rbhz#692799
* Thu Apr 13 2011 HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com> - 1.0-1
- Remove inclusion of kvmdump.h and unwind_x86_64.h due to non-supporting issue
on crash-devel package. Instead, use a new interface for them.
- Remove ppc64, ia64, s390 and s390x from ExclusiveArch, leave x86_64
and %%{ix86} there.
- Add descriptions in BuildRequires and Requires about crash and crash-devel.
* Wed Apr 6 2011 HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com> - 1.0-0
* Fri Jan 22 2021 HATAYAMA Daisuke <d.hatayama@fujitsu.com> - 1.6.2-1
- Initial crash-gcore-command package