* [PATCH] fix kexec load hang in case crash notes addr read failure
@ 2015-09-25 2:37 Dave Young
2015-09-25 5:39 ` Simon Horman
0 siblings, 1 reply; 2+ messages in thread
From: Dave Young @ 2015-09-25 2:37 UTC (permalink / raw)
To: kexec
While readng crash note, count_cpu variable will be never decreased in case
any failure to read the sysfs file.
The issue was found during I test CONFIG_KEXEC_FILE only kernel option.
crash_notes are exported to sysfs only for CONFIG_KEXEC. In latest kernel
we can configure kernel with CONFIG_KEXEC_FILE only in Kconfig. In this
case, if you run a kernel with kexec_file only but do not specify "-s"
in kexec-tools arguments, then kexec-tools will hang there.
Though "-s" is mandatory for kexec_file_load, kexec should still fail out
instead of hanging.
Fixing the problem by always decreasing count_cpu in the for loop.
Signed-off-by: Dave Young <dyoung@redhat.com>
---
Ideally checking if kernel support kexec_load or kexec_file_load syscall
early is better, but there's no apparent way to check it, call the syscalls
with fake arguments then check return value sounds bad..
kexec/crashdump-elf.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
--- kexec-tools.orig/kexec/crashdump-elf.c
+++ kexec-tools/kexec/crashdump-elf.c
@@ -141,11 +141,12 @@ int FUNC(struct kexec_info *info,
count_cpu = nr_cpus;
for (i = 0; count_cpu > 0; i++) {
- if (get_note_info(i, ¬es_addr, ¬es_len) < 0) {
- /* This cpu is not present. Skip it. */
- continue;
- }
+ int ret;
+
+ ret = get_note_info(i, ¬es_addr, ¬es_len);
count_cpu--;
+ if (ret < 0) /* This cpu is not present. Skip it. */
+ continue;
phdr = (PHDR *) bufp;
bufp += sizeof(PHDR);
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] fix kexec load hang in case crash notes addr read failure
2015-09-25 2:37 [PATCH] fix kexec load hang in case crash notes addr read failure Dave Young
@ 2015-09-25 5:39 ` Simon Horman
0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2015-09-25 5:39 UTC (permalink / raw)
To: Dave Young; +Cc: kexec
On Fri, Sep 25, 2015 at 10:37:51AM +0800, Dave Young wrote:
> While readng crash note, count_cpu variable will be never decreased in case
> any failure to read the sysfs file.
>
> The issue was found during I test CONFIG_KEXEC_FILE only kernel option.
> crash_notes are exported to sysfs only for CONFIG_KEXEC. In latest kernel
> we can configure kernel with CONFIG_KEXEC_FILE only in Kconfig. In this
> case, if you run a kernel with kexec_file only but do not specify "-s"
> in kexec-tools arguments, then kexec-tools will hang there.
>
> Though "-s" is mandatory for kexec_file_load, kexec should still fail out
> instead of hanging.
>
> Fixing the problem by always decreasing count_cpu in the for loop.
>
> Signed-off-by: Dave Young <dyoung@redhat.com>
Thanks Dave, applied.
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-09-25 5:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-25 2:37 [PATCH] fix kexec load hang in case crash notes addr read failure Dave Young
2015-09-25 5:39 ` Simon Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox