]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.45/xen-blkfront-use-a-right-index-when-checking-requests.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.45 / xen-blkfront-use-a-right-index-when-checking-requests.patch
CommitLineData
93c5a571
GKH
1From b15bd8cb37598afb2963f7eb9e2de468d2d60a2f Mon Sep 17 00:00:00 2001
2From: Munehisa Kamata <kamatam@amazon.com>
3Date: Wed, 9 Aug 2017 15:31:40 -0700
4Subject: xen-blkfront: use a right index when checking requests
5
6From: Munehisa Kamata <kamatam@amazon.com>
7
8commit b15bd8cb37598afb2963f7eb9e2de468d2d60a2f upstream.
9
10Since commit d05d7f40791c ("Merge branch 'for-4.8/core' of
11git://git.kernel.dk/linux-block") and 3fc9d690936f ("Merge branch
12'for-4.8/drivers' of git://git.kernel.dk/linux-block"), blkfront_resume()
13has been using an index for iterating ring_info to check request when
14iterating blk_shadow in an inner loop. This seems to have been
15accidentally introduced during the massive rewrite of the block layer
16macros in the commits.
17
18This may cause crash like this:
19
20[11798.057074] BUG: unable to handle kernel NULL pointer dereference at 0000000000000048
21[11798.058832] IP: [<ffffffff814411fa>] blkfront_resume+0x10a/0x610
22....
23[11798.061063] Call Trace:
24[11798.061063] [<ffffffff8139ce93>] xenbus_dev_resume+0x53/0x140
25[11798.061063] [<ffffffff8139ce40>] ? xenbus_dev_probe+0x150/0x150
26[11798.061063] [<ffffffff813f359e>] dpm_run_callback+0x3e/0x110
27[11798.061063] [<ffffffff813f3a08>] device_resume+0x88/0x190
28[11798.061063] [<ffffffff813f4cc0>] dpm_resume+0x100/0x2d0
29[11798.061063] [<ffffffff813f5221>] dpm_resume_end+0x11/0x20
30[11798.061063] [<ffffffff813950a8>] do_suspend+0xe8/0x1a0
31[11798.061063] [<ffffffff813954bd>] shutdown_handler+0xfd/0x130
32[11798.061063] [<ffffffff8139aba0>] ? split+0x110/0x110
33[11798.061063] [<ffffffff8139ac26>] xenwatch_thread+0x86/0x120
34[11798.061063] [<ffffffff810b4570>] ? prepare_to_wait_event+0x110/0x110
35[11798.061063] [<ffffffff8108fe57>] kthread+0xd7/0xf0
36[11798.061063] [<ffffffff811da811>] ? kfree+0x121/0x170
37[11798.061063] [<ffffffff8108fd80>] ? kthread_park+0x60/0x60
38[11798.061063] [<ffffffff810863b0>] ? call_usermodehelper_exec_work+0xb0/0xb0
39[11798.061063] [<ffffffff810864ea>] ? call_usermodehelper_exec_async+0x13a/0x140
40[11798.061063] [<ffffffff81534a45>] ret_from_fork+0x25/0x30
41
42Use the right index in the inner loop.
43
44Fixes: d05d7f40791c ("Merge branch 'for-4.8/core' of git://git.kernel.dk/linux-block")
45Fixes: 3fc9d690936f ("Merge branch 'for-4.8/drivers' of git://git.kernel.dk/linux-block")
46Signed-off-by: Munehisa Kamata <kamatam@amazon.com>
47Reviewed-by: Thomas Friebel <friebelt@amazon.de>
48Reviewed-by: Eduardo Valentin <eduval@amazon.com>
49Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
50Cc: Juergen Gross <jgross@suse.com>
51Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
52Reviewed-by: Roger Pau Monne <roger.pau@citrix.com>
53Cc: xen-devel@lists.xenproject.org
54Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
55Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
56
57---
58 drivers/block/xen-blkfront.c | 6 +++---
59 1 file changed, 3 insertions(+), 3 deletions(-)
60
61--- a/drivers/block/xen-blkfront.c
62+++ b/drivers/block/xen-blkfront.c
63@@ -2112,9 +2112,9 @@ static int blkfront_resume(struct xenbus
64 /*
65 * Get the bios in the request so we can re-queue them.
66 */
67- if (req_op(shadow[i].request) == REQ_OP_FLUSH ||
68- req_op(shadow[i].request) == REQ_OP_DISCARD ||
69- req_op(shadow[i].request) == REQ_OP_SECURE_ERASE ||
70+ if (req_op(shadow[j].request) == REQ_OP_FLUSH ||
71+ req_op(shadow[j].request) == REQ_OP_DISCARD ||
72+ req_op(shadow[j].request) == REQ_OP_SECURE_ERASE ||
73 shadow[j].request->cmd_flags & REQ_FUA) {
74 /*
75 * Flush operations don't contain bios, so