]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.0/xsysace-fix-error-handling-in-ace_setup.patch
Linux 4.19.41
[thirdparty/kernel/stable-queue.git] / queue-5.0 / xsysace-fix-error-handling-in-ace_setup.patch
1 From 5b8e4f8c89ee3038f3da3f29a52be8fb20b6b0f7 Mon Sep 17 00:00:00 2001
2 From: Guenter Roeck <linux@roeck-us.net>
3 Date: Tue, 19 Feb 2019 08:49:56 -0800
4 Subject: xsysace: Fix error handling in ace_setup
5
6 [ Upstream commit 47b16820c490149c2923e8474048f2c6e7557cab ]
7
8 If xace hardware reports a bad version number, the error handling code
9 in ace_setup() calls put_disk(), followed by queue cleanup. However, since
10 the disk data structure has the queue pointer set, put_disk() also
11 cleans and releases the queue. This results in blk_cleanup_queue()
12 accessing an already released data structure, which in turn may result
13 in a crash such as the following.
14
15 [ 10.681671] BUG: Kernel NULL pointer dereference at 0x00000040
16 [ 10.681826] Faulting instruction address: 0xc0431480
17 [ 10.682072] Oops: Kernel access of bad area, sig: 11 [#1]
18 [ 10.682251] BE PAGE_SIZE=4K PREEMPT Xilinx Virtex440
19 [ 10.682387] Modules linked in:
20 [ 10.682528] CPU: 0 PID: 1 Comm: swapper Tainted: G W 5.0.0-rc6-next-20190218+ #2
21 [ 10.682733] NIP: c0431480 LR: c043147c CTR: c0422ad8
22 [ 10.682863] REGS: cf82fbe0 TRAP: 0300 Tainted: G W (5.0.0-rc6-next-20190218+)
23 [ 10.683065] MSR: 00029000 <CE,EE,ME> CR: 22000222 XER: 00000000
24 [ 10.683236] DEAR: 00000040 ESR: 00000000
25 [ 10.683236] GPR00: c043147c cf82fc90 cf82ccc0 00000000 00000000 00000000 00000002 00000000
26 [ 10.683236] GPR08: 00000000 00000000 c04310bc 00000000 22000222 00000000 c0002c54 00000000
27 [ 10.683236] GPR16: 00000000 00000001 c09aa39c c09021b0 c09021dc 00000007 c0a68c08 00000000
28 [ 10.683236] GPR24: 00000001 ced6d400 ced6dcf0 c0815d9c 00000000 00000000 00000000 cedf0800
29 [ 10.684331] NIP [c0431480] blk_mq_run_hw_queue+0x28/0x114
30 [ 10.684473] LR [c043147c] blk_mq_run_hw_queue+0x24/0x114
31 [ 10.684602] Call Trace:
32 [ 10.684671] [cf82fc90] [c043147c] blk_mq_run_hw_queue+0x24/0x114 (unreliable)
33 [ 10.684854] [cf82fcc0] [c04315bc] blk_mq_run_hw_queues+0x50/0x7c
34 [ 10.685002] [cf82fce0] [c0422b24] blk_set_queue_dying+0x30/0x68
35 [ 10.685154] [cf82fcf0] [c0423ec0] blk_cleanup_queue+0x34/0x14c
36 [ 10.685306] [cf82fd10] [c054d73c] ace_probe+0x3dc/0x508
37 [ 10.685445] [cf82fd50] [c052d740] platform_drv_probe+0x4c/0xb8
38 [ 10.685592] [cf82fd70] [c052abb0] really_probe+0x20c/0x32c
39 [ 10.685728] [cf82fda0] [c052ae58] driver_probe_device+0x68/0x464
40 [ 10.685877] [cf82fdc0] [c052b500] device_driver_attach+0xb4/0xe4
41 [ 10.686024] [cf82fde0] [c052b5dc] __driver_attach+0xac/0xfc
42 [ 10.686161] [cf82fe00] [c0528428] bus_for_each_dev+0x80/0xc0
43 [ 10.686314] [cf82fe30] [c0529b3c] bus_add_driver+0x144/0x234
44 [ 10.686457] [cf82fe50] [c052c46c] driver_register+0x88/0x15c
45 [ 10.686610] [cf82fe60] [c09de288] ace_init+0x4c/0xac
46 [ 10.686742] [cf82fe80] [c0002730] do_one_initcall+0xac/0x330
47 [ 10.686888] [cf82fee0] [c09aafd0] kernel_init_freeable+0x34c/0x478
48 [ 10.687043] [cf82ff30] [c0002c6c] kernel_init+0x18/0x114
49 [ 10.687188] [cf82ff40] [c000f2f0] ret_from_kernel_thread+0x14/0x1c
50 [ 10.687349] Instruction dump:
51 [ 10.687435] 3863ffd4 4bfffd70 9421ffd0 7c0802a6 93c10028 7c9e2378 93e1002c 38810008
52 [ 10.687637] 7c7f1b78 90010034 4bfffc25 813f008c <81290040> 75290100 4182002c 80810008
53 [ 10.688056] ---[ end trace 13c9ff51d41b9d40 ]---
54
55 Fix the problem by setting the disk queue pointer to NULL before calling
56 put_disk(). A more comprehensive fix might be to rearrange the code
57 to check the hardware version before initializing data structures,
58 but I don't know if this would have undesirable side effects, and
59 it would increase the complexity of backporting the fix to older kernels.
60
61 Fixes: 74489a91dd43a ("Add support for Xilinx SystemACE CompactFlash interface")
62 Acked-by: Michal Simek <michal.simek@xilinx.com>
63 Signed-off-by: Guenter Roeck <linux@roeck-us.net>
64 Signed-off-by: Jens Axboe <axboe@kernel.dk>
65 Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
66 ---
67 drivers/block/xsysace.c | 2 ++
68 1 file changed, 2 insertions(+)
69
70 diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
71 index 87ccef4bd69e..32a21b8d1d85 100644
72 --- a/drivers/block/xsysace.c
73 +++ b/drivers/block/xsysace.c
74 @@ -1090,6 +1090,8 @@ static int ace_setup(struct ace_device *ace)
75 return 0;
76
77 err_read:
78 + /* prevent double queue cleanup */
79 + ace->gd->queue = NULL;
80 put_disk(ace->gd);
81 err_alloc_disk:
82 blk_cleanup_queue(ace->queue);
83 --
84 2.20.1
85