Fix OOPS in crash_kernel_shrink
Two "echo 0 > /sys/kernel/kexec_crash_size" OOPSes kernel. Also content of this file is invalid after first shrink to zero: it shows 1 instead of 0.
This patch fixes it.
kernel/kexec.c +2 -4
@@ -1134,11 +1134,9 @@ int crash_shrink_memory(unsigned long new_size)free_reserved_phys_range (end, crashk_res.end); -if (start == end) { - crashk_res.end = end; +if (start == end)release_resource (&crashk_res); - }else - crashk_res.end = end -1 ; + crashk_res.end = end -1 ; unlock:mutex_unlock (&kexec_mutex);
Signature · 1 line
wbr, Vitaly
Quoted 5 lines · Vitaly Mayatskikh
Two "echo 0 >
/sys/kernel/kexec_crash_size" OOPSes kernel. Also content of this file is invalid after first shrink to zero: it shows 1 instead of 0.This patch fixes it.
Hmmm, I certainly did tests for 'echo 0 > kexec_crash_size' when I worked on this, but I didn't get any oops. Can you show me the full oops?
But yes, the size calculation looks wrong.
Quoted 9 lines
Signed-off-by Vitaly Mayatskikh <[email protected]>kernel/kexec.c +0
-0@@ -1134,11 +1134,9 @@ int crash_shrink_memory(unsigned long new_size)
kernel/kexec.c int crash_shrink_memory(unsigned long new_size) · line 1140
Quoted 10 lines
kernel/kexec.c +2
-4free_reserved_phys_range (end, crashk_res.end); -if (start == end) { - crashk_res.end = end; +if (start == end)release_resource (&crashk_res); - }else - crashk_res.end = end -1 ; + crashk_res.end = end -1 ;
If we do this, crashk_res.end will be ahead of crashk.start.
Thanks.
Quoted 11 lines · Cong Wang
Quoted 5 lines · Vitaly Mayatskikh
Two "echo 0 >
/sys/kernel/kexec_crash_size" OOPSes kernel. Also content of this file is invalid after first shrink to zero: it shows 1 instead of 0.This patch fixes it.
Hmmm, I certainly did tests for 'echo 0 >
kexec_crash_size' when I worked on this, but I didn't get any oops. Can you show me the full oops?
Do it twice. start == end condition will work over and over, and kernel will try to release_resource() again (and that's causes OOPS).
This scenario is unlikely to happen often (root privs, valid crashkernel= in cmdline, dump-capture kernel not loaded), I hit it only by chance.
Signature · 1 line
wbr, Vitaly
Quoted 6 lines · Vitaly Mayatskikh
Quoted 5 lines · Cong Wang
Quoted 4 lines · Vitaly Mayatskikh
Two "echo 0 >
/sys/kernel/kexec_crash_size" OOPSes kernel. Also content of this file is invalid after first shrink to zero: it shows 1 instead of 0.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
This patch fixes it.
Hmmm, I certainly did tests for 'echo 0 >
kexec_crash_size' when I worked on this, but I didn't get any oops. Can you show me the full oops?Do it twice. start == end condition will work over and over, and kernel will try to
release_resource()again (and that's causes OOPS).
Hmm, I see. ACK to your patch.
Thanks much!