All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] Update doc and fix some issues about kdump
@ 2022-02-08 12:51 ` Tiezhu Yang
  0 siblings, 0 replies; 18+ messages in thread
From: Tiezhu Yang @ 2022-02-08 12:51 UTC (permalink / raw)
  To: Baoquan He, Jonathan Corbet, Andrew Morton, Marco Elver, Andrey Ryabinin
  Cc: Xuefeng Li, kexec, linux-doc, kasan-dev, linux-mm, linux-kernel

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


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 0/5] Update doc and fix some issues about kdump
@ 2022-02-08 12:51 ` Tiezhu Yang
  0 siblings, 0 replies; 18+ messages in thread
From: Tiezhu Yang @ 2022-02-08 12:51 UTC (permalink / raw)
  To: kexec

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



^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 1/5] docs: kdump: update description about sysfs file system support
  2022-02-08 12:51 ` Tiezhu Yang
@ 2022-02-08 12:51   ` Tiezhu Yang
  -1 siblings, 0 replies; 18+ messages in thread
From: Tiezhu Yang @ 2022-02-08 12:51 UTC (permalink / raw)
  To: Baoquan He, Jonathan Corbet, Andrew Morton, Marco Elver, Andrey Ryabinin
  Cc: Xuefeng Li, kexec, linux-doc, kasan-dev, linux-mm, linux-kernel

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 <yangtiezhu@loongson.cn>
Acked-by: Baoquan He <bhe@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


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 1/5] docs: kdump: update description about sysfs file system support
@ 2022-02-08 12:51   ` Tiezhu Yang
  0 siblings, 0 replies; 18+ messages in thread
From: Tiezhu Yang @ 2022-02-08 12:51 UTC (permalink / raw)
  To: kexec

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 <yangtiezhu@loongson.cn>
Acked-by: Baoquan He <bhe@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



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 2/5] docs: kdump: add scp example to write out the dump file
  2022-02-08 12:51 ` Tiezhu Yang
@ 2022-02-08 12:51   ` Tiezhu Yang
  -1 siblings, 0 replies; 18+ messages in thread
From: Tiezhu Yang @ 2022-02-08 12:51 UTC (permalink / raw)
  To: Baoquan He, Jonathan Corbet, Andrew Morton, Marco Elver, Andrey Ryabinin
  Cc: Xuefeng Li, kexec, linux-doc, kasan-dev, linux-mm, linux-kernel

Except cp and makedumpfile, add scp example to write out the dump file.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Acked-by: Baoquan He <bhe@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


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 2/5] docs: kdump: add scp example to write out the dump file
@ 2022-02-08 12:51   ` Tiezhu Yang
  0 siblings, 0 replies; 18+ messages in thread
From: Tiezhu Yang @ 2022-02-08 12:51 UTC (permalink / raw)
  To: kexec

Except cp and makedumpfile, add scp example to write out the dump file.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Acked-by: Baoquan He <bhe@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 at 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



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 3/5] panic: unset panic_on_warn inside panic()
  2022-02-08 12:51 ` Tiezhu Yang
@ 2022-02-08 12:51   ` Tiezhu Yang
  -1 siblings, 0 replies; 18+ messages in thread
From: Tiezhu Yang @ 2022-02-08 12:51 UTC (permalink / raw)
  To: Baoquan He, Jonathan Corbet, Andrew Morton, Marco Elver, Andrey Ryabinin
  Cc: Xuefeng Li, kexec, linux-doc, kasan-dev, linux-mm, linux-kernel

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 <yangtiezhu@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


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 3/5] panic: unset panic_on_warn inside panic()
@ 2022-02-08 12:51   ` Tiezhu Yang
  0 siblings, 0 replies; 18+ messages in thread
From: Tiezhu Yang @ 2022-02-08 12:51 UTC (permalink / raw)
  To: kexec

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 <yangtiezhu@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



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 4/5] ubsan: no need to unset panic_on_warn in ubsan_epilogue()
  2022-02-08 12:51 ` Tiezhu Yang
@ 2022-02-08 12:51   ` Tiezhu Yang
  -1 siblings, 0 replies; 18+ messages in thread
From: Tiezhu Yang @ 2022-02-08 12:51 UTC (permalink / raw)
  To: Baoquan He, Jonathan Corbet, Andrew Morton, Marco Elver, Andrey Ryabinin
  Cc: Xuefeng Li, kexec, linux-doc, kasan-dev, linux-mm, linux-kernel

panic_on_warn is unset inside panic(), so no need to unset it
before calling panic() in ubsan_epilogue().

Signed-off-by: Tiezhu Yang <yangtiezhu@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


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 4/5] ubsan: no need to unset panic_on_warn in ubsan_epilogue()
@ 2022-02-08 12:51   ` Tiezhu Yang
  0 siblings, 0 replies; 18+ messages in thread
From: Tiezhu Yang @ 2022-02-08 12:51 UTC (permalink / raw)
  To: kexec

panic_on_warn is unset inside panic(), so no need to unset it
before calling panic() in ubsan_epilogue().

Signed-off-by: Tiezhu Yang <yangtiezhu@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



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 5/5] kasan: no need to unset panic_on_warn in end_report()
  2022-02-08 12:51 ` Tiezhu Yang
@ 2022-02-08 12:51   ` Tiezhu Yang
  -1 siblings, 0 replies; 18+ messages in thread
From: Tiezhu Yang @ 2022-02-08 12:51 UTC (permalink / raw)
  To: Baoquan He, Jonathan Corbet, Andrew Morton, Marco Elver, Andrey Ryabinin
  Cc: Xuefeng Li, kexec, linux-doc, kasan-dev, linux-mm, linux-kernel

panic_on_warn is unset inside panic(), so no need to unset it
before calling panic() in end_report().

Signed-off-by: Tiezhu Yang <yangtiezhu@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


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 5/5] kasan: no need to unset panic_on_warn in end_report()
@ 2022-02-08 12:51   ` Tiezhu Yang
  0 siblings, 0 replies; 18+ messages in thread
From: Tiezhu Yang @ 2022-02-08 12:51 UTC (permalink / raw)
  To: kexec

panic_on_warn is unset inside panic(), so no need to unset it
before calling panic() in end_report().

Signed-off-by: Tiezhu Yang <yangtiezhu@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



^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 3/5] panic: unset panic_on_warn inside panic()
  2022-02-08 12:51   ` Tiezhu Yang
@ 2022-02-08 13:38     ` Marco Elver
  -1 siblings, 0 replies; 18+ messages in thread
From: Marco Elver @ 2022-02-08 13:38 UTC (permalink / raw)
  To: Tiezhu Yang
  Cc: Baoquan He, Jonathan Corbet, Andrew Morton, Andrey Ryabinin,
	Xuefeng Li, kexec, linux-doc, kasan-dev, linux-mm, linux-kernel

On Tue, 8 Feb 2022 at 13:51, Tiezhu Yang <yangtiezhu@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 <yangtiezhu@loongson.cn>

Reviewed-by: Marco Elver <elver@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.

> +                * 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
>
> --
> 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+unsubscribe@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.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 3/5] panic: unset panic_on_warn inside panic()
@ 2022-02-08 13:38     ` Marco Elver
  0 siblings, 0 replies; 18+ messages in thread
From: Marco Elver @ 2022-02-08 13:38 UTC (permalink / raw)
  To: kexec

On Tue, 8 Feb 2022 at 13:51, Tiezhu Yang <yangtiezhu@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 <yangtiezhu@loongson.cn>

Reviewed-by: Marco Elver <elver@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.

> +                * 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
>
> --
> 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+unsubscribe at 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.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 4/5] ubsan: no need to unset panic_on_warn in ubsan_epilogue()
  2022-02-08 12:51   ` Tiezhu Yang
@ 2022-02-08 13:39     ` Marco Elver
  -1 siblings, 0 replies; 18+ messages in thread
From: Marco Elver @ 2022-02-08 13:39 UTC (permalink / raw)
  To: Tiezhu Yang
  Cc: Baoquan He, Jonathan Corbet, Andrew Morton, Andrey Ryabinin,
	Xuefeng Li, kexec, linux-doc, kasan-dev, linux-mm, linux-kernel

On Tue, 8 Feb 2022 at 13:51, Tiezhu Yang <yangtiezhu@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 <yangtiezhu@loongson.cn>

Reviewed-by: Marco Elver <elver@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+unsubscribe@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.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 4/5] ubsan: no need to unset panic_on_warn in ubsan_epilogue()
@ 2022-02-08 13:39     ` Marco Elver
  0 siblings, 0 replies; 18+ messages in thread
From: Marco Elver @ 2022-02-08 13:39 UTC (permalink / raw)
  To: kexec

On Tue, 8 Feb 2022 at 13:51, Tiezhu Yang <yangtiezhu@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 <yangtiezhu@loongson.cn>

Reviewed-by: Marco Elver <elver@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+unsubscribe at 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.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 5/5] kasan: no need to unset panic_on_warn in end_report()
  2022-02-08 12:51   ` Tiezhu Yang
@ 2022-02-08 13:39     ` Marco Elver
  -1 siblings, 0 replies; 18+ messages in thread
From: Marco Elver @ 2022-02-08 13:39 UTC (permalink / raw)
  To: Tiezhu Yang
  Cc: Baoquan He, Jonathan Corbet, Andrew Morton, Andrey Ryabinin,
	Xuefeng Li, kexec, linux-doc, kasan-dev, linux-mm, linux-kernel

On Tue, 8 Feb 2022 at 13:51, Tiezhu Yang <yangtiezhu@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 <yangtiezhu@loongson.cn>

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


> ---
>  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
>
> --
> 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+unsubscribe@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.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 5/5] kasan: no need to unset panic_on_warn in end_report()
@ 2022-02-08 13:39     ` Marco Elver
  0 siblings, 0 replies; 18+ messages in thread
From: Marco Elver @ 2022-02-08 13:39 UTC (permalink / raw)
  To: kexec

On Tue, 8 Feb 2022 at 13:51, Tiezhu Yang <yangtiezhu@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 <yangtiezhu@loongson.cn>

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


> ---
>  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
>
> --
> 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+unsubscribe at 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.


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2022-02-08 13:39 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-08 12:51 [PATCH v2 0/5] Update doc and fix some issues about kdump Tiezhu Yang
2022-02-08 12:51 ` Tiezhu Yang
2022-02-08 12:51 ` [PATCH v2 1/5] docs: kdump: update description about sysfs file system support Tiezhu Yang
2022-02-08 12:51   ` Tiezhu Yang
2022-02-08 12:51 ` [PATCH v2 2/5] docs: kdump: add scp example to write out the dump file Tiezhu Yang
2022-02-08 12:51   ` Tiezhu Yang
2022-02-08 12:51 ` [PATCH v2 3/5] panic: unset panic_on_warn inside panic() Tiezhu Yang
2022-02-08 12:51   ` Tiezhu Yang
2022-02-08 13:38   ` Marco Elver
2022-02-08 13:38     ` Marco Elver
2022-02-08 12:51 ` [PATCH v2 4/5] ubsan: no need to unset panic_on_warn in ubsan_epilogue() Tiezhu Yang
2022-02-08 12:51   ` Tiezhu Yang
2022-02-08 13:39   ` Marco Elver
2022-02-08 13:39     ` Marco Elver
2022-02-08 12:51 ` [PATCH v2 5/5] kasan: no need to unset panic_on_warn in end_report() Tiezhu Yang
2022-02-08 12:51   ` Tiezhu Yang
2022-02-08 13:39   ` Marco Elver
2022-02-08 13:39     ` Marco Elver

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.