Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4630798rdb; Tue, 12 Dec 2023 05:18:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEFlsbCkCSwloJ+Oqpvf2s9zRKtkgfz36UUxWqBi00Aghk0GmhQno3cNFBRbyV+1nH+6H9V X-Received: by 2002:a17:902:ab45:b0:1d3:3e7b:75de with SMTP id ij5-20020a170902ab4500b001d33e7b75demr338085plb.84.1702387105721; Tue, 12 Dec 2023 05:18:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702387105; cv=none; d=google.com; s=arc-20160816; b=r4zWJSm7BmERGfXOjKegulsDLKTKXew/cDZI7Y1NRXrxey6UfqFfP+9RdQkwbcQ2Ac kWhrakKLtx/sQZkWTyPkE5k+uND3lhKg+4S5SvyJRJOI7aHgnK7pmcKc1yFzegEt+Tsj 2YIG6Sj4nbQdvSH203B+4MblMV108Zqon9B8a6MAyofJGz2/tvYe18EZMe2LdZI4KtbP mCE23SCq2T3tdYybjpeYodMTb23XECHPvaNktnA6A7EIS9zqgjUVFVCy1KvokaPIoQFD dWCNfp5kvbyjlRE7NVaOo7b5Gwpr5RtjLnz2yegI/NCWrC/wkmtXQBCq76//hBAF/Lde oC3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Kbn/Pj7lGZv5FQhku3s01YJlXyJKSmX12DB6Cc5Zb3k=; fh=LxmBIMHLWtCjcf7wsP7T1D32SQqzEfF7erhVR43RAg4=; b=u6z5SYNynSHQ/NIfEsYkfws3wm4pRpySturXwS2h3lLUuoBLq3cBuHIa9lt10TV/Mx 7mT4hB8UNYseUo1RqETbsb1KFHy5DWORtgX+cr6PvHci6UE5lAnQbQGjKTCx9Cv+w65r E4uZiO7w1KVMmg89c1hGsZngW2IopFSEF5pNKBJErJ5XVRCQgiK2PISCr5Of+iYh80nD irznIpXRL+yHOZp9EjGLcZpZn526sMSiDdZ6Q02/GaiGRbdkNU/bglN5fcFg9ZMw8Sh/ nDsU4BA9fCYGYqOlEeh3bQHcXl0zPrRUkB+DGWb2jaX/uzOdexc96FnlKVfHKoE/ymag oYew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RIDTSKQt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id p16-20020a17090adf9000b00286ad92ab6fsi8887203pjv.185.2023.12.12.05.18.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 05:18:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RIDTSKQt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 00C748027070; Tue, 12 Dec 2023 05:18:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376681AbjLLNRh (ORCPT + 99 others); Tue, 12 Dec 2023 08:17:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376616AbjLLNRX (ORCPT ); Tue, 12 Dec 2023 08:17:23 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6016F115 for ; Tue, 12 Dec 2023 05:17:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702387048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Kbn/Pj7lGZv5FQhku3s01YJlXyJKSmX12DB6Cc5Zb3k=; b=RIDTSKQtyt/0vCclYSaCYcw+rEUtEude+BzAiqP0s/4apapYWvMr/0I+nDgOJ3AIWAo4eR wzP+fuNMGVXyaVqoFCLNx+uhIf9TWx1oK37dIpMjDVE1WCdXJo68OoibK6ccmEd52idWjw EXG7BhKfmo0jlqkZKANGIdCxyYUIW2k= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-267-r6trOJMmMXybz5kfVgFA4A-1; Tue, 12 Dec 2023 08:17:24 -0500 X-MC-Unique: r6trOJMmMXybz5kfVgFA4A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ED34928EC102; Tue, 12 Dec 2023 13:17:22 +0000 (UTC) Received: from max-p1.redhat.com (unknown [10.39.208.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id C38C31121306; Tue, 12 Dec 2023 13:17:19 +0000 (UTC) From: Maxime Coquelin To: mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, stephen.smalley.work@gmail.com, eparis@parisplace.org, xieyongji@bytedance.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org, david.marchand@redhat.com, lulu@redhat.com, casey@schaufler-ca.com Cc: Maxime Coquelin Subject: [PATCH v5 1/4] vduse: validate block features only with block devices Date: Tue, 12 Dec 2023 14:17:09 +0100 Message-ID: <20231212131712.1816324-2-maxime.coquelin@redhat.com> In-Reply-To: <20231212131712.1816324-1-maxime.coquelin@redhat.com> References: <20231212131712.1816324-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 12 Dec 2023 05:18:23 -0800 (PST) This patch is preliminary work to enable network device type support to VDUSE. As VIRTIO_BLK_F_CONFIG_WCE shares the same value as VIRTIO_NET_F_HOST_TSO4, we need to restrict its check to Virtio-blk device type. Acked-by: Jason Wang Reviewed-by: Xie Yongji Signed-off-by: Maxime Coquelin --- drivers/vdpa/vdpa_user/vduse_dev.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index 0ddd4b8abecb..0486ff672408 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1671,13 +1671,14 @@ static bool device_is_allowed(u32 device_id) return false; } -static bool features_is_valid(u64 features) +static bool features_is_valid(struct vduse_dev_config *config) { - if (!(features & (1ULL << VIRTIO_F_ACCESS_PLATFORM))) + if (!(config->features & (1ULL << VIRTIO_F_ACCESS_PLATFORM))) return false; /* Now we only support read-only configuration space */ - if (features & (1ULL << VIRTIO_BLK_F_CONFIG_WCE)) + if ((config->device_id == VIRTIO_ID_BLOCK) && + (config->features & (1ULL << VIRTIO_BLK_F_CONFIG_WCE))) return false; return true; @@ -1704,7 +1705,7 @@ static bool vduse_validate_config(struct vduse_dev_config *config) if (!device_is_allowed(config->device_id)) return false; - if (!features_is_valid(config->features)) + if (!features_is_valid(config)) return false; return true; -- 2.43.0