Fix a failure due to offset change of uts_namespace.name

The offset of the field 'init_uts_ns.name' has changed
since commit 9a56493f6942 ("uts: Use generic ns_common::count").

Link: https://lore.kernel.org/r/159644978167.604812.1773586504374412107.stgit@localhost.localdomain

Read the offset from the vmlinux file's debuginfo data properly
to fix a failure during crash initialization.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
This commit is contained in:
Alexander Egorenkov 2020-10-01 15:19:59 +02:00 committed by Kazuhito Hagio
parent 79e756606c
commit a5e1aeb864
3 changed files with 14 additions and 5 deletions

1
defs.h
View File

@ -2104,6 +2104,7 @@ struct offset_table { /* stash of commonly-used offsets */
long inode_i_sb_list;
long irq_common_data_affinity;
long irq_desc_irq_common_data;
long uts_namespace_name;
};
struct size_table { /* stash of commonly-used sizes */

View File

@ -230,16 +230,21 @@ kernel_init()
fprintf(fp, "%s\n\n", ctime_tz(&kt->date.tv_sec));
clean_exit(0);
}
MEMBER_OFFSET_INIT(uts_namespace_name, "uts_namespace", "name");
if (symbol_exists("system_utsname"))
readmem(symbol_value("system_utsname"), KVADDR, &kt->utsname,
sizeof(struct new_utsname), "system_utsname",
RETURN_ON_ERROR);
else if (symbol_exists("init_uts_ns"))
readmem(symbol_value("init_uts_ns") + sizeof(int),
KVADDR, &kt->utsname, sizeof(struct new_utsname),
else if (symbol_exists("init_uts_ns")) {
long offset = sizeof(int);
if (VALID_MEMBER(uts_namespace_name))
offset = OFFSET(uts_namespace_name);
readmem(symbol_value("init_uts_ns") + offset,
KVADDR, &kt->utsname, sizeof(struct new_utsname),
"init_uts_ns", RETURN_ON_ERROR);
else
} else
error(INFO, "cannot access utsname information\n\n");
if (CRASHDEBUG(1)) {

View File

@ -10585,6 +10585,9 @@ dump_offset_table(char *spec, ulong makestruct)
fprintf(fp, " xa_node_shift: %ld\n",
OFFSET(xa_node_shift));
fprintf(fp, " uts_namespace_name: %ld\n",
OFFSET(uts_namespace_name));
fprintf(fp, "\n size_table:\n");
fprintf(fp, " page: %ld\n", SIZE(page));
fprintf(fp, " page_flags: %ld\n", SIZE(page_flags));