From nobody Wed Sep 18 23:06:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1716892666; cv=none; d=zohomail.com; s=zohoarc; b=kIOW1qv9QOHHY5X+Z0TAh4Yv+/mx9TtZ30NF2yamVFSZnl6SvdKDgvAQq1O6lfnXw6RfDgFB66KpMaDxUwmjakeC1AnfLzLnKs6bS0FFkdsc2TIDhWK+s+foNvBt8T5LPacesQDT/vpfaXRnZm7H3REIpV95iDkMGRGu70aXGsM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716892666; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1S2/FREUTloncOeuDDrajxRNh9S3+Gj4t6YZDhkj1gc=; b=h8sg7rPWrUOl3UqSRtWWeFXlhIz0sRShTjf+XZt8UeU10Hn+XmWskdSlXknZz3UDcYQX/WJn2G6/bs+wW+xPFU6mYjOt/xgwGUd7urr9HHg8sp/dl9EzPAcPyzDDmkISjL+f5AIvucP0mASNq0AAQalR8msqDDUsLdmPcQ17Iio= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1716892666197628.9878437258205; Tue, 28 May 2024 03:37:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sBuBu-0004RU-9N; Tue, 28 May 2024 06:36:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sBuBb-0004Hj-OZ for qemu-devel@nongnu.org; Tue, 28 May 2024 06:36:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sBuBZ-0008Bk-0i for qemu-devel@nongnu.org; Tue, 28 May 2024 06:36:07 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-682-AbgRrUeLP3egJT5C4pfgyA-1; Tue, 28 May 2024 06:36:03 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-42109a85f5cso4638865e9.2 for ; Tue, 28 May 2024 03:36:03 -0700 (PDT) Received: from step1.redhat.com (host-79-53-30-109.retail.telecomitalia.it. [79.53.30.109]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35579d7dba2sm11244776f8f.17.2024.05.28.03.35.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 03:36:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716892564; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1S2/FREUTloncOeuDDrajxRNh9S3+Gj4t6YZDhkj1gc=; b=XdJ9IfzdSiPo6JAI3hPN0bDMcDdKxk4Epx9hxpNrAl59bztjPKc88vDxVukfubO+jj7/W+ BxUXBw9mRKM8wEvwPG17zLwVCgdnryIbZyVx+BrLVETToPp1JEkUNJtSPde8t8mKkXRokc b99RrEVMcysdGJmS4JJArykfEdwwVB0= X-MC-Unique: AbgRrUeLP3egJT5C4pfgyA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716892561; x=1717497361; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1S2/FREUTloncOeuDDrajxRNh9S3+Gj4t6YZDhkj1gc=; b=CPtuFxytrijp8joprFPvbRntR1DbISliBDT+vMUtRNrvNqRuY9C3mIvDJU5JUgPFaC Q+DK0oUhVb1n1n/78Ggm9eQmR9U1nnwyx6sGLkXjd69q5IngZQkBDUYlNwZT55wfw4Gl Dmvd51foP3lOP1yrQzB5QUtgVMCd5ioKDudxisHE9Ec46sfsEo28HEHtJEuR/e6d/ceH UiXfhGxhxYS4iqvRFJUxd4CySh3l73tQU1B8csLQyZa2HqT6jgK0H1gibH7i4nEHUaUB ljDMYVqT5RR6BxEtNWEOIpJk+e6PXUiulcxO2wT9HPDf8QhFB16dho/xTTFSCFjoLWrW Yd0w== X-Gm-Message-State: AOJu0YyWc2VY7Sw+uFzHZ3BxLKRcvRhYWp4kePJ/X8O+IwBYk/0w6V9J AHh8DufPnnVD354ehfXvaKxwBVozncGz8IX5iFst+evToggCWEKtSmWSQ0nCU8UrBbZs+16SkTO us0G/XKghPvOnyrizzysOdFYJtJGWeo82X1ily8Xteqo/B5jmU1TamoEgzML6u4w5V1PmTevCYg xF1rZ9TbR9ZR40wFX52Gvvl0a1uIh+1g8WUI22 X-Received: by 2002:a7b:ce8c:0:b0:41b:edf4:4071 with SMTP id 5b1f17b1804b1-42108aa6fc3mr136175265e9.35.1716892561665; Tue, 28 May 2024 03:36:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAHjoS3mWbS3S5UrzxHwxs2o/RE6gwgI0Ih4ab6GDi4TNszd+g85Axky2YD+4HZL6p13/6FA== X-Received: by 2002:a7b:ce8c:0:b0:41b:edf4:4071 with SMTP id 5b1f17b1804b1-42108aa6fc3mr136174815e9.35.1716892561256; Tue, 28 May 2024 03:36:01 -0700 (PDT) From: Stefano Garzarella To: qemu-devel@nongnu.org Cc: slp@redhat.com, David Hildenbrand , Paolo Bonzini , Eduardo Habkost , Igor Mammedov , Brad Smith , gmaglione@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier , Kevin Wolf , Jason Wang , "Michael S. Tsirkin" , Eric Blake , Markus Armbruster , Coiby Xu , qemu-block@nongnu.org, Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Raphael Norwitz , Thomas Huth , stefanha@redhat.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Gerd Hoffmann , Stefano Garzarella Subject: [PATCH v6 03/12] libvhost-user: mask F_INFLIGHT_SHMFD if memfd is not supported Date: Tue, 28 May 2024 12:35:34 +0200 Message-ID: <20240528103543.145412-4-sgarzare@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240528103543.145412-1-sgarzare@redhat.com> References: <20240528103543.145412-1-sgarzare@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=sgarzare@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.034, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1716892668186100003 libvhost-user will panic when receiving VHOST_USER_GET_INFLIGHT_FD message if MFD_ALLOW_SEALING is not defined, since it's not able to create a memfd. VHOST_USER_GET_INFLIGHT_FD is used only if VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD is negotiated. So, let's mask that feature if the backend is not able to properly handle these messages. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Stefan Hajnoczi Reviewed-by: David Hildenbrand Signed-off-by: Stefano Garzarella --- subprojects/libvhost-user/libvhost-user.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index a11afd1960..2c20cdc16e 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -1674,6 +1674,17 @@ vu_get_protocol_features_exec(VuDev *dev, VhostUserM= sg *vmsg) features |=3D dev->iface->get_protocol_features(dev); } =20 +#ifndef MFD_ALLOW_SEALING + /* + * If MFD_ALLOW_SEALING is not defined, we are not able to handle + * VHOST_USER_GET_INFLIGHT_FD messages, since we can't create a memfd. + * Those messages are used only if VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD + * is negotiated. A device implementation can enable it, so let's mask + * it to avoid a runtime panic. + */ + features &=3D ~(1ULL << VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD); +#endif + vmsg_set_reply_u64(vmsg, features); return true; } --=20 2.45.1