[PATCH v2 0/5] Update doc and fix some issues about kdump

9 views
Skip to first unread message

Tiezhu Yang

unread,
Feb 8, 2022, 7:51:11 AM2/8/22
to Baoquan He, Jonathan Corbet, Andrew Morton, Marco Elver, Andrey Ryabinin, Xuefeng Li, ke...@lists.infradead.org, linu...@vger.kernel.org, kasa...@googlegroups.com, linu...@kvack.org, linux-...@vger.kernel.org
Tiezhu Yang (5):
docs: kdump: update description about sysfs file system support
docs: kdump: add scp example to write out the dump file
panic: unset panic_on_warn inside panic()
ubsan: no need to unset panic_on_warn in ubsan_epilogue()
kasan: no need to unset panic_on_warn in end_report()

Documentation/admin-guide/kdump/kdump.rst | 10 +++++++---
kernel/panic.c | 20 +++++++++++---------
lib/ubsan.c | 10 +---------
mm/kasan/report.c | 10 +---------
4 files changed, 20 insertions(+), 30 deletions(-)

--
2.1.0

Tiezhu Yang

unread,
Feb 8, 2022, 7:51:12 AM2/8/22
to Baoquan He, Jonathan Corbet, Andrew Morton, Marco Elver, Andrey Ryabinin, Xuefeng Li, ke...@lists.infradead.org, linu...@vger.kernel.org, kasa...@googlegroups.com, linu...@kvack.org, linux-...@vger.kernel.org
In the current code, the following three places need to unset
panic_on_warn before calling panic() to avoid recursive panics:

kernel/kcsan/report.c: print_report()
kernel/sched/core.c: __schedule_bug()
mm/kfence/report.c: kfence_report_error()

In order to avoid copy-pasting "panic_on_warn = 0" all over the
places, it is better to move it inside panic() and then remove
it from the other places.

Signed-off-by: Tiezhu Yang <yangt...@loongson.cn>
---
kernel/panic.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/kernel/panic.c b/kernel/panic.c
index 55b50e0..95ba825 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -185,6 +185,16 @@ void panic(const char *fmt, ...)
int old_cpu, this_cpu;
bool _crash_kexec_post_notifiers = crash_kexec_post_notifiers;

+ if (panic_on_warn) {
+ /*
+ * This thread may hit another WARN() in the panic path.
+ * Resetting this prevents additional WARN() from panicking the
+ * system on this thread. Other threads are blocked by the
+ * panic_mutex in panic().
+ */
+ panic_on_warn = 0;
+ }
+
/*
* Disable local interrupts. This will prevent panic_smp_self_stop
* from deadlocking the first cpu that invokes the panic, since
@@ -576,16 +586,8 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
if (regs)
show_regs(regs);

- if (panic_on_warn) {
- /*
- * This thread may hit another WARN() in the panic path.
- * Resetting this prevents additional WARN() from panicking the
- * system on this thread. Other threads are blocked by the
- * panic_mutex in panic().
- */
- panic_on_warn = 0;
+ if (panic_on_warn)
panic("panic_on_warn set ...\n");
- }

if (!regs)
dump_stack();
--
2.1.0

Tiezhu Yang

unread,
Feb 8, 2022, 7:51:12 AM2/8/22
to Baoquan He, Jonathan Corbet, Andrew Morton, Marco Elver, Andrey Ryabinin, Xuefeng Li, ke...@lists.infradead.org, linu...@vger.kernel.org, kasa...@googlegroups.com, linu...@kvack.org, linux-...@vger.kernel.org
After commit 6a108a14fa35 ("kconfig: rename CONFIG_EMBEDDED to
CONFIG_EXPERT"), "Configure standard kernel features (for small
systems)" is not exist, we should use "Configure standard kernel
features (expert users)" now.

Signed-off-by: Tiezhu Yang <yangt...@loongson.cn>
Acked-by: Baoquan He <b...@redhat.com>
---
Documentation/admin-guide/kdump/kdump.rst | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/admin-guide/kdump/kdump.rst b/Documentation/admin-guide/kdump/kdump.rst
index cb30ca3d..d187df2 100644
--- a/Documentation/admin-guide/kdump/kdump.rst
+++ b/Documentation/admin-guide/kdump/kdump.rst
@@ -146,9 +146,9 @@ System kernel config options
CONFIG_SYSFS=y

Note that "sysfs file system support" might not appear in the "Pseudo
- filesystems" menu if "Configure standard kernel features (for small
- systems)" is not enabled in "General Setup." In this case, check the
- .config file itself to ensure that sysfs is turned on, as follows::
+ filesystems" menu if "Configure standard kernel features (expert users)"
+ is not enabled in "General Setup." In this case, check the .config file
+ itself to ensure that sysfs is turned on, as follows::

grep 'CONFIG_SYSFS' .config

--
2.1.0

Tiezhu Yang

unread,
Feb 8, 2022, 7:51:12 AM2/8/22
to Baoquan He, Jonathan Corbet, Andrew Morton, Marco Elver, Andrey Ryabinin, Xuefeng Li, ke...@lists.infradead.org, linu...@vger.kernel.org, kasa...@googlegroups.com, linu...@kvack.org, linux-...@vger.kernel.org
panic_on_warn is unset inside panic(), so no need to unset it
before calling panic() in ubsan_epilogue().

Signed-off-by: Tiezhu Yang <yangt...@loongson.cn>
---
lib/ubsan.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/lib/ubsan.c b/lib/ubsan.c
index bdc380f..36bd75e 100644
--- a/lib/ubsan.c
+++ b/lib/ubsan.c
@@ -154,16 +154,8 @@ static void ubsan_epilogue(void)

current->in_ubsan--;

- if (panic_on_warn) {
- /*
- * This thread may hit another WARN() in the panic path.
- * Resetting this prevents additional WARN() from panicking the
- * system on this thread. Other threads are blocked by the
- * panic_mutex in panic().
- */
- panic_on_warn = 0;
+ if (panic_on_warn)
panic("panic_on_warn set ...\n");
- }
}

void __ubsan_handle_divrem_overflow(void *_data, void *lhs, void *rhs)
--
2.1.0

Tiezhu Yang

unread,
Feb 8, 2022, 7:51:12 AM2/8/22
to Baoquan He, Jonathan Corbet, Andrew Morton, Marco Elver, Andrey Ryabinin, Xuefeng Li, ke...@lists.infradead.org, linu...@vger.kernel.org, kasa...@googlegroups.com, linu...@kvack.org, linux-...@vger.kernel.org
Except cp and makedumpfile, add scp example to write out the dump file.

Signed-off-by: Tiezhu Yang <yangt...@loongson.cn>
Acked-by: Baoquan He <b...@redhat.com>
---
Documentation/admin-guide/kdump/kdump.rst | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/Documentation/admin-guide/kdump/kdump.rst b/Documentation/admin-guide/kdump/kdump.rst
index d187df2..a748e7e 100644
--- a/Documentation/admin-guide/kdump/kdump.rst
+++ b/Documentation/admin-guide/kdump/kdump.rst
@@ -533,6 +533,10 @@ the following command::

cp /proc/vmcore <dump-file>

+or use scp to write out the dump file between hosts on a network, e.g::
+
+ scp /proc/vmcore remote_username@remote_ip:<dump-file>
+
You can also use makedumpfile utility to write out the dump file
with specified options to filter out unwanted contents, e.g::

--
2.1.0

Tiezhu Yang

unread,
Feb 8, 2022, 7:51:13 AM2/8/22
to Baoquan He, Jonathan Corbet, Andrew Morton, Marco Elver, Andrey Ryabinin, Xuefeng Li, ke...@lists.infradead.org, linu...@vger.kernel.org, kasa...@googlegroups.com, linu...@kvack.org, linux-...@vger.kernel.org
panic_on_warn is unset inside panic(), so no need to unset it
before calling panic() in end_report().

Signed-off-by: Tiezhu Yang <yangt...@loongson.cn>
---
mm/kasan/report.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index 3ad9624..f141465 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -117,16 +117,8 @@ static void end_report(unsigned long *flags, unsigned long addr)
pr_err("==================================================================\n");
add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
spin_unlock_irqrestore(&report_lock, *flags);
- if (panic_on_warn && !test_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags)) {
- /*
- * This thread may hit another WARN() in the panic path.
- * Resetting this prevents additional WARN() from panicking the
- * system on this thread. Other threads are blocked by the
- * panic_mutex in panic().
- */
- panic_on_warn = 0;
+ if (panic_on_warn && !test_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags))
panic("panic_on_warn set ...\n");
- }
if (kasan_arg_fault == KASAN_ARG_FAULT_PANIC)
panic("kasan.fault=panic set ...\n");
kasan_enable_current();
--
2.1.0

Marco Elver

unread,
Feb 8, 2022, 8:38:35 AM2/8/22
to Tiezhu Yang, Baoquan He, Jonathan Corbet, Andrew Morton, Andrey Ryabinin, Xuefeng Li, ke...@lists.infradead.org, linu...@vger.kernel.org, kasa...@googlegroups.com, linu...@kvack.org, linux-...@vger.kernel.org
On Tue, 8 Feb 2022 at 13:51, Tiezhu Yang <yangt...@loongson.cn> wrote:
>
> In the current code, the following three places need to unset
> panic_on_warn before calling panic() to avoid recursive panics:
>
> kernel/kcsan/report.c: print_report()
> kernel/sched/core.c: __schedule_bug()
> mm/kfence/report.c: kfence_report_error()
>
> In order to avoid copy-pasting "panic_on_warn = 0" all over the
> places, it is better to move it inside panic() and then remove
> it from the other places.
>
> Signed-off-by: Tiezhu Yang <yangt...@loongson.cn>

Reviewed-by: Marco Elver <el...@google.com>


> ---
> kernel/panic.c | 20 +++++++++++---------
> 1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/kernel/panic.c b/kernel/panic.c
> index 55b50e0..95ba825 100644
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -185,6 +185,16 @@ void panic(const char *fmt, ...)
> int old_cpu, this_cpu;
> bool _crash_kexec_post_notifiers = crash_kexec_post_notifiers;
>
> + if (panic_on_warn) {
> + /*
> + * This thread may hit another WARN() in the panic path.

Alas, this may actually fix another problem: doing a panic() not from
a WARN(), but then hitting a WARN() along in the panic path. So
"another WARN" is irrelevant, just "a WARN" would be enough to break
things.
> --
> You received this message because you are subscribed to the Google Groups "kasan-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to kasan-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/1644324666-15947-4-git-send-email-yangtiezhu%40loongson.cn.

Marco Elver

unread,
Feb 8, 2022, 8:39:18 AM2/8/22
to Tiezhu Yang, Baoquan He, Jonathan Corbet, Andrew Morton, Andrey Ryabinin, Xuefeng Li, ke...@lists.infradead.org, linu...@vger.kernel.org, kasa...@googlegroups.com, linu...@kvack.org, linux-...@vger.kernel.org
On Tue, 8 Feb 2022 at 13:51, Tiezhu Yang <yangt...@loongson.cn> wrote:
>
> panic_on_warn is unset inside panic(), so no need to unset it
> before calling panic() in ubsan_epilogue().
>
> Signed-off-by: Tiezhu Yang <yangt...@loongson.cn>

Reviewed-by: Marco Elver <el...@google.com>


> ---
> lib/ubsan.c | 10 +---------
> 1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/lib/ubsan.c b/lib/ubsan.c
> index bdc380f..36bd75e 100644
> --- a/lib/ubsan.c
> +++ b/lib/ubsan.c
> @@ -154,16 +154,8 @@ static void ubsan_epilogue(void)
>
> current->in_ubsan--;
>
> - if (panic_on_warn) {
> - /*
> - * This thread may hit another WARN() in the panic path.
> - * Resetting this prevents additional WARN() from panicking the
> - * system on this thread. Other threads are blocked by the
> - * panic_mutex in panic().
> - */
> - panic_on_warn = 0;
> + if (panic_on_warn)
> panic("panic_on_warn set ...\n");
> - }
> }
>
> void __ubsan_handle_divrem_overflow(void *_data, void *lhs, void *rhs)
> --
> 2.1.0
>
> --
> You received this message because you are subscribed to the Google Groups "kasan-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to kasan-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/1644324666-15947-5-git-send-email-yangtiezhu%40loongson.cn.

Marco Elver

unread,
Feb 8, 2022, 8:39:46 AM2/8/22
to Tiezhu Yang, Baoquan He, Jonathan Corbet, Andrew Morton, Andrey Ryabinin, Xuefeng Li, ke...@lists.infradead.org, linu...@vger.kernel.org, kasa...@googlegroups.com, linu...@kvack.org, linux-...@vger.kernel.org
On Tue, 8 Feb 2022 at 13:51, Tiezhu Yang <yangt...@loongson.cn> wrote:
>
> panic_on_warn is unset inside panic(), so no need to unset it
> before calling panic() in end_report().
>
> Signed-off-by: Tiezhu Yang <yangt...@loongson.cn>

Reviewed-by: Marco Elver <el...@google.com>
> --
> You received this message because you are subscribed to the Google Groups "kasan-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to kasan-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/1644324666-15947-6-git-send-email-yangtiezhu%40loongson.cn.
Reply all
Reply to author
Forward
0 new messages