Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4393520pxb; Mon, 21 Feb 2022 20:07:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJze7XWsKZ9TZ/1ZNwlonMTZy7pJxV0lNOiPG5LrS7eqCxeBCRxqs06obohOUOS/GC6CWP51 X-Received: by 2002:a63:155b:0:b0:374:3af8:3200 with SMTP id 27-20020a63155b000000b003743af83200mr6891385pgv.610.1645502866970; Mon, 21 Feb 2022 20:07:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1645502866; cv=pass; d=google.com; s=arc-20160816; b=AF/wMeMXv7GyIFGq58/lagn+evc0FxjmF0A9XUoF1mFv2r1c7R9o9sMXslUaBn6p4B Pjpl2PwcHMGfox00zI3ihoNqQFIFGaCesICFK7E0xfxisnMx7inz3bWMGWcw7q26IYyz zt7TvS54TKeint0QDb/zq81WHt9aOlPwR/NqEZUGM1cihL8Pr+xnkn+sqQRl132jGFof iH2PPG4EAib55SrCkWTGQPVB4u+dmqiNag5PFaUHThhnlPvJMBRnx4kysSVfgUL7bKa2 5gFynANmR8Z3ZLnlgTmFEmd7rFWv6Y2f18Hs1KZRpyNcp8sztqC1oGL842gWmPTAVYga MQng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=qgsrilDNczksuq7T/Z/KkzqksxwwWB5R95lUSLH4//U=; b=rs0Yv9BblFkfH88Ftik7Ex3wfEafeAC4bBQRBR4XvNl36tOaGRDeAjmwYNxKO/4J7R HjMQCfLfoY7pfxiN+zYz+dLi0+PZzCyW7mOoIIJ379KKwHE/p/f3S/AskUtQRjUh+2c0 QXKUWvV+3xhNjkQCe5UkquQAFScJEi7iPoGszofKtcrtAhB70zexpPOkwjGVCOQjTtbF 7cYWIvhckgrJ8PTHdlxGHYALKFJbbUjIpROM+w+H/JBhO4vhmu6LHaip2jXD5H1RSfFf RwWGJxRUTB2hqHhXUvf5jUMt8Wud8RdnSpF8i8y2ZrWAmniODHysxEzVpdJiPTmf8jqV OcnA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@anirudhrb.com header.s=zoho header.b=OmkZ9IRB; arc=pass (i=1 spf=pass spfdomain=anirudhrb.com dkim=pass dkdomain=anirudhrb.com dmarc=pass fromdomain=anirudhrb.com>); spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id x19si19988720pga.392.2022.02.21.20.07.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 20:07:46 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@anirudhrb.com header.s=zoho header.b=OmkZ9IRB; arc=pass (i=1 spf=pass spfdomain=anirudhrb.com dkim=pass dkdomain=anirudhrb.com dmarc=pass fromdomain=anirudhrb.com>); spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 08AD06C949; Mon, 21 Feb 2022 20:07:35 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233343AbiBUT6O (ORCPT + 99 others); Mon, 21 Feb 2022 14:58:14 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:37192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233319AbiBUT6L (ORCPT ); Mon, 21 Feb 2022 14:58:11 -0500 Received: from sender4-of-o53.zoho.com (sender4-of-o53.zoho.com [136.143.188.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC25C22531; Mon, 21 Feb 2022 11:57:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645473463; cv=none; d=zohomail.com; s=zohoarc; b=GFCIllRM0JXstnfQu9dNJpdQ1FXf/mLTbryY4AGBuFfplzvxcLxU4zEfUaqf0ex6Rmbtm1Zz1vaR/hGOQURrYCQJeIPi6uwz0i1vKck76P5vur4/2EmtxWnIiM0d6HqTvelA7XaGVFvGhqTzyqp5qzAYMmJL8BWht0P6WyWtyQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645473463; h=Content-Type:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=qgsrilDNczksuq7T/Z/KkzqksxwwWB5R95lUSLH4//U=; b=iVoUitgIWGeSz5o7a4BMa7xPpmJsb++7kuKpuYuszNg9N5QN4X2ZHnlV1VThC2Z13DGQwn20fimXqdbnIGs5SzS7BsOBsdnNVPUIsS+0bCP/FDRZPkTOkT3PSjJfdO712N95rzOlTKG/srj3b/pE1ReFvcui3poAhQIpi2YQ7Do= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=anirudhrb.com; spf=pass smtp.mailfrom=mail@anirudhrb.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1645473463; s=zoho; d=anirudhrb.com; i=mail@anirudhrb.com; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:Content-Type:In-Reply-To; bh=qgsrilDNczksuq7T/Z/KkzqksxwwWB5R95lUSLH4//U=; b=OmkZ9IRBCeIMYWEmEyk8ni0n+jZqP1SqJcMlER3IOqdAB9buvzG752p8HOB2DT+P pSXv5ZBk01wvMNfJ9lVi28rM2/t8LjesDFZTIzrt5ktfJAVQXxrYrEypdKaKzSXkDS5 UyI9TIwRnOg36eFZAkquCNhEWYZ1TKSwvcQ0lzyY= Received: from anirudhrb.com (49.207.206.107 [49.207.206.107]) by mx.zohomail.com with SMTPS id 1645473461841291.94881628695555; Mon, 21 Feb 2022 11:57:41 -0800 (PST) Date: Tue, 22 Feb 2022 01:27:35 +0530 From: Anirudh Rayabharam To: Stefano Garzarella Cc: "Michael S. Tsirkin" , Jason Wang , syzbot+0abd373e2e50d704db87@syzkaller.appspotmail.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] vhost: handle zero regions in vhost_set_memory Message-ID: References: <20220221072852.31820-1-mail@anirudhrb.com> <20220221164817.obpw477w74auxlkn@sgarzare-redhat> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220221164817.obpw477w74auxlkn@sgarzare-redhat> X-ZohoMailClient: External X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 21, 2022 at 05:48:17PM +0100, Stefano Garzarella wrote: > On Mon, Feb 21, 2022 at 12:58:51PM +0530, Anirudh Rayabharam wrote: > > Return early when userspace sends zero regions in the VHOST_SET_MEM_TABLE > > ioctl. > > > > Otherwise, this causes an erroneous entry to be added to the iotlb. This > > entry has a range size of 0 (due to u64 overflow). This then causes > > iotlb_access_ok() to loop indefinitely resulting in a hung thread. > > Syzbot has reported this here: > > > > https://syzkaller.appspot.com/bug?extid=0abd373e2e50d704db87 > > IIUC vhost_iotlb_add_range() in the for loop is never called if mem.nregions > is 0, so I'm not sure the problem reported by syzbot is related. > > In any case maybe this patch is fine, but currently I think we're just > registering an iotlb without any regions, which in theory shouldn't cause > any problems. Sent a new patch: https://lore.kernel.org/lkml/20220221195303.13560-1-mail@anirudhrb.com/T/#u > > Thanks, > Stefano > > > > > Reported-and-tested-by: syzbot+0abd373e2e50d704db87@syzkaller.appspotmail.com > > Signed-off-by: Anirudh Rayabharam > > --- > > drivers/vhost/vhost.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > > index 59edb5a1ffe2..821aba60eac2 100644 > > --- a/drivers/vhost/vhost.c > > +++ b/drivers/vhost/vhost.c > > @@ -1428,6 +1428,8 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m) > > return -EFAULT; > > if (mem.padding) > > return -EOPNOTSUPP; > > + if (mem.nregions == 0) > > + return 0; > > if (mem.nregions > max_mem_regions) > > return -E2BIG; > > newmem = kvzalloc(struct_size(newmem, regions, mem.nregions), > > -- > > 2.35.1 > > >