arm64: fix wrong check of on_sdei_stack in nmi context
PATCH 1/1 arm64: fix wrong check of on_sdei_stack in nmi context
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.
--- arch/arm64/kernel/sdei.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/kernel/sdei.c +6 -0
@@ -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;
Signature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Wei,
Quoted 7 lines · Wei Li
When doing
unwind_frame()in the context of pseudo nmi (need enableCONFIG_ARM64_PSEUDO_NMI), reaching the botton of the stack (fp == 0, pc != 0), functionon_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 <[email protected]>
Thanks for catching this. The change makes sense to me.
Quoted 29 lines
--- arch/arm64/kernel/sdei.c | 6 ++++++ 1 file changed, 6 insertions(+)arch/arm64/kernel/sdei.c +6
-0@@ -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;
Signature · 6 lines
Julien Thierry _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 2 lines · Wei Li
When doing
unwind_frame()in the context of pseudo nmi (need enableCONFIG_ARM64_PSEUDO_NMI), reaching the botton of the stack (fp == 0,
botton -> bottom?
Heyi
Quoted 24 lines
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 <[email protected]>--- arch/arm64/kernel/sdei.c | 6 ++++++ 1 file changed, 6 insertions(+)arch/arm64/kernel/sdei.c +3
-0@@ -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;
arch/arm64/kernel/sdei.c static bool on_sdei_critical_stack(unsigned long sp, struct stack_info *info) · line 122
Quoted 9 lines
arch/arm64/kernel/sdei.c +3
-0@@ -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
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Catalin Marinas
maintainerQuoted 7 lines · Wei Li
When doing
unwind_frame()in the context of pseudo nmi (need enableCONFIG_ARM64_PSEUDO_NMI), reaching the botton of the stack (fp == 0, pc != 0), functionon_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 <[email protected]>
Thanks. I'll queue it for -rc4.
Signature · 6 lines
Catalin _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel