From nobody Thu Sep 19 01:11:42 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=1720047226; cv=none; d=zohomail.com; s=zohoarc; b=KqWvPmK44gNBPxNR1Dud7fZqJ68REWe8TBZCwsUYdcPLF+gPZCNjJrz3y/hbExO2UTfbKBD21Q+ECIX7nDcgjIsnWdjg/R4OKAEFL6KH6BdPFPqZcwhVtoEIurrACq7Z9pdMDQRvdmNviukomWPaEZOoAxPGO1FrbjGwLSH0nwA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720047226; 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=QrTyYgO+P/l4LBdE4jQm9EUMOljixFZgw03WGI4si6s=; b=WJhxscqpz1HXPTjnTlZehNb0ihjrXVz3YWbrr68E0+nCanKWSW7cs49WbqGou6I66GoListrA1hC4WTCY3e5QZkIm+3dfGu8RJvgmWsqlSuLt11wSNg5s1CmvoD3TI1hlBOqGSrk7km1/dTGdtDxVYVKXmWbX1mcrh2MaawEFRI= 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 1720047226013383.0139720528797; Wed, 3 Jul 2024 15:53:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8lx-0008HR-IH; Wed, 03 Jul 2024 18:48:21 -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 1sP8lt-0007ob-Pa for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48:17 -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 1sP8lq-0003Um-Ho for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48:17 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-460-KcfLPtAVMDeyexIL6xLxGw-1; Wed, 03 Jul 2024 18:48:12 -0400 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a6fe837c066so9030066b.1 for ; Wed, 03 Jul 2024 15:48:11 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58612c835cfsm7582950a12.14.2024.07.03.15.48.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:48:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046893; 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=QrTyYgO+P/l4LBdE4jQm9EUMOljixFZgw03WGI4si6s=; b=e0afm35x2Dh5wCFs+8mzfmPJcwwN0K7uQBeGnr3lBitBqx+Iyk9/rxyOeAY3VO/PqO4Uw/ CN/LQ/RukjkQf8QqzJZk5/Rlq2VkEyM+LSOxSo6MIpEw2Qq70rlJeOT/7/TVa/o9d6CF9v LrIMPUpUjiziBMvJAjvC4RrxmVGcAQY= X-MC-Unique: KcfLPtAVMDeyexIL6xLxGw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046890; x=1720651690; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QrTyYgO+P/l4LBdE4jQm9EUMOljixFZgw03WGI4si6s=; b=KY6w+IOcdcF8J05o+2SzrjaCyNb2qFoMP68z23htHTuPINsihowipBAWr8oPhpuVnr WSsXKQIbNof6j8N4TxirJcNhBTFKvhu/faF4fBs/3UOi3OcyURB/m/la//6V8RA0Tp97 NFbcDtG6V8Cpq69sj64GZb2F7+KxiNBStXpMsgy1wAJaix6h1VBtTWzLef3dFmz9CQmb H0qF7Afl7ZZKbHuXdGqW7EruO0azzGKrhpEtdvY2DgJS6CKjHZYzRqqXkMOsMXV0Y1+8 N4tyBR28AYlE1cf9YBAZ3jn67hlxvr0UqqnktSTc3XavET+2Ko6J3n0L6OI49+YAWXAb hdbw== X-Gm-Message-State: AOJu0YwNE/Utbt85rkeePDThmrF5RFIw0sObAFB0wCr5w8c0fOHFqpe4 qgHpV0l0qtTjGBcSpiT4DAIOw8jfHWMdBkQkYo9yEUpv6lWIMiZB48KQ6mIyEtqfpK3aqZiTjqV 9SqiWCzWHfbW6J8/9XmxdT/tWedNGSrv3zlRxajRH7otam47eItNBfLHRjzY6VJqmDOu2CAGIrv cJZEd6P8mbo6/Di9noW+G1eoiJbPHxUg== X-Received: by 2002:a17:906:a259:b0:a6f:dd93:7ffb with SMTP id a640c23a62f3a-a77a2404383mr193536566b.1.1720046890242; Wed, 03 Jul 2024 15:48:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHig2bzfs8B101b6zoi98QMSZGI61PWTDRQjv0sU+bCjptEC+Uu7uhrnDLaOdxxA241+roeXA== X-Received: by 2002:a17:906:a259:b0:a6f:dd93:7ffb with SMTP id a640c23a62f3a-a77a2404383mr193534866b.1.1720046889731; Wed, 03 Jul 2024 15:48:09 -0700 (PDT) Date: Wed, 3 Jul 2024 18:48:05 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefano Garzarella , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , David Hildenbrand Subject: [PULL v3 49/85] libvhost-user: mask F_INFLIGHT_SHMFD if memfd is not supported Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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=mst@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.001, 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 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: 1720047226854100001 From: Stefano Garzarella 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 Message-Id: <20240618100043.144657-5-sgarzare@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- 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 ea27683dac..9c630c2170 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 MST