diff mbox series

[4.9,3/8] arm64: fix for bad_mode() handler to always result in panic

Message ID 20191122105253.11375-3-lee.jones@linaro.org
State Superseded
Headers show
Series [4.9,1/8] ARM: 8904/1: skip nomap memblocks while finding the lowmem/highmem boundary | expand

Commit Message

Lee Jones Nov. 22, 2019, 10:52 a.m. UTC
From: Hari Vyas <hari.vyas@broadcom.com>


[ Upstream commit e4ba15debcfd27f60d43da940a58108783bff2a6 ]

The bad_mode() handler is called if we encounter an uunknown exception,
with the expectation that the subsequent call to panic() will halt the
system. Unfortunately, if the exception calling bad_mode() is taken from
EL0, then the call to die() can end up killing the current user task and
calling schedule() instead of falling through to panic().

Remove the die() call altogether, since we really want to bring down the
machine in this "impossible" case.

Signed-off-by: Hari Vyas <hari.vyas@broadcom.com>

Signed-off-by: Will Deacon <will.deacon@arm.com>

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

Signed-off-by: Lee Jones <lee.jones@linaro.org>

---
 arch/arm64/kernel/traps.c | 1 -
 1 file changed, 1 deletion(-)

-- 
2.24.0

Comments

Sasha Levin Nov. 25, 2019, 1:47 p.m. UTC | #1
On Fri, Nov 22, 2019 at 10:52:48AM +0000, Lee Jones wrote:
>From: Hari Vyas <hari.vyas@broadcom.com>

>

>[ Upstream commit e4ba15debcfd27f60d43da940a58108783bff2a6 ]

>

>The bad_mode() handler is called if we encounter an uunknown exception,

>with the expectation that the subsequent call to panic() will halt the

>system. Unfortunately, if the exception calling bad_mode() is taken from

>EL0, then the call to die() can end up killing the current user task and

>calling schedule() instead of falling through to panic().

>

>Remove the die() call altogether, since we really want to bring down the

>machine in this "impossible" case.


Should this be in newer LTS kernels too? I don't see it in 4.14. We
can't take anything into older kernels if it's not in newer ones - we
don't want to break users who update their kernels.

-- 
Thanks,
Sasha
Lee Jones Nov. 25, 2019, 2:44 p.m. UTC | #2
On Mon, 25 Nov 2019, Sasha Levin wrote:

> On Fri, Nov 22, 2019 at 10:52:48AM +0000, Lee Jones wrote:

> > From: Hari Vyas <hari.vyas@broadcom.com>

> > 

> > [ Upstream commit e4ba15debcfd27f60d43da940a58108783bff2a6 ]

> > 

> > The bad_mode() handler is called if we encounter an uunknown exception,

> > with the expectation that the subsequent call to panic() will halt the

> > system. Unfortunately, if the exception calling bad_mode() is taken from

> > EL0, then the call to die() can end up killing the current user task and

> > calling schedule() instead of falling through to panic().

> > 

> > Remove the die() call altogether, since we really want to bring down the

> > machine in this "impossible" case.

> 

> Should this be in newer LTS kernels too? I don't see it in 4.14. We

> can't take anything into older kernels if it's not in newer ones - we

> don't want to break users who update their kernels.


Only; 3.18, 4.4, 4.9 and 5.3 were studied.

I can look at others if it helps.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Greg Kroah-Hartman Nov. 25, 2019, 5:41 p.m. UTC | #3
On Mon, Nov 25, 2019 at 02:44:29PM +0000, Lee Jones wrote:
> On Mon, 25 Nov 2019, Sasha Levin wrote:

> 

> > On Fri, Nov 22, 2019 at 10:52:48AM +0000, Lee Jones wrote:

> > > From: Hari Vyas <hari.vyas@broadcom.com>

> > > 

> > > [ Upstream commit e4ba15debcfd27f60d43da940a58108783bff2a6 ]

> > > 

> > > The bad_mode() handler is called if we encounter an uunknown exception,

> > > with the expectation that the subsequent call to panic() will halt the

> > > system. Unfortunately, if the exception calling bad_mode() is taken from

> > > EL0, then the call to die() can end up killing the current user task and

> > > calling schedule() instead of falling through to panic().

> > > 

> > > Remove the die() call altogether, since we really want to bring down the

> > > machine in this "impossible" case.

> > 

> > Should this be in newer LTS kernels too? I don't see it in 4.14. We

> > can't take anything into older kernels if it's not in newer ones - we

> > don't want to break users who update their kernels.

> 

> Only; 3.18, 4.4, 4.9 and 5.3 were studied.

> 

> I can look at others if it helps.


You have to look at others, we can't have regressions if people move
from one LTS to a newer one.

thanks,

greg k-h
Lee Jones Nov. 25, 2019, 6:25 p.m. UTC | #4
On Mon, 25 Nov 2019, Greg KH wrote:

> On Mon, Nov 25, 2019 at 02:44:29PM +0000, Lee Jones wrote:

> > On Mon, 25 Nov 2019, Sasha Levin wrote:

> > 

> > > On Fri, Nov 22, 2019 at 10:52:48AM +0000, Lee Jones wrote:

> > > > From: Hari Vyas <hari.vyas@broadcom.com>

> > > > 

> > > > [ Upstream commit e4ba15debcfd27f60d43da940a58108783bff2a6 ]

> > > > 

> > > > The bad_mode() handler is called if we encounter an uunknown exception,

> > > > with the expectation that the subsequent call to panic() will halt the

> > > > system. Unfortunately, if the exception calling bad_mode() is taken from

> > > > EL0, then the call to die() can end up killing the current user task and

> > > > calling schedule() instead of falling through to panic().

> > > > 

> > > > Remove the die() call altogether, since we really want to bring down the

> > > > machine in this "impossible" case.

> > > 

> > > Should this be in newer LTS kernels too? I don't see it in 4.14. We

> > > can't take anything into older kernels if it's not in newer ones - we

> > > don't want to break users who update their kernels.

> > 

> > Only; 3.18, 4.4, 4.9 and 5.3 were studied.

> > 

> > I can look at others if it helps.

> 

> You have to look at others, we can't have regressions if people move

> from one LTS to a newer one.


Sure, I understand. Will do from now on.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Lee Jones Nov. 26, 2019, 1:49 p.m. UTC | #5
On Mon, 25 Nov 2019, Lee Jones wrote:

> On Mon, 25 Nov 2019, Greg KH wrote:

> 

> > On Mon, Nov 25, 2019 at 02:44:29PM +0000, Lee Jones wrote:

> > > On Mon, 25 Nov 2019, Sasha Levin wrote:

> > > 

> > > > On Fri, Nov 22, 2019 at 10:52:48AM +0000, Lee Jones wrote:

> > > > > From: Hari Vyas <hari.vyas@broadcom.com>

> > > > > 

> > > > > [ Upstream commit e4ba15debcfd27f60d43da940a58108783bff2a6 ]

> > > > > 

> > > > > The bad_mode() handler is called if we encounter an uunknown exception,

> > > > > with the expectation that the subsequent call to panic() will halt the

> > > > > system. Unfortunately, if the exception calling bad_mode() is taken from

> > > > > EL0, then the call to die() can end up killing the current user task and

> > > > > calling schedule() instead of falling through to panic().

> > > > > 

> > > > > Remove the die() call altogether, since we really want to bring down the

> > > > > machine in this "impossible" case.

> > > > 

> > > > Should this be in newer LTS kernels too? I don't see it in 4.14. We

> > > > can't take anything into older kernels if it's not in newer ones - we

> > > > don't want to break users who update their kernels.

> > > 

> > > Only; 3.18, 4.4, 4.9 and 5.3 were studied.

> > > 

> > > I can look at others if it helps.

> > 

> > You have to look at others, we can't have regressions if people move

> > from one LTS to a newer one.


Okay, now sent appropriate patches to linux-4.14.y and linux-4.19.y.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
diff mbox series

Patch

diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index 28bef94cf792..5962badb3346 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -611,7 +611,6 @@  asmlinkage void bad_mode(struct pt_regs *regs, int reason, unsigned int esr)
 		handler[reason], smp_processor_id(), esr,
 		esr_get_class_string(esr));
 
-	die("Oops - bad mode", regs, 0);
 	local_irq_disable();
 	panic("bad mode");
 }