Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1028578pxb; Fri, 15 Apr 2022 18:52:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmwOU3yrVBIUhQVbwi0EARLZYLYhOFmXzorLMPanEwCI3XjCVyYroTf3EUX7AfjXkEso5e X-Received: by 2002:a17:902:c215:b0:153:8d90:a108 with SMTP id 21-20020a170902c21500b001538d90a108mr1674704pll.172.1650073967462; Fri, 15 Apr 2022 18:52:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650073967; cv=none; d=google.com; s=arc-20160816; b=TQ2nl2yqAbvqf+OGyTy2FaEJVNcqmo/ZEuUcTU3CxORwkeOqHp9hIm9c+GkqqlbC7q 3BjQuWpgFrUkHKL0q125S1srcLNB22sbAYkMsXlRZJjNsZPut5D6RR2lyzdu64vdAY/D Tyu7/VzP9+qqSjJP3w1Q+GkdfDbfeDWwwA09NojZvde2LCAgFKKMl4GDS1Mh2OOo51L9 eJPJRBphTwHhUAZ6k9Rdap1lkzIEjnxHmj46kYS7SmJHm9aWyHKCl+Fsvb0DaAudoA3J S1QrxA9OO+xIEyTcp7VufHXepeyK1RDIysDWYC1PlevcGgiRYxsWZGDC4/S+pMAvYqK/ k0GA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5TOAbxh3NZDFWBIaeLv+3Jo1nWFwQqo/5/P4ygdmvIM=; b=z0NQF48QYFDV60vyTzZ0XFjhTJIl2qdaAa98bPBlkAqgoZZGAYkLCHzRD05A81ADEf +tDgR6LUQzTfIWN527YJuE8c5bee4/GCtHWUKTLo/b/XONO5a/XTsSlTK4ZpTrZizMUu 9tUJ5FlRn36LTwsH90tJlXsEXZoXIa8/ZfPj5d5NqRmXPWC3kyIrJzG/ms5aWShgZxL0 AbTHxHPhd6nREx663fGsqpHf5LEpZxC2TwyG+az+RIw1g+FwZrOQaJfDl5tCgy4b0gI2 +Dzd9uVK/95tMLhpi6gr0zelsL8YZ/oCQYMHi3F2PpP9XyUru+2+ChzqSGI+/aoNPTDy KS6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Iefce4ZK; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u63-20020a637942000000b003a24866dc00si3010634pgc.696.2022.04.15.18.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 18:52:47 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Iefce4ZK; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 49457AAB69; Fri, 15 Apr 2022 18:14:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243861AbiDNNUo (ORCPT + 99 others); Thu, 14 Apr 2022 09:20:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243873AbiDNNTD (ORCPT ); Thu, 14 Apr 2022 09:19:03 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 541D591AD9; Thu, 14 Apr 2022 06:16:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 02DFAB82981; Thu, 14 Apr 2022 13:16:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C4A8C385A1; Thu, 14 Apr 2022 13:16:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649942174; bh=xzu+s2ywCeLAoEzKldWQcGxNKVPhhlA9OwVIgCkHXGI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Iefce4ZKPVXN6XN9YaNcolNKOtDCkhSl8iVUfp5e/k3svAlGWdWp5Tr2CwDHM5CVE peyemcVQAh2ZimViSjeIhT7igs3Ddl5XZ9PDyk77OMf39IsH5Ko69DVRY4BMu7enEm bs+fRHTsibAwBPPRw7dToNDrXbdRZfaeCTJElPO8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Manish Chopra , Ariel Elior , "David S. Miller" Subject: [PATCH 4.19 041/338] qed: validate and restrict untrusted VFs vlan promisc mode Date: Thu, 14 Apr 2022 15:09:04 +0200 Message-Id: <20220414110840.065530217@linuxfoundation.org> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220414110838.883074566@linuxfoundation.org> References: <20220414110838.883074566@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Manish Chopra commit cbcc44db2cf7b836896733acc0e5ea966136ed22 upstream. Today when VFs are put in promiscuous mode, they can request PF to configure device for them to receive all VLANs traffic regardless of what vlan is configured by the PF (via ip link) and PF allows this config request regardless of whether VF is trusted or not. >From security POV, when VLAN is configured for VF through PF (via ip link), honour such config requests from VF only when they are configured to be trusted, otherwise restrict such VFs vlan promisc mode config. Cc: stable@vger.kernel.org Fixes: f990c82c385b ("qed*: Add support for ndo_set_vf_trust") Signed-off-by: Manish Chopra Signed-off-by: Ariel Elior Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/qlogic/qed/qed_sriov.c | 28 ++++++++++++++++++++++++++-- drivers/net/ethernet/qlogic/qed/qed_sriov.h | 1 + 2 files changed, 27 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/qlogic/qed/qed_sriov.c +++ b/drivers/net/ethernet/qlogic/qed/qed_sriov.c @@ -3002,12 +3002,16 @@ static int qed_iov_pre_update_vport(stru u8 mask = QED_ACCEPT_UCAST_UNMATCHED | QED_ACCEPT_MCAST_UNMATCHED; struct qed_filter_accept_flags *flags = ¶ms->accept_flags; struct qed_public_vf_info *vf_info; + u16 tlv_mask; + + tlv_mask = BIT(QED_IOV_VP_UPDATE_ACCEPT_PARAM) | + BIT(QED_IOV_VP_UPDATE_ACCEPT_ANY_VLAN); /* Untrusted VFs can't even be trusted to know that fact. * Simply indicate everything is configured fine, and trace * configuration 'behind their back'. */ - if (!(*tlvs & BIT(QED_IOV_VP_UPDATE_ACCEPT_PARAM))) + if (!(*tlvs & tlv_mask)) return 0; vf_info = qed_iov_get_public_vf_info(hwfn, vfid, true); @@ -3024,6 +3028,13 @@ static int qed_iov_pre_update_vport(stru flags->tx_accept_filter &= ~mask; } + if (params->update_accept_any_vlan_flg) { + vf_info->accept_any_vlan = params->accept_any_vlan; + + if (vf_info->forced_vlan && !vf_info->is_trusted_configured) + params->accept_any_vlan = false; + } + return 0; } @@ -5140,6 +5151,12 @@ static void qed_iov_handle_trust_change( params.update_ctl_frame_check = 1; params.mac_chk_en = !vf_info->is_trusted_configured; + params.update_accept_any_vlan_flg = 0; + + if (vf_info->accept_any_vlan && vf_info->forced_vlan) { + params.update_accept_any_vlan_flg = 1; + params.accept_any_vlan = vf_info->accept_any_vlan; + } if (vf_info->rx_accept_mode & mask) { flags->update_rx_mode_config = 1; @@ -5155,13 +5172,20 @@ static void qed_iov_handle_trust_change( if (!vf_info->is_trusted_configured) { flags->rx_accept_filter &= ~mask; flags->tx_accept_filter &= ~mask; + params.accept_any_vlan = false; } if (flags->update_rx_mode_config || flags->update_tx_mode_config || - params.update_ctl_frame_check) + params.update_ctl_frame_check || + params.update_accept_any_vlan_flg) { + DP_VERBOSE(hwfn, QED_MSG_IOV, + "vport update config for %s VF[abs 0x%x rel 0x%x]\n", + vf_info->is_trusted_configured ? "trusted" : "untrusted", + vf->abs_vf_id, vf->relative_vf_id); qed_sp_vport_update(hwfn, ¶ms, QED_SPQ_MODE_EBLOCK, NULL); + } } } --- a/drivers/net/ethernet/qlogic/qed/qed_sriov.h +++ b/drivers/net/ethernet/qlogic/qed/qed_sriov.h @@ -88,6 +88,7 @@ struct qed_public_vf_info { bool is_trusted_request; u8 rx_accept_mode; u8 tx_accept_mode; + bool accept_any_vlan; }; struct qed_iov_vf_init_params {