Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp569291rwr; Thu, 20 Apr 2023 03:33:05 -0700 (PDT) X-Google-Smtp-Source: AKy350Z8WITIlCsxiS0GOseU++L02vXJQidxPDgFjwMuBl91+6FJE1vrk0KrUlrI6ObLyEX2/0y/ X-Received: by 2002:a17:903:40cb:b0:1a6:9e53:950e with SMTP id t11-20020a17090340cb00b001a69e53950emr1011455pld.41.1681986785328; Thu, 20 Apr 2023 03:33:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681986785; cv=none; d=google.com; s=arc-20160816; b=ILx2XOxLIsYktb2478Yc1yBLzU0ZrsyNgjy6Bic0mPEG7c4cUoV/mER+Xs/LhtCVuL ebOp+/c9NXqaMvjQBC/8MwybVqyMVfVdu4IFKpIylpD1MqkysZ1D2sL4WofHKlUFEspV 2ivNLt5RsZpo13GU5WZyRQZeph03rcAeFYWpBgx1HkXJOuijaNSIQE8fQUI+rfJZKeQZ kiV8d436MZY1fqt3SfCLAcjxBFga76q4/Gu21F6u1nZ6salcIq5ZJZSXPTE7CyGGwKW/ oiz7X9l+kEk4p1KsOoFf3gd0Cy//Q6+poC0S9vzABPBogRKrzkH11AY3ny9S3PL6QANy WLvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=xHh4Hk5Wr59/VR6ozFS/iFZq7pLvic32jswlAbPFFNU=; b=xMaL3zQp+HwRLX4+kOebn4PUSHoABhwenpD9zfoPjBkrI3HUfzg7YPSOP4+RrCBGSg JWZklWWVouHee8Xh7hqCPkZ8D5noRx2rzJIHv4YAW6iB4TqoITb1HzfYgNVCkVlCMP3s dVmsASmtELWlOQwNV7CLVElsOnmVWmc+//7JfOsJrhh21/mCsJRUSzL9lb82BUePV8YO SXV85nvA+0v+T5uEB9vHaSi+CTub6WD+vbfUI/7spQCnoH+X4Bet+9YBbeFTMc64ULOU 5KiCiDgMb1c801EP+k9f3SuxKmU3RqzsLr0ZzRvVoQnL/zu8AFz+3sa/h0iEWIyflqE9 5mRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="c+zf/oqK"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b7-20020a170902d88700b0019ea9a23140si1477321plz.309.2023.04.20.03.32.41; Thu, 20 Apr 2023 03:33:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="c+zf/oqK"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234322AbjDTKZV (ORCPT + 99 others); Thu, 20 Apr 2023 06:25:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234644AbjDTKYX (ORCPT ); Thu, 20 Apr 2023 06:24:23 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE8912D5D for ; Thu, 20 Apr 2023 03:22:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681986170; 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=xHh4Hk5Wr59/VR6ozFS/iFZq7pLvic32jswlAbPFFNU=; b=c+zf/oqKrWbC7asJzHP+skopR38D4atanek+Ti/ENHvRyi+C466jVv9fowVTpmF64W0+wE 2uL12ecHlbo8EyLuK9I/H8utRrPEv4zmyTPVbWns4e87T2H0qBeMZcB5zCmTYdKlfOl/In zYxcc09Pw3JSRfVMgdf2Qt7XKIF71FI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-368-1K4aE1vEMg2jHWaV3Oc8jg-1; Thu, 20 Apr 2023 06:22:39 -0400 X-MC-Unique: 1K4aE1vEMg2jHWaV3Oc8jg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BAB46101A531; Thu, 20 Apr 2023 10:22:38 +0000 (UTC) Received: from [10.39.208.29] (unknown [10.39.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D3D114020BEE; Thu, 20 Apr 2023 10:22:36 +0000 (UTC) Message-ID: Date: Thu, 20 Apr 2023 12:22:34 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [RFC 1/2] vduse: validate block features only with block devices Content-Language: en-US To: Jason Wang Cc: xieyongji@bytedance.com, mst@redhat.com, david.marchand@redhat.com, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, xuanzhuo@linux.alibaba.com, eperezma@redhat.com References: <20230419134329.346825-1-maxime.coquelin@redhat.com> <20230419134329.346825-2-maxime.coquelin@redhat.com> From: Maxime Coquelin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/20/23 06:06, Jason Wang wrote: > On Wed, Apr 19, 2023 at 9:43 PM Maxime Coquelin > wrote: >> >> 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. >> >> 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 0c3b48616a9f..6fa598a03d8e 100644 >> --- a/drivers/vdpa/vdpa_user/vduse_dev.c >> +++ b/drivers/vdpa/vdpa_user/vduse_dev.c >> @@ -1416,13 +1416,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))) > > The reason we filter WCE out is to avoid writable config space which > might block the driver with a buggy userspace. > > For networking, I guess we should fail if VERSION_1 is not negotiated, > then we can avoid setting mac addresses via the config space. Ok, I will add it to patch 2 in V1. Thanks, Maxime > > Thanks > >> return false; >> >> return true; >> @@ -1446,7 +1447,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.39.2 >> >