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 781F2C433EF for ; Wed, 2 Mar 2022 14:57:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243311AbiCBO6W (ORCPT ); Wed, 2 Mar 2022 09:58:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243298AbiCBO6S (ORCPT ); Wed, 2 Mar 2022 09:58:18 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 628D513DD7 for ; Wed, 2 Mar 2022 06:57:33 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id bg16-20020a05600c3c9000b00380f6f473b0so3456427wmb.1 for ; Wed, 02 Mar 2022 06:57:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=wGGyr8F/4yesRnDkleDkSeBi9/XbD7YGJTcIBLykmxo=; b=YAWW5HKlB7Eey/hbn/tEyKoY+Ej9P8bjmKwFJpG4WIH2K/pus2hP+RvzIjDv6V3z5p k6x5v3LHFzzK0yNYVc3/6rqsj7QQzSFP9PqTvboq8Gd2h2U5akBPL3gjR8Gis5rXW7a5 f5Wj0QWjydNWVbiao3cyHkss6w5fRltrK3+kbwT6yAe/CdOFs42vPOp9Mksavp1FhfDg b+8kmdCZBXU7N1sbqbnIx9h7JeO+bMDEWXRboAhQXSO6FrQS9Y2kIONVMIQBVPZeWrO0 GsIgMsxoTCsl6Mtqj6TTCwunX0DqqFgLwCazwzkBeT0HF1oYRmofMt0ZOyXz8dF5vh/a nxAQ== 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:content-transfer-encoding :in-reply-to; bh=wGGyr8F/4yesRnDkleDkSeBi9/XbD7YGJTcIBLykmxo=; b=kLC/Hp0XIRzKdXLioTbCC4YPEzxAXyLz3cKvnBlH2j5UH2gaAhkpGYyI+UEH0qMrz5 a/gB4dF+qtxh/SF0sMT+YlJvfsEWZ4dpbjhT8t0vmekcAl2kVw3/Qm+gm1hwptrZ1CKO QNpJmDK6yE7yR2wSXWD4A8GzAaZPfTrNT4pfHdGEcjZRqlAOYzf5GU4g+zUh9U4QD2w4 KkMDLqLkC3YEjydTRvckIgd8KrJMVRxEELjuAAbi/+EFz/x+Sd3wlqO7D+GpLUdrE+0L TZ6qqUfVThJ2nvv4E9Csdv36zJxxz/DKgemchumYLG/kQycnZZ/fF6VWW9fimwwuhuyV 6gsA== X-Gm-Message-State: AOAM531/IL2JUuSiVRVrnF7ifw3jm+VlnL825tDRo+n2GEkPX5BH9tog 6FH7H1rZQDYIDVjVJLqdjKC1MA== X-Google-Smtp-Source: ABdhPJxDjgY35zlNFNM4bX0OTXrJd0JfiswPqCzf7heVkctOxPWyBqq7cmIrMgVAjnLfYiYdzW+RlQ== X-Received: by 2002:a05:600c:40cf:b0:381:1f87:84c4 with SMTP id m15-20020a05600c40cf00b003811f8784c4mr102404wmh.181.1646233051757; Wed, 02 Mar 2022 06:57:31 -0800 (PST) Received: from google.com (cpc155339-bagu17-2-0-cust87.1-3.cable.virginm.net. [86.27.177.88]) by smtp.gmail.com with ESMTPSA id o204-20020a1ca5d5000000b0038331f2f951sm4751221wme.0.2022.03.02.06.57.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 06:57:31 -0800 (PST) Date: Wed, 2 Mar 2022 14:57:26 +0000 From: Lee Jones To: "Michael S. Tsirkin" 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: References: <20220302075421.2131221-1-lee.jones@linaro.org> <20220302082021-mutt-send-email-mst@kernel.org> <20220302095045-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220302095045-mutt-send-email-mst@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 02 Mar 2022, Michael S. Tsirkin wrote: > On Wed, Mar 02, 2022 at 01:56:35PM +0000, Lee Jones wrote: > > On Wed, 02 Mar 2022, Michael S. Tsirkin wrote: > > > > > 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? > > > > As a rework to this, or as a subsequent patch? > > Can be a separate patch. > > > Just before the first lock I assume? > > I guess so, yes. No problem. Patch to follow. I'm also going to attempt to debug the root cause, but I'm new to this subsystem to it might take a while for me to get my head around. -- Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog