[Crash-utility] [PATCH v6 10/14] Fix cpumask_t recursive dependence issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There is recursive dependence for cpumask_t and will exhause the stack,
see the following stack trace:

(gdb) bt
 ...snip...
 #61965 0x00000000005de98c in datatype_info (name=name@entry=0xa5b1fd "cpumask_t", member=member@entry=0x0, dm=dm@entry=0xfffffffffffffffc) at symbols.c:6694
 #61966 0x000000000057e4ea in cpu_map_size ...
 #61967 0x000000000058e7bd in get_cpus_online ...
 #61968 0x000000000061fa4b in diskdump_get_prstatus_percpu ...
 #61969 0x0000000000616d74 in get_netdump_regs_x86_64 ...
 #61970 0x0000000000585290 in get_dumpfile_regs ...
 #61971 0x00000000005b7a3c in x86_64_get_current_task_reg ...
 #61972 0x0000000000650389 in crash_target::fetch_registers ...
 #61973 0x00000000008f385a in target_fetch_registers ...
 #61974 0x000000000086ecda in regcache::raw_update ...
 #61975 regcache::raw_update ...
 #61976 0x000000000086ed7a in readable_regcache::raw_read ...
 #61977 0x000000000086f063 in readable_regcache::cooked_read_value ...
 #61978 0x000000000089c4ee in sentinel_frame_prev_register ...
 #61979 0x0000000000786c76 in frame_unwind_register_value ...
 #61980 0x0000000000786f18 in frame_register_unwind ...
 #61981 0x0000000000787267 in frame_unwind_register ...
 #61982 0x00000000007ad9b0 in i386_unwind_pc ...
 #61983 0x00000000007866c0 in frame_unwind_pc ...
 #61984 0x000000000078679c in get_frame_pc ...
 #61985 get_frame_address_in_block ...
 #61986 0x0000000000786849 in get_frame_address_in_block_if_available ...
 #61987 0x0000000000691466 in get_frame_block ...
 #61988 0x00000000008b9430 in get_selected_block ...
 #61989 0x000000000084f8f2 in parse_exp_in_context ...
 #61990 0x000000000084f9e5 in parse_exp_1 ...
 #61991 parse_expression ...
 #61992 0x00000000008d44da in gdb_get_datatype ...
 #61993 gdb_command_funnel_1 ...
 #61994 0x00000000008d48ae in gdb_command_funnel ...
 #61995 0x000000000059cc42 in gdb_interface ...
 #61996 0x00000000005de98c in datatype_info (name=name@entry=0xa5b1fd "cpumask_t", member=member@entry=0x0, dm=dm@entry=0xfffffffffffffffc) at symbols.c:6694
 #61997 0x000000000057e4ea in cpu_map_size ...
 #61998 0x000000000058e7bd in get_cpus_online () ...
 #61999 0x000000000061fa4b in diskdump_get_prstatus_percpu ...
 #62000 0x0000000000616d74 in get_netdump_regs_x86_64 ...
 #62001 0x0000000000585290 in get_dumpfile_regs ...
 #62002 0x00000000005b7a3c in x86_64_get_current_task_reg ...
 #62003 0x0000000000650389 in crash_target::fetch_registers ...

The cpumask_t will be recursively evaluated. This patch will
fix the bug.

Cc: Sourabh Jain <sourabhjain@xxxxxxxxxxxxx>
Cc: Hari Bathini <hbathini@xxxxxxxxxxxxx>
Cc: Mahesh J Salgaonkar <mahesh@xxxxxxxxxxxxx>
Cc: Naveen N. Rao <naveen.n.rao@xxxxxxxxxxxxxxxxxx>
Cc: Lianbo Jiang <lijiang@xxxxxxxxxx>
Cc: HAGIO KAZUHITO(萩尾 一仁) <k-hagio-ab@xxxxxxx>
Cc: Tao Liu <ltao@xxxxxxxxxx>
Cc: Alexey Makhalov <alexey.makhalov@xxxxxxxxxxxx>
Signed-off-by: Tao Liu <ltao@xxxxxxxxxx>
---
 defs.h      |  1 +
 kernel.c    | 19 ++++++++++---------
 symbols.c   |  1 +
 tools.c     |  2 +-
 xen_hyper.c |  2 +-
 5 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/defs.h b/defs.h
index 12d001f..abfa923 100644
--- a/defs.h
+++ b/defs.h
@@ -2434,6 +2434,7 @@ struct size_table {         /* stash of commonly-used sizes */
 	long module_memory;
 	long fred_frame;
 	long vmap_node;
+	long cpumask_t;
 };
 
 struct array_table {
diff --git a/kernel.c b/kernel.c
index 19833fa..8c2e0ca 100644
--- a/kernel.c
+++ b/kernel.c
@@ -157,6 +157,7 @@ kernel_init()
         if (!(kt->cpu_flags = (ulong *)calloc(NR_CPUS, sizeof(ulong))))
                 error(FATAL, "cannot malloc cpu_flags array");
 
+	STRUCT_SIZE_INIT(cpumask_t, "cpumask_t");
 	cpu_maps_init();
 
 	kt->stext = symbol_value("_stext");
@@ -914,9 +915,9 @@ cpu_map_size(const char *type)
 	struct gnu_request req;
 
         if (LKCD_KERNTYPES()) {
-                if ((len = STRUCT_SIZE("cpumask_t")) < 0)
-                        error(FATAL, "cannot determine type cpumask_t\n");
-		return len;
+		if (INVALID_SIZE(cpumask_t))
+			error(FATAL, "cannot determine type cpumask_t\n");
+		return SIZE(cpumask_t);
 	}
 
 	sprintf(map_symbol, "cpu_%s_map", type);
@@ -926,11 +927,9 @@ cpu_map_size(const char *type)
 		return len;
 	}
 
-	len = STRUCT_SIZE("cpumask_t");
-	if (len < 0)
+	if (INVALID_SIZE(cpumask_t))
 		return sizeof(ulong);
-	else
-		return len;
+	return SIZE(cpumask_t);
 }
 
 /*
@@ -953,8 +952,10 @@ cpu_maps_init(void)
 		{ ACTIVE_MAP, "active" },
 	};
 
-	if ((len = STRUCT_SIZE("cpumask_t")) < 0)
+	if (INVALID_SIZE(cpumask_t))
 		len = sizeof(ulong);
+	else
+		len = SIZE(cpumask_t);
 
 	buf = GETBUF(len);
 
@@ -7421,7 +7422,7 @@ generic_get_irq_affinity(int irq)
 		return;
 
 	len = DIV_ROUND_UP(kt->cpus, BITS_PER_LONG) * sizeof(ulong);
-	len_cpumask = STRUCT_SIZE("cpumask_t");
+	len_cpumask = VALID_SIZE(cpumask_t) ? SIZE(cpumask_t) : 0;
 	if (len_cpumask > 0)
 		len = len_cpumask > len ? len : len_cpumask;
 
diff --git a/symbols.c b/symbols.c
index 927c5ad..b05ba33 100644
--- a/symbols.c
+++ b/symbols.c
@@ -12106,6 +12106,7 @@ dump_offset_table(char *spec, ulong makestruct)
 	fprintf(fp, "                    maple_node: %ld\n", SIZE(maple_node));
 
 	fprintf(fp, "                percpu_counter: %ld\n", SIZE(percpu_counter));
+	fprintf(fp, "                     cpumask_t: %ld\n", SIZE(cpumask_t));
 
         fprintf(fp, "\n                   array_table:\n");
 	/*
diff --git a/tools.c b/tools.c
index bd77a05..85d8b6f 100644
--- a/tools.c
+++ b/tools.c
@@ -6721,7 +6721,7 @@ get_cpumask_buf(void)
 	int cpulen, len_cpumask;
 
 	cpulen = DIV_ROUND_UP(kt->cpus, BITS_PER_LONG) * sizeof(ulong);
-	len_cpumask = STRUCT_SIZE("cpumask_t");
+	len_cpumask = VALID_SIZE(cpumask_t) ? SIZE(cpumask_t) : 0;
 	if (len_cpumask > 0)
 		cpulen = len_cpumask > cpulen ? cpulen : len_cpumask;
 
diff --git a/xen_hyper.c b/xen_hyper.c
index 32e56fa..54c7f57 100644
--- a/xen_hyper.c
+++ b/xen_hyper.c
@@ -52,7 +52,7 @@ xen_hyper_init(void)
 	 */
 	xht->xen_virt_start &= 0xffffffffc0000000;
 #endif
-
+	STRUCT_SIZE_INIT(cpumask_t, "cpumask_t");
 	if (machine_type("X86_64") &&
 	    symbol_exists("xen_phys_start") && !xen_phys_start())
 		error(WARNING, 
-- 
2.40.1
--
Crash-utility mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxxxxxx
https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/
Contribution Guidelines: https://github.com/crash-utility/crash/wiki




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux