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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E78AFC433EF for ; Mon, 17 Jan 2022 13:05:50 +0000 (UTC) Received: from localhost ([::1]:46708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n9Rhl-0004ao-Ec for qemu-devel@archiver.kernel.org; Mon, 17 Jan 2022 08:05:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9RBx-0000OX-St for qemu-devel@nongnu.org; Mon, 17 Jan 2022 07:33:00 -0500 Received: from [2a00:1450:4864:20::32b] (port=39719 helo=mail-wm1-x32b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n9RBb-0000Ig-NU for qemu-devel@nongnu.org; Mon, 17 Jan 2022 07:32:51 -0500 Received: by mail-wm1-x32b.google.com with SMTP id d18-20020a05600c251200b0034974323cfaso23971963wma.4 for ; Mon, 17 Jan 2022 04:32:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=hLuxJCNBsQa8zQWxGVgKvZBec57S5JksLr7FFGldYh8=; b=NfDKP2irVS6FGHYsYvxUtp45lKYlZRuwp+oiAxaJy0EkfmKiRnfqCDqM6OneZxxNJu SINS0PyFSwtvr194/v8K3IOVELq7ZoA6r/EO3BBSxGK6mRfwdtWPAvjXlYvuuoUHktrx Gz1DWk/0ce28y6ZVQV9KxTKNPIAIRfKlZZ9Cc2ZSW0/8ufluFQgzG75VInUE75Ryrfib QTLGIFKvm90GGufq7YrwuCtKYgY67GQrgiA9peFzMl6/u86pvZ915puLaYwianY5u7HB ElcdfYt1ugWiznbRBkhcSNwvD24Ea6GwIa7GN/VtYvpkvOgSfO/S7qwvMnPv5mKMMryL 0L7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=hLuxJCNBsQa8zQWxGVgKvZBec57S5JksLr7FFGldYh8=; b=kHwRlHssHsSu3NLY2oQ2vX7ba+xUPCv1Gixoh0cNVd1V31A4g/+NQV2WbHxhIDDsIh KlSKr83AbtJbsqpz84WQMz9ziFWOxQacvMLNcfvqzU/Iq342i0ZFql+0b1Y69tlUsUy3 uqUFVQuhfAgxD27q/TwQkUeVonJ3NiAl59hpJVhU8Dwy3vkxm/eIAYDdAjSxv14ADGeX y//noPNdMNsZV8wuKvu+01EfdAzEgD5lefS0AY2X6fpqYp71e6HNdkxRiykhvEdeoogZ D0ycPLJpW3ldUw/4Sip1a9F8k9bmFhsiFfkO106aEhWU1w3PKZfEFB/3N3xgSSn277dV WqPg== X-Gm-Message-State: AOAM533GmDQKd/jUCSzmitzJeEED1E/LbQRh4iWqi/OwbW+uJKskB+YK nO94+IJQEVwV4g+h4jVM0gw= X-Google-Smtp-Source: ABdhPJwzfAxj+2vSsCVHB2wTHyq/2DBUuFPd0OgmO84+pg0saL3anzgk2jh5nlguLuenkpI69JPnwg== X-Received: by 2002:a5d:560e:: with SMTP id l14mr19693648wrv.619.1642422752118; Mon, 17 Jan 2022 04:32:32 -0800 (PST) Received: from [192.168.1.40] (154.red-83-50-83.dynamicip.rima-tde.net. [83.50.83.154]) by smtp.gmail.com with ESMTPSA id r11sm16170789wrz.78.2022.01.17.04.32.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Jan 2022 04:32:31 -0800 (PST) Message-ID: <9da887d9-b2ad-82c1-e3af-1711b4a2d4ae@amsat.org> Date: Mon, 17 Jan 2022 13:32:30 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH v3 5/6] libvhost-user: prevent over-running max RAM slots Content-Language: en-US To: David Hildenbrand , Raphael Norwitz , "stefanha@redhat.com" , "marcandre.lureau@redhat.com" , "mst@redhat.com" Cc: "raphael.s.norwitz@gmail.com" , "qemu-devel@nongnu.org" References: <20220117041050.19718-1-raphael.norwitz@nutanix.com> <20220117041050.19718-6-raphael.norwitz@nutanix.com> <055d3a4e-521b-3f23-196a-40bdaeb96145@redhat.com> In-Reply-To: <055d3a4e-521b-3f23-196a-40bdaeb96145@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::32b (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x32b.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NICE_REPLY_A=-0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Reply-to: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= via On 1/17/22 09:20, David Hildenbrand wrote: > On 17.01.22 05:12, Raphael Norwitz wrote: >> When VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS support was added to >> libvhost-user, no guardrails were added to protect against QEMU >> attempting to hot-add too many RAM slots to a VM with a libvhost-user >> based backed attached. >> >> This change adds the missing error handling by introducing a check on >> the number of RAM slots the device has available before proceeding to >> process the VHOST_USER_ADD_MEM_REG message. >> >> Suggested-by: Stefan Hajnoczi >> Signed-off-by: Raphael Norwitz >> --- >> subprojects/libvhost-user/libvhost-user.c | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> + if (dev->nregions == VHOST_USER_MAX_RAM_SLOTS) { >> + close(vmsg->fds[0]); >> + vu_panic(dev, "failing attempt to hot add memory via " >> + "VHOST_USER_ADD_MEM_REG message because the backend has " >> + "no free ram slots available"); > > Maybe simply "VHOST_USER_ADD_MEM_REG failed because there are no free > ram slots" > > Reviewed-by: David Hildenbrand > Reviewed-by: Philippe Mathieu-Daudé