* [PATCH] arm64: fix wrong check of on_sdei_stack in nmi context
@ 2019-04-01 3:55 Wei Li
2019-04-01 9:49 ` Julien Thierry
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Wei Li @ 2019-04-01 3:55 UTC (permalink / raw)
To: catalin.marinas, will.deacon, mark.rutland, labbott, alex.popov,
james.morse
Cc: guohanjun, huawei.libin, linux-arm-kernel, julien.thierry
When doing unwind_frame() in the context of pseudo nmi (need enable
CONFIG_ARM64_PSEUDO_NMI), reaching the botton of the stack (fp == 0,
pc != 0), function on_sdei_stack() will return true while the sdei acpi
table is not inited in fact. This will cause a "NULL pointer dereference"
oops when going on.
Signed-off-by: Wei Li <liwei391@huawei.com>
---
arch/arm64/kernel/sdei.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/arm64/kernel/sdei.c b/arch/arm64/kernel/sdei.c
index 5ba4465e44f0..ea94cf8f9dc6 100644
--- a/arch/arm64/kernel/sdei.c
+++ b/arch/arm64/kernel/sdei.c
@@ -94,6 +94,9 @@ static bool on_sdei_normal_stack(unsigned long sp, struct stack_info *info)
unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_normal_ptr);
unsigned long high = low + SDEI_STACK_SIZE;
+ if (!low)
+ return false;
+
if (sp < low || sp >= high)
return false;
@@ -111,6 +114,9 @@ static bool on_sdei_critical_stack(unsigned long sp, struct stack_info *info)
unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_critical_ptr);
unsigned long high = low + SDEI_STACK_SIZE;
+ if (!low)
+ return false;
+
if (sp < low || sp >= high)
return false;
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64: fix wrong check of on_sdei_stack in nmi context
2019-04-01 3:55 [PATCH] arm64: fix wrong check of on_sdei_stack in nmi context Wei Li
@ 2019-04-01 9:49 ` Julien Thierry
2019-04-01 10:32 ` Heyi Guo
2019-04-02 17:13 ` Catalin Marinas
2 siblings, 0 replies; 4+ messages in thread
From: Julien Thierry @ 2019-04-01 9:49 UTC (permalink / raw)
To: Wei Li, catalin.marinas, will.deacon, mark.rutland, labbott,
alex.popov, james.morse
Cc: huawei.libin, linux-arm-kernel, guohanjun
Hi Wei,
On 01/04/2019 04:55, Wei Li wrote:
> When doing unwind_frame() in the context of pseudo nmi (need enable
> CONFIG_ARM64_PSEUDO_NMI), reaching the botton of the stack (fp == 0,
> pc != 0), function on_sdei_stack() will return true while the sdei acpi
> table is not inited in fact. This will cause a "NULL pointer dereference"
> oops when going on.
>
> Signed-off-by: Wei Li <liwei391@huawei.com>
Thanks for catching this. The change makes sense to me.
Reviewed-by: Julien Thierry <julien.thierry@arm.com>
> ---
> arch/arm64/kernel/sdei.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/arch/arm64/kernel/sdei.c b/arch/arm64/kernel/sdei.c
> index 5ba4465e44f0..ea94cf8f9dc6 100644
> --- a/arch/arm64/kernel/sdei.c
> +++ b/arch/arm64/kernel/sdei.c
> @@ -94,6 +94,9 @@ static bool on_sdei_normal_stack(unsigned long sp, struct stack_info *info)
> unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_normal_ptr);
> unsigned long high = low + SDEI_STACK_SIZE;
>
> + if (!low)
> + return false;
> +
> if (sp < low || sp >= high)
> return false;
>
> @@ -111,6 +114,9 @@ static bool on_sdei_critical_stack(unsigned long sp, struct stack_info *info)
> unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_critical_ptr);
> unsigned long high = low + SDEI_STACK_SIZE;
>
> + if (!low)
> + return false;
> +
> if (sp < low || sp >= high)
> return false;
>
>
--
Julien Thierry
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64: fix wrong check of on_sdei_stack in nmi context
2019-04-01 3:55 [PATCH] arm64: fix wrong check of on_sdei_stack in nmi context Wei Li
2019-04-01 9:49 ` Julien Thierry
@ 2019-04-01 10:32 ` Heyi Guo
2019-04-02 17:13 ` Catalin Marinas
2 siblings, 0 replies; 4+ messages in thread
From: Heyi Guo @ 2019-04-01 10:32 UTC (permalink / raw)
To: Wei Li, catalin.marinas, will.deacon, mark.rutland, labbott,
alex.popov, james.morse
Cc: wanghaibin 00208455, julien.thierry, linux-arm-kernel,
huawei.libin, guohanjun
On 2019/4/1 11:55, Wei Li wrote:
> When doing unwind_frame() in the context of pseudo nmi (need enable
> CONFIG_ARM64_PSEUDO_NMI), reaching the botton of the stack (fp == 0,
botton -> bottom?
Heyi
> pc != 0), function on_sdei_stack() will return true while the sdei acpi
> table is not inited in fact. This will cause a "NULL pointer dereference"
> oops when going on.
>
> Signed-off-by: Wei Li <liwei391@huawei.com>
> ---
> arch/arm64/kernel/sdei.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/arch/arm64/kernel/sdei.c b/arch/arm64/kernel/sdei.c
> index 5ba4465e44f0..ea94cf8f9dc6 100644
> --- a/arch/arm64/kernel/sdei.c
> +++ b/arch/arm64/kernel/sdei.c
> @@ -94,6 +94,9 @@ static bool on_sdei_normal_stack(unsigned long sp, struct stack_info *info)
> unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_normal_ptr);
> unsigned long high = low + SDEI_STACK_SIZE;
>
> + if (!low)
> + return false;
> +
> if (sp < low || sp >= high)
> return false;
>
> @@ -111,6 +114,9 @@ static bool on_sdei_critical_stack(unsigned long sp, struct stack_info *info)
> unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_critical_ptr);
> unsigned long high = low + SDEI_STACK_SIZE;
>
> + if (!low)
> + return false;
> +
> if (sp < low || sp >= high)
> return false;
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64: fix wrong check of on_sdei_stack in nmi context
2019-04-01 3:55 [PATCH] arm64: fix wrong check of on_sdei_stack in nmi context Wei Li
2019-04-01 9:49 ` Julien Thierry
2019-04-01 10:32 ` Heyi Guo
@ 2019-04-02 17:13 ` Catalin Marinas
2 siblings, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2019-04-02 17:13 UTC (permalink / raw)
To: Wei Li
Cc: mark.rutland, julien.thierry, will.deacon, james.morse,
huawei.libin, guohanjun, labbott, linux-arm-kernel, alex.popov
On Mon, Apr 01, 2019 at 11:55:57AM +0800, Wei Li wrote:
> When doing unwind_frame() in the context of pseudo nmi (need enable
> CONFIG_ARM64_PSEUDO_NMI), reaching the botton of the stack (fp == 0,
> pc != 0), function on_sdei_stack() will return true while the sdei acpi
> table is not inited in fact. This will cause a "NULL pointer dereference"
> oops when going on.
>
> Signed-off-by: Wei Li <liwei391@huawei.com>
Thanks. I'll queue it for -rc4.
--
Catalin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-04-02 17:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-01 3:55 [PATCH] arm64: fix wrong check of on_sdei_stack in nmi context Wei Li
2019-04-01 9:49 ` Julien Thierry
2019-04-01 10:32 ` Heyi Guo
2019-04-02 17:13 ` Catalin Marinas
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).