]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.4/arm-8839-1-kprobe-make-patch_lock-a-raw_spinlock_t.patch
autosel patches for 4.4
[thirdparty/kernel/stable-queue.git] / queue-4.4 / arm-8839-1-kprobe-make-patch_lock-a-raw_spinlock_t.patch
1 From 7aea42a7935dd29e1fc538a36104c6247472cd6a Mon Sep 17 00:00:00 2001
2 From: Yang Shi <yang.shi@linaro.org>
3 Date: Wed, 13 Feb 2019 17:14:23 +0100
4 Subject: ARM: 8839/1: kprobe: make patch_lock a raw_spinlock_t
5
6 [ Upstream commit 143c2a89e0e5fda6c6fd08d7bc1126438c19ae90 ]
7
8 When running kprobe on -rt kernel, the below bug is caught:
9
10 |BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:931
11 |in_atomic(): 1, irqs_disabled(): 128, pid: 14, name: migration/0
12 |Preemption disabled at:[<802f2b98>] cpu_stopper_thread+0xc0/0x140
13 |CPU: 0 PID: 14 Comm: migration/0 Tainted: G O 4.8.3-rt2 #1
14 |Hardware name: Freescale LS1021A
15 |[<8025a43c>] (___might_sleep)
16 |[<80b5b324>] (rt_spin_lock)
17 |[<80b5c31c>] (__patch_text_real)
18 |[<80b5c3ac>] (patch_text_stop_machine)
19 |[<802f2920>] (multi_cpu_stop)
20
21 Since patch_text_stop_machine() is called in stop_machine() which
22 disables IRQ, sleepable lock should be not used in this atomic context,
23 so replace patch_lock to raw lock.
24
25 Signed-off-by: Yang Shi <yang.shi@linaro.org>
26 Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
27 Reviewed-by: Arnd Bergmann <arnd@arndb.de>
28 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
29 Signed-off-by: Sasha Levin <sashal@kernel.org>
30 ---
31 arch/arm/kernel/patch.c | 6 +++---
32 1 file changed, 3 insertions(+), 3 deletions(-)
33
34 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
35 index 69bda1a5707e..1f665acaa6a9 100644
36 --- a/arch/arm/kernel/patch.c
37 +++ b/arch/arm/kernel/patch.c
38 @@ -15,7 +15,7 @@ struct patch {
39 unsigned int insn;
40 };
41
42 -static DEFINE_SPINLOCK(patch_lock);
43 +static DEFINE_RAW_SPINLOCK(patch_lock);
44
45 static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags)
46 __acquires(&patch_lock)
47 @@ -32,7 +32,7 @@ static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags)
48 return addr;
49
50 if (flags)
51 - spin_lock_irqsave(&patch_lock, *flags);
52 + raw_spin_lock_irqsave(&patch_lock, *flags);
53 else
54 __acquire(&patch_lock);
55
56 @@ -47,7 +47,7 @@ static void __kprobes patch_unmap(int fixmap, unsigned long *flags)
57 clear_fixmap(fixmap);
58
59 if (flags)
60 - spin_unlock_irqrestore(&patch_lock, *flags);
61 + raw_spin_unlock_irqrestore(&patch_lock, *flags);
62 else
63 __release(&patch_lock);
64 }
65 --
66 2.19.1
67