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 AEA07C433EF for ; Tue, 8 Mar 2022 08:10:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344824AbiCHILn (ORCPT ); Tue, 8 Mar 2022 03:11:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344929AbiCHILa (ORCPT ); Tue, 8 Mar 2022 03:11:30 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A037A3EBAE for ; Tue, 8 Mar 2022 00:10:10 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id e24so14129190wrc.10 for ; Tue, 08 Mar 2022 00:10:10 -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=bC4nX/4w2hAp8ne90xPCyTuVT60oAJGeczdCQbo0l3c=; b=QmDNjmplj+bPdQf7fQe47SUylL4K0+DMOKwd1ybuiZGCaFLMOK8TYpXB5AN6ao8waC 3RZ+8T5oBvLk7sE8SOLy3Vz1qthxs76QJ5vxuIzAQn2tIcCjEx/kMREVsJJ8aV8zKTVg H+F+0e0ovnAOA9t3tYMnV8ptAl5j9ZBM5bIKWPUDTYj1jx2IDv6Dcp/OPIkhOrvT1Iac sB/7dFSog87yqWl1RZnPK5SURyoAx5s88de7qeZCRoVaffTncrbKpLpjju3MFchUQ6KE gCpshgv7aHnKpeJNFdT71GJq6SZgRbqKt3YqoJwgKbGm57vDDUhGBEiKEsWqgdR+jPje ny/w== 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=bC4nX/4w2hAp8ne90xPCyTuVT60oAJGeczdCQbo0l3c=; b=qBP/DgFv7zUrJa6v28Gm4fU4gjzsJl0Zu4N7hBGsPNOzZQcOFhMWSvFuBJXE8DCdss uhr69QQfjr2O2PBeuJVmPIS6Rx7zOILUPM0V3RQoX8gEIm6eL0FY42YzdnAertBrxw5+ SsDNvkMWB/9I31kiOwLgRhQObE3HjtnWu0R6PfzQcNxetK4o8yn4epbOtIU4HwmvHokq /lf9TuRrOon9JD5pxtLyXGisiNDYmlXOa1Iqn3Ps9DFgI3idSSvuGyj6dDrm6J6N1fcx u4kjf/6YD6dzv2iYozHK7JwiM4KPiJ8Yzbyy+Fi+JwWLCzy3EBIZJCksDCbG5HKuvj/I iTbQ== X-Gm-Message-State: AOAM531VWpiKTgCgyMVXsdC3A1zgQkm2GahVq9pOz7/PtYL8QiVZLfsJ NRZXEvObqQnOOZzZf2Y8LYo25g== X-Google-Smtp-Source: ABdhPJzUt2KoS6npL3OLj00DKa4VkVnkLSkI4Qmgp881qSFd1k1FRRraWZrqYUd/ozCf3xX3VYvw8Q== X-Received: by 2002:adf:dcc2:0:b0:1f0:4c38:d6be with SMTP id x2-20020adfdcc2000000b001f04c38d6bemr11263420wrm.79.1646727008778; Tue, 08 Mar 2022 00:10:08 -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 f20-20020a05600c4e9400b003898e252cd4sm1555824wmq.12.2022.03.08.00.10.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 00:10:08 -0800 (PST) Date: Tue, 8 Mar 2022 08:10:06 +0000 From: Lee Jones To: Greg KH Cc: mst@redhat.com, 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: <20220307191757.3177139-1-lee.jones@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Mon, 07 Mar 2022, Greg KH wrote: > On Mon, Mar 07, 2022 at 07:17:57PM +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 here is take the same lock > > during virtqueue clean-up and we mitigate the reported issues. > > > > Also WARN() as a precautionary measure. The purpose of this is to > > capture possible future race conditions which may pop up over time. > > > > 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 | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > > > > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > > index 59edb5a1ffe28..ef7e371e3e649 100644 > > --- a/drivers/vhost/vhost.c > > +++ b/drivers/vhost/vhost.c > > @@ -693,6 +693,15 @@ void vhost_dev_cleanup(struct vhost_dev *dev) > > int i; > > > > for (i = 0; i < dev->nvqs; ++i) { > > + /* No workers should run here by design. However, races have > > + * previously occurred where drivers have been unable to flush > > + * all work properly prior to clean-up. Without a successful > > + * flush the guest will malfunction, but avoiding host memory > > + * corruption in those cases does seem preferable. > > + */ > > + WARN_ON(mutex_is_locked(&dev->vqs[i]->mutex)); > > So you are trading one syzbot triggered issue for another one in the > future? :) > > If this ever can happen, handle it, but don't log it with a WARN_ON() as > that will trigger the panic-on-warn boxes, as well as syzbot. Unless > you want that to happen? No, Syzbot doesn't report warnings, only BUGs and memory corruption. > And what happens if the mutex is locked _RIGHT_ after you checked it? > You still have a race... No, we miss a warning that one time. Memory is still protected. -- Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog