* [PATCH] irq_work: Make irq_work_queue_on() NMI-safe again
@ 2022-04-26 13:49 Jun Miao
2022-04-27 1:49 ` Jun Miao
0 siblings, 1 reply; 6+ messages in thread
From: Jun Miao @ 2022-04-26 13:49 UTC (permalink / raw)
To: peterz; +Cc: bigeasy, qiang1.zhang, linux-kernel, jun.miao
We should not put NMI unsafe code in irq_work_queue_on().
The KASAN of kasan_record_aux_stack_noalloc() is not NMI safe. Because which
will call the spinlock. While the irq_work_queue_on() is also very carefully
carafted to be exactly that.
When unable CONFIG_SM or local CPU, the irq_work_queue_on() is even same to
irq_work_queue(). So delete KASAN instantly.
Fixes: e2b5bcf9f5ba ("irq_work: record irq_work_queue() call stack")
Suggested by: "Huang, Ying" <ying.huang@intel.com>
Signed-off-by: Jun Miao <jun.miao@intel.com>
---
kernel/irq_work.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/kernel/irq_work.c b/kernel/irq_work.c
index 7afa40fe5cc4..e7f48aa8d8af 100644
--- a/kernel/irq_work.c
+++ b/kernel/irq_work.c
@@ -20,7 +20,6 @@
#include <linux/smp.h>
#include <linux/smpboot.h>
#include <asm/processor.h>
-#include <linux/kasan.h>
static DEFINE_PER_CPU(struct llist_head, raised_list);
static DEFINE_PER_CPU(struct llist_head, lazy_list);
@@ -137,8 +136,6 @@ bool irq_work_queue_on(struct irq_work *work, int cpu)
if (!irq_work_claim(work))
return false;
- kasan_record_aux_stack_noalloc(work);
-
preempt_disable();
if (cpu != smp_processor_id()) {
/* Arch remote IPI send/receive backend aren't NMI safe */
--
2.32.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] irq_work: Make irq_work_queue_on() NMI-safe again
2022-04-26 13:49 [PATCH] irq_work: Make irq_work_queue_on() NMI-safe again Jun Miao
@ 2022-04-27 1:49 ` Jun Miao
2022-04-27 12:26 ` Marco Elver
0 siblings, 1 reply; 6+ messages in thread
From: Jun Miao @ 2022-04-27 1:49 UTC (permalink / raw)
To: ryabinin.a.a, Dmitry Vyukov
Cc: bigeasy, qiang1.zhang, peterz, akpm, andreyknvl, ying.huang,
akpm, kasan-dev, linux-kernel
Add To/Cc : KASAN/MEM , since I only used the scripts/get_maintainer.pl
to irq_work.c file.
Thanks
Jun Miao
On 2022/4/26 21:49, Jun Miao wrote:
> We should not put NMI unsafe code in irq_work_queue_on().
>
> The KASAN of kasan_record_aux_stack_noalloc() is not NMI safe. Because which
> will call the spinlock. While the irq_work_queue_on() is also very carefully
> carafted to be exactly that.
> When unable CONFIG_SM or local CPU, the irq_work_queue_on() is even same to
> irq_work_queue(). So delete KASAN instantly.
>
> Fixes: e2b5bcf9f5ba ("irq_work: record irq_work_queue() call stack")
> Suggested by: "Huang, Ying" <ying.huang@intel.com>
> Signed-off-by: Jun Miao <jun.miao@intel.com>
> ---
> kernel/irq_work.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/kernel/irq_work.c b/kernel/irq_work.c
> index 7afa40fe5cc4..e7f48aa8d8af 100644
> --- a/kernel/irq_work.c
> +++ b/kernel/irq_work.c
> @@ -20,7 +20,6 @@
> #include <linux/smp.h>
> #include <linux/smpboot.h>
> #include <asm/processor.h>
> -#include <linux/kasan.h>
>
> static DEFINE_PER_CPU(struct llist_head, raised_list);
> static DEFINE_PER_CPU(struct llist_head, lazy_list);
> @@ -137,8 +136,6 @@ bool irq_work_queue_on(struct irq_work *work, int cpu)
> if (!irq_work_claim(work))
> return false;
>
> - kasan_record_aux_stack_noalloc(work);
> -
> preempt_disable();
> if (cpu != smp_processor_id()) {
> /* Arch remote IPI send/receive backend aren't NMI safe */
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] irq_work: Make irq_work_queue_on() NMI-safe again
2022-04-27 1:49 ` Jun Miao
@ 2022-04-27 12:26 ` Marco Elver
2022-04-27 13:17 ` Jun Miao
0 siblings, 1 reply; 6+ messages in thread
From: Marco Elver @ 2022-04-27 12:26 UTC (permalink / raw)
To: Jun Miao
Cc: ryabinin.a.a, Dmitry Vyukov, bigeasy, qiang1.zhang, peterz, akpm,
andreyknvl, ying.huang, kasan-dev, linux-kernel
On Wed, 27 Apr 2022 at 03:49, Jun Miao <jun.miao@intel.com> wrote:
>
> Add To/Cc : KASAN/MEM , since I only used the scripts/get_maintainer.pl
> to irq_work.c file.
>
> Thanks
> Jun Miao
>
>
> On 2022/4/26 21:49, Jun Miao wrote:
> > We should not put NMI unsafe code in irq_work_queue_on().
> >
> > The KASAN of kasan_record_aux_stack_noalloc() is not NMI safe. Because which
> > will call the spinlock. While the irq_work_queue_on() is also very carefully
> > carafted to be exactly that.
"crafted"
> > When unable CONFIG_SM or local CPU, the irq_work_queue_on() is even same to
CONFIG_SM -> CONFIG_SMP
> > irq_work_queue(). So delete KASAN instantly.
> >
> > Fixes: e2b5bcf9f5ba ("irq_work: record irq_work_queue() call stack")
> > Suggested by: "Huang, Ying" <ying.huang@intel.com>
> > Signed-off-by: Jun Miao <jun.miao@intel.com>
I thought this had already been removed, but apparently there were 2
places: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=156172a13ff0626d8e23276e741c7e2cb2f3b572
Acked-by: Marco Elver <elver@google.com>
> > ---
> > kernel/irq_work.c | 3 ---
> > 1 file changed, 3 deletions(-)
> >
> > diff --git a/kernel/irq_work.c b/kernel/irq_work.c
> > index 7afa40fe5cc4..e7f48aa8d8af 100644
> > --- a/kernel/irq_work.c
> > +++ b/kernel/irq_work.c
> > @@ -20,7 +20,6 @@
> > #include <linux/smp.h>
> > #include <linux/smpboot.h>
> > #include <asm/processor.h>
> > -#include <linux/kasan.h>
> >
> > static DEFINE_PER_CPU(struct llist_head, raised_list);
> > static DEFINE_PER_CPU(struct llist_head, lazy_list);
> > @@ -137,8 +136,6 @@ bool irq_work_queue_on(struct irq_work *work, int cpu)
> > if (!irq_work_claim(work))
> > return false;
> >
> > - kasan_record_aux_stack_noalloc(work);
> > -
> > preempt_disable();
> > if (cpu != smp_processor_id()) {
> > /* Arch remote IPI send/receive backend aren't NMI safe */
>
> --
> 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/9c951fe6-d354-5870-e91b-83d8346ac162%40intel.com.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] irq_work: Make irq_work_queue_on() NMI-safe again
2022-04-27 12:26 ` Marco Elver
@ 2022-04-27 13:17 ` Jun Miao
0 siblings, 0 replies; 6+ messages in thread
From: Jun Miao @ 2022-04-27 13:17 UTC (permalink / raw)
To: Marco Elver
Cc: ryabinin.a.a, Dmitry Vyukov, bigeasy, qiang1.zhang, peterz, akpm,
andreyknvl, ying.huang, kasan-dev, linux-kernel
On 2022/4/27 20:26, Marco Elver wrote:
> On Wed, 27 Apr 2022 at 03:49, Jun Miao <jun.miao@intel.com> wrote:
>> Add To/Cc : KASAN/MEM , since I only used the scripts/get_maintainer.pl
>> to irq_work.c file.
>>
>> Thanks
>> Jun Miao
>>
>>
>> On 2022/4/26 21:49, Jun Miao wrote:
>>> We should not put NMI unsafe code in irq_work_queue_on().
>>>
>>> The KASAN of kasan_record_aux_stack_noalloc() is not NMI safe. Because which
>>> will call the spinlock. While the irq_work_queue_on() is also very carefully
>>> carafted to be exactly that.
> "crafted"
>
>>> When unable CONFIG_SM or local CPU, the irq_work_queue_on() is even same to
> CONFIG_SM -> CONFIG_SMP
>
>>> irq_work_queue(). So delete KASAN instantly.
>>>
>>> Fixes: e2b5bcf9f5ba ("irq_work: record irq_work_queue() call stack")
>>> Suggested by: "Huang, Ying" <ying.huang@intel.com>
>>> Signed-off-by: Jun Miao <jun.miao@intel.com>
> I thought this had already been removed, but apparently there were 2
> places: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=156172a13ff0626d8e23276e741c7e2cb2f3b572
>
> Acked-by: Marco Elver <elver@google.com>
Sure, I also found this patch which is the same reason, maybe Peter Z
forgot it. Let me make up a little.😉
Send V2 later.
Thanks
Jun Miao
>>> ---
>>> kernel/irq_work.c | 3 ---
>>> 1 file changed, 3 deletions(-)
>>>
>>> diff --git a/kernel/irq_work.c b/kernel/irq_work.c
>>> index 7afa40fe5cc4..e7f48aa8d8af 100644
>>> --- a/kernel/irq_work.c
>>> +++ b/kernel/irq_work.c
>>> @@ -20,7 +20,6 @@
>>> #include <linux/smp.h>
>>> #include <linux/smpboot.h>
>>> #include <asm/processor.h>
>>> -#include <linux/kasan.h>
>>>
>>> static DEFINE_PER_CPU(struct llist_head, raised_list);
>>> static DEFINE_PER_CPU(struct llist_head, lazy_list);
>>> @@ -137,8 +136,6 @@ bool irq_work_queue_on(struct irq_work *work, int cpu)
>>> if (!irq_work_claim(work))
>>> return false;
>>>
>>> - kasan_record_aux_stack_noalloc(work);
>>> -
>>> preempt_disable();
>>> if (cpu != smp_processor_id()) {
>>> /* Arch remote IPI send/receive backend aren't NMI safe */
>> --
>> 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/9c951fe6-d354-5870-e91b-83d8346ac162%40intel.com.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] irq_work: Make irq_work_queue_on() NMI-safe again
2022-04-27 13:50 Jun Miao
@ 2022-04-27 13:59 ` Jun Miao
0 siblings, 0 replies; 6+ messages in thread
From: Jun Miao @ 2022-04-27 13:59 UTC (permalink / raw)
To: elver, dvyukov, ryabinin.a.a, peterz
Cc: bigeasy, qiang1.zhang, andreyknvl, kasan-dev, linux-kernel, akpm
Sorry, please ignore!
On 2022/4/27 21:50, Jun Miao wrote:
> We should not put NMI unsafe code in irq_work_queue_on().
>
> The KASAN of kasan_record_aux_stack_noalloc() is not NMI safe. Because which
> will call the spinlock. While the irq_work_queue_on() is also very carefully
> carfted to be exactly that.
> When unable CONFIG_SMP or local CPU, the irq_work_queue_on() is even same to
> irq_work_queue(). So delete KASAN instantly.
>
> Fixes: e2b5bcf9f5ba ("irq_work: record irq_work_queue() call stack")
> Suggested by: "Huang, Ying" <ying.huang@intel.com>
> Signed-off-by: Jun Miao <jun.miao@intel.com>
> Acked-by: Marco Elver <elver@google.com>
> ---
> kernel/irq_work.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/kernel/irq_work.c b/kernel/irq_work.c
> index 7afa40fe5cc4..e7f48aa8d8af 100644
> --- a/kernel/irq_work.c
> +++ b/kernel/irq_work.c
> @@ -20,7 +20,6 @@
> #include <linux/smp.h>
> #include <linux/smpboot.h>
> #include <asm/processor.h>
> -#include <linux/kasan.h>
>
> static DEFINE_PER_CPU(struct llist_head, raised_list);
> static DEFINE_PER_CPU(struct llist_head, lazy_list);
> @@ -137,8 +136,6 @@ bool irq_work_queue_on(struct irq_work *work, int cpu)
> if (!irq_work_claim(work))
> return false;
>
> - kasan_record_aux_stack_noalloc(work);
> -
> preempt_disable();
> if (cpu != smp_processor_id()) {
> /* Arch remote IPI send/receive backend aren't NMI safe */
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] irq_work: Make irq_work_queue_on() NMI-safe again
@ 2022-04-27 13:50 Jun Miao
2022-04-27 13:59 ` Jun Miao
0 siblings, 1 reply; 6+ messages in thread
From: Jun Miao @ 2022-04-27 13:50 UTC (permalink / raw)
To: elver, dvyukov, ryabinin.a.a, peterz
Cc: bigeasy, qiang1.zhang, andreyknvl, kasan-dev, linux-kernel, akpm,
jun.miao
We should not put NMI unsafe code in irq_work_queue_on().
The KASAN of kasan_record_aux_stack_noalloc() is not NMI safe. Because which
will call the spinlock. While the irq_work_queue_on() is also very carefully
carfted to be exactly that.
When unable CONFIG_SMP or local CPU, the irq_work_queue_on() is even same to
irq_work_queue(). So delete KASAN instantly.
Fixes: e2b5bcf9f5ba ("irq_work: record irq_work_queue() call stack")
Suggested by: "Huang, Ying" <ying.huang@intel.com>
Signed-off-by: Jun Miao <jun.miao@intel.com>
Acked-by: Marco Elver <elver@google.com>
---
kernel/irq_work.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/kernel/irq_work.c b/kernel/irq_work.c
index 7afa40fe5cc4..e7f48aa8d8af 100644
--- a/kernel/irq_work.c
+++ b/kernel/irq_work.c
@@ -20,7 +20,6 @@
#include <linux/smp.h>
#include <linux/smpboot.h>
#include <asm/processor.h>
-#include <linux/kasan.h>
static DEFINE_PER_CPU(struct llist_head, raised_list);
static DEFINE_PER_CPU(struct llist_head, lazy_list);
@@ -137,8 +136,6 @@ bool irq_work_queue_on(struct irq_work *work, int cpu)
if (!irq_work_claim(work))
return false;
- kasan_record_aux_stack_noalloc(work);
-
preempt_disable();
if (cpu != smp_processor_id()) {
/* Arch remote IPI send/receive backend aren't NMI safe */
--
2.32.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-04-27 14:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-26 13:49 [PATCH] irq_work: Make irq_work_queue_on() NMI-safe again Jun Miao
2022-04-27 1:49 ` Jun Miao
2022-04-27 12:26 ` Marco Elver
2022-04-27 13:17 ` Jun Miao
2022-04-27 13:50 Jun Miao
2022-04-27 13:59 ` Jun Miao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).