From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78ED6C433FE for ; Wed, 2 Mar 2022 13:31:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242242AbiCBNbw (ORCPT ); Wed, 2 Mar 2022 08:31:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242249AbiCBNbu (ORCPT ); Wed, 2 Mar 2022 08:31:50 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 95AEEBB57E for ; Wed, 2 Mar 2022 05:31:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646227866; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vpr93uN6MxOxe9fXO/50h3J2w847QD18h7MxHrR4EFI=; b=gNqtl+s2BIViCDXUkMidMP4/S33Nv5cVYoFHXJJDukdbRd6jIbYd9O4gLFmBf27wp3+AEK hAdSpBFD0urHap2+a+FrqCTI1Ro2W7v044H0T3fRr1vGMPa+W/SjkDOXXn56RClYCKZonb 53NNDElPAlnKG9WP7wz4Q22G8HeEai4= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-404-QKaF1uHDO06RJ0WXh-yMgw-1; Wed, 02 Mar 2022 08:31:05 -0500 X-MC-Unique: QKaF1uHDO06RJ0WXh-yMgw-1 Received: by mail-wr1-f70.google.com with SMTP id t8-20020adfa2c8000000b001e8f6889404so668758wra.0 for ; Wed, 02 Mar 2022 05:31:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=vpr93uN6MxOxe9fXO/50h3J2w847QD18h7MxHrR4EFI=; b=HCRUjux9FuZRjs24GQzslusxpp49dT7iW0fGdWCSKpKRmvCX4i4rm6QeCTkPPXOYTB nHkj5/Xffm/J48z/dJ7L1ixubZDUUE40qf9+BCtrk/bcqSg3C78Z/wajn3wY6GBHR2mG rTKe5Nu8aKwMoZRYok4fpUIcJskINRy/T0hO1VD7wxajXbXN5BgwH5eeZ4pd2bJGFkoI iMPaAvDZHbaEUeqRLiUVhX4EO8jFnhsFesipmna3vMvi7sJTRoS1+GTs1ESTSunjuRM4 NJ0oAho4Ln63Svt19AlVTcBR7T2Ji+Fe4m6b6c4Rf00ZVJc1brdGa6K2zbUipA1fYyzx N7hA== X-Gm-Message-State: AOAM530AagQ0yA9mTq5HXV8+1/2N67pkMLlLHAQrjWbExwUV3QCZLJ16 8qd8mbMT5vq4W/Dj6WTq7QfN9+6dOBvKJupWHyizONMb3nS18m/Q49d9Vu2OpI+XnqVSUcHJLWd iq8F1FOODyoKuP0oc X-Received: by 2002:a5d:4089:0:b0:1f0:4819:61ba with SMTP id o9-20020a5d4089000000b001f0481961bamr707043wrp.307.1646227862765; Wed, 02 Mar 2022 05:31:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJyB5w9pGnsT+Lg3Clzc3lJA6rrR//BxxGl8wdCoogL6jR5Pnb1QZrgmJ3q8QCWDn1myvFVNdQ== X-Received: by 2002:a5d:4089:0:b0:1f0:4819:61ba with SMTP id o9-20020a5d4089000000b001f0481961bamr706789wrp.307.1646227857681; Wed, 02 Mar 2022 05:30:57 -0800 (PST) Received: from redhat.com ([2a10:8006:355c:0:48d6:b937:2fb9:b7de]) by smtp.gmail.com with ESMTPSA id bi6-20020a05600c3d8600b00381590dbb25sm9721486wmb.3.2022.03.02.05.30.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 05:30:56 -0800 (PST) Date: Wed, 2 Mar 2022 08:30:54 -0500 From: "Michael S. Tsirkin" To: Lee Jones Cc: jasowang@redhat.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, stable@vger.kernel.org, syzbot+adc3cb32385586bec859@syzkaller.appspotmail.com Subject: Re: [PATCH 1/1] vhost: Protect the virtqueue from being cleared whilst still in use Message-ID: <20220302082021-mutt-send-email-mst@kernel.org> References: <20220302075421.2131221-1-lee.jones@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220302075421.2131221-1-lee.jones@linaro.org> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, Mar 02, 2022 at 07:54:21AM +0000, Lee Jones wrote: > vhost_vsock_handle_tx_kick() already holds the mutex during its call > to vhost_get_vq_desc(). All we have to do is take the same lock > during virtqueue clean-up and we mitigate the reported issues. > > Link: https://syzkaller.appspot.com/bug?extid=279432d30d825e63ba00 > > Cc: > Reported-by: syzbot+adc3cb32385586bec859@syzkaller.appspotmail.com > Signed-off-by: Lee Jones > --- > drivers/vhost/vhost.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > index 59edb5a1ffe28..bbaff6a5e21b8 100644 > --- a/drivers/vhost/vhost.c > +++ b/drivers/vhost/vhost.c > @@ -693,6 +693,7 @@ void vhost_dev_cleanup(struct vhost_dev *dev) > int i; > > for (i = 0; i < dev->nvqs; ++i) { > + mutex_lock(&dev->vqs[i]->mutex); > if (dev->vqs[i]->error_ctx) > eventfd_ctx_put(dev->vqs[i]->error_ctx); > if (dev->vqs[i]->kick) > @@ -700,6 +701,7 @@ void vhost_dev_cleanup(struct vhost_dev *dev) > if (dev->vqs[i]->call_ctx.ctx) > eventfd_ctx_put(dev->vqs[i]->call_ctx.ctx); > vhost_vq_reset(dev, dev->vqs[i]); > + mutex_unlock(&dev->vqs[i]->mutex); > } So this is a mitigation plan but the bug is still there though we don't know exactly what it is. I would prefer adding something like WARN_ON(mutex_is_locked(vqs[i]->mutex) here - does this make sense? > vhost_dev_free_iovecs(dev); > if (dev->log_ctx) > -- > 2.35.1.574.g5d30c73bfb-goog