From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org,
syzbot+1e3ea63db39f2b4440e0@syzkaller.appspotmail.com,
Stefano Garzarella <sgarzare@redhat.com>,
Jason Wang <jasowang@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
syzbot+3140b17cb44a7b174008@syzkaller.appspotmail.com
Subject: [PATCH 4.9 02/29] vhost/vsock: dont check owner in vhost_vsock_stop() while releasing
Date: Mon, 28 Feb 2022 18:23:29 +0100 [thread overview]
Message-ID: <20220228172141.981731348@linuxfoundation.org> (raw)
In-Reply-To: <20220228172141.744228435@linuxfoundation.org>
From: Stefano Garzarella <sgarzare@redhat.com>
commit a58da53ffd70294ebea8ecd0eb45fd0d74add9f9 upstream.
vhost_vsock_stop() calls vhost_dev_check_owner() to check the device
ownership. It expects current->mm to be valid.
vhost_vsock_stop() is also called by vhost_vsock_dev_release() when
the user has not done close(), so when we are in do_exit(). In this
case current->mm is invalid and we're releasing the device, so we
should clean it anyway.
Let's check the owner only when vhost_vsock_stop() is called
by an ioctl.
When invoked from release we can not fail so we don't check return
code of vhost_vsock_stop(). We need to stop vsock even if it's not
the owner.
Fixes: 433fc58e6bf2 ("VSOCK: Introduce vhost_vsock.ko")
Cc: stable@vger.kernel.org
Reported-by: syzbot+1e3ea63db39f2b4440e0@syzkaller.appspotmail.com
Reported-and-tested-by: syzbot+3140b17cb44a7b174008@syzkaller.appspotmail.com
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/vhost/vsock.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
--- a/drivers/vhost/vsock.c
+++ b/drivers/vhost/vsock.c
@@ -484,16 +484,18 @@ err:
return ret;
}
-static int vhost_vsock_stop(struct vhost_vsock *vsock)
+static int vhost_vsock_stop(struct vhost_vsock *vsock, bool check_owner)
{
size_t i;
- int ret;
+ int ret = 0;
mutex_lock(&vsock->dev.mutex);
- ret = vhost_dev_check_owner(&vsock->dev);
- if (ret)
- goto err;
+ if (check_owner) {
+ ret = vhost_dev_check_owner(&vsock->dev);
+ if (ret)
+ goto err;
+ }
for (i = 0; i < ARRAY_SIZE(vsock->vqs); i++) {
struct vhost_virtqueue *vq = &vsock->vqs[i];
@@ -611,7 +613,12 @@ static int vhost_vsock_dev_release(struc
* inefficient. Room for improvement here. */
vsock_for_each_connected_socket(vhost_vsock_reset_orphans);
- vhost_vsock_stop(vsock);
+ /* Don't check the owner, because we are in the release path, so we
+ * need to stop the vsock device in any case.
+ * vhost_vsock_stop() can not fail in this case, so we don't need to
+ * check the return code.
+ */
+ vhost_vsock_stop(vsock, false);
vhost_vsock_flush(vsock);
vhost_dev_stop(&vsock->dev);
@@ -709,7 +716,7 @@ static long vhost_vsock_dev_ioctl(struct
if (start)
return vhost_vsock_start(vsock);
else
- return vhost_vsock_stop(vsock);
+ return vhost_vsock_stop(vsock, true);
case VHOST_GET_FEATURES:
features = VHOST_VSOCK_FEATURES;
if (copy_to_user(argp, &features, sizeof(features)))
next prev parent reply other threads:[~2022-02-28 17:26 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-28 17:23 [PATCH 4.9 00/29] 4.9.304-rc1 review Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 01/29] mtd: rawnand: brcmnand: Fixed incorrect sub-page ECC status Greg Kroah-Hartman
2022-02-28 17:23 ` Greg Kroah-Hartman [this message]
2022-02-28 17:23 ` [PATCH 4.9 03/29] parisc/unaligned: Fix fldd and fstd unaligned handlers on 32-bit kernel Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 04/29] parisc/unaligned: Fix ldw() and stw() unalignment handlers Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 05/29] sr9700: sanity check for packet length Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 06/29] USB: zaurus: support another broken Zaurus Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 07/29] serial: 8250: fix error handling in of_platform_serial_probe() Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 08/29] serial: 8250: of: Fix mapped region size when using reg-offset property Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 09/29] net: __pskb_pull_tail() & pskb_carve_frag_list() drop_monitor friends Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 10/29] gso: do not skip outer ip header in case of ipip and net_failover Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 11/29] openvswitch: Fix setting ipv6 fields causing hw csum failure Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 12/29] drm/edid: Always set RGB444 Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 13/29] net/mlx5e: Fix wrong return value on ioctl EEPROM query failure Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 14/29] configfs: fix a race in configfs_{,un}register_subsystem() Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 15/29] RDMA/ib_srp: Fix a deadlock Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 16/29] iio: adc: men_z188_adc: Fix a resource leak in an error handling path Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 17/29] ata: pata_hpt37x: disable primary channel on HPT371 Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 18/29] Revert "USB: serial: ch341: add new Product ID for CH341A" Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 19/29] usb: gadget: rndis: add spinlock for rndis response list Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 20/29] USB: gadget: validate endpoint index for xilinx udc Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 21/29] tracefs: Set the group ownership in apply_options() not parse_options() Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 22/29] USB: serial: option: add support for DW5829e Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 23/29] USB: serial: option: add Telit LE910R1 compositions Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 24/29] usb: dwc3: gadget: Let the interrupt handler disable bottom halves Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 25/29] xhci: Prevent futile URB re-submissions due to incorrect return value Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 26/29] tty: n_gsm: fix encoding of control signal octet bit DV Greg Kroah-Hartman
2022-03-02 21:01 ` Pavel Machek
2022-02-28 17:23 ` [PATCH 4.9 27/29] tty: n_gsm: fix proper link termination after failed open Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 28/29] memblock: use kfree() to release kmalloced memblock regions Greg Kroah-Hartman
2022-02-28 17:23 ` [PATCH 4.9 29/29] fget: clarify and improve __fget_files() implementation Greg Kroah-Hartman
2022-02-28 21:24 ` [PATCH 4.9 00/29] 4.9.304-rc1 review Florian Fainelli
2022-02-28 21:43 ` Shuah Khan
2022-03-01 9:13 ` Jon Hunter
2022-03-01 17:06 ` Naresh Kamboju
2022-03-01 19:09 ` Guenter Roeck
2022-03-01 19:35 ` Slade Watkins
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220228172141.981731348@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=davem@davemloft.net \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sgarzare@redhat.com \
--cc=stable@vger.kernel.org \
--cc=syzbot+1e3ea63db39f2b4440e0@syzkaller.appspotmail.com \
--cc=syzbot+3140b17cb44a7b174008@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).