]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.15.17/vhost-correctly-remove-wait-queue-during-poll-failure.patch
Linux 4.14.95
[thirdparty/kernel/stable-queue.git] / releases / 4.15.17 / vhost-correctly-remove-wait-queue-during-poll-failure.patch
1 From foo@baz Tue Apr 10 23:19:36 CEST 2018
2 From: Jason Wang <jasowang@redhat.com>
3 Date: Tue, 27 Mar 2018 20:50:52 +0800
4 Subject: vhost: correctly remove wait queue during poll failure
5
6 From: Jason Wang <jasowang@redhat.com>
7
8
9 [ Upstream commit dc6455a71c7fc5117977e197f67f71b49f27baba ]
10
11 We tried to remove vq poll from wait queue, but do not check whether
12 or not it was in a list before. This will lead double free. Fixing
13 this by switching to use vhost_poll_stop() which zeros poll->wqh after
14 removing poll from waitqueue to make sure it won't be freed twice.
15
16 Cc: Darren Kenny <darren.kenny@oracle.com>
17 Reported-by: syzbot+c0272972b01b872e604a@syzkaller.appspotmail.com
18 Fixes: 2b8b328b61c79 ("vhost_net: handle polling errors when setting backend")
19 Signed-off-by: Jason Wang <jasowang@redhat.com>
20 Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
21 Acked-by: Michael S. Tsirkin <mst@redhat.com>
22 Signed-off-by: David S. Miller <davem@davemloft.net>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24 ---
25 drivers/vhost/vhost.c | 3 +--
26 1 file changed, 1 insertion(+), 2 deletions(-)
27
28 --- a/drivers/vhost/vhost.c
29 +++ b/drivers/vhost/vhost.c
30 @@ -213,8 +213,7 @@ int vhost_poll_start(struct vhost_poll *
31 if (mask)
32 vhost_poll_wakeup(&poll->wait, 0, 0, (void *)mask);
33 if (mask & POLLERR) {
34 - if (poll->wqh)
35 - remove_wait_queue(poll->wqh, &poll->wait);
36 + vhost_poll_stop(poll);
37 ret = -EINVAL;
38 }
39