Skip to content

Commit cbcc44d

Browse files
manishc88davem330
authored andcommitted
qed: validate and restrict untrusted VFs vlan promisc mode
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: [email protected] Fixes: f990c82 ("qed*: Add support for ndo_set_vf_trust") Signed-off-by: Manish Chopra <[email protected]> Signed-off-by: Ariel Elior <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4e6e6be commit cbcc44d

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

drivers/net/ethernet/qlogic/qed/qed_sriov.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2984,12 +2984,16 @@ static int qed_iov_pre_update_vport(struct qed_hwfn *hwfn,
29842984
u8 mask = QED_ACCEPT_UCAST_UNMATCHED | QED_ACCEPT_MCAST_UNMATCHED;
29852985
struct qed_filter_accept_flags *flags = &params->accept_flags;
29862986
struct qed_public_vf_info *vf_info;
2987+
u16 tlv_mask;
2988+
2989+
tlv_mask = BIT(QED_IOV_VP_UPDATE_ACCEPT_PARAM) |
2990+
BIT(QED_IOV_VP_UPDATE_ACCEPT_ANY_VLAN);
29872991

29882992
/* Untrusted VFs can't even be trusted to know that fact.
29892993
* Simply indicate everything is configured fine, and trace
29902994
* configuration 'behind their back'.
29912995
*/
2992-
if (!(*tlvs & BIT(QED_IOV_VP_UPDATE_ACCEPT_PARAM)))
2996+
if (!(*tlvs & tlv_mask))
29932997
return 0;
29942998

29952999
vf_info = qed_iov_get_public_vf_info(hwfn, vfid, true);
@@ -3006,6 +3010,13 @@ static int qed_iov_pre_update_vport(struct qed_hwfn *hwfn,
30063010
flags->tx_accept_filter &= ~mask;
30073011
}
30083012

3013+
if (params->update_accept_any_vlan_flg) {
3014+
vf_info->accept_any_vlan = params->accept_any_vlan;
3015+
3016+
if (vf_info->forced_vlan && !vf_info->is_trusted_configured)
3017+
params->accept_any_vlan = false;
3018+
}
3019+
30093020
return 0;
30103021
}
30113022

@@ -5146,6 +5157,12 @@ static void qed_iov_handle_trust_change(struct qed_hwfn *hwfn)
51465157

51475158
params.update_ctl_frame_check = 1;
51485159
params.mac_chk_en = !vf_info->is_trusted_configured;
5160+
params.update_accept_any_vlan_flg = 0;
5161+
5162+
if (vf_info->accept_any_vlan && vf_info->forced_vlan) {
5163+
params.update_accept_any_vlan_flg = 1;
5164+
params.accept_any_vlan = vf_info->accept_any_vlan;
5165+
}
51495166

51505167
if (vf_info->rx_accept_mode & mask) {
51515168
flags->update_rx_mode_config = 1;
@@ -5161,13 +5178,20 @@ static void qed_iov_handle_trust_change(struct qed_hwfn *hwfn)
51615178
if (!vf_info->is_trusted_configured) {
51625179
flags->rx_accept_filter &= ~mask;
51635180
flags->tx_accept_filter &= ~mask;
5181+
params.accept_any_vlan = false;
51645182
}
51655183

51665184
if (flags->update_rx_mode_config ||
51675185
flags->update_tx_mode_config ||
5168-
params.update_ctl_frame_check)
5186+
params.update_ctl_frame_check ||
5187+
params.update_accept_any_vlan_flg) {
5188+
DP_VERBOSE(hwfn, QED_MSG_IOV,
5189+
"vport update config for %s VF[abs 0x%x rel 0x%x]\n",
5190+
vf_info->is_trusted_configured ? "trusted" : "untrusted",
5191+
vf->abs_vf_id, vf->relative_vf_id);
51695192
qed_sp_vport_update(hwfn, &params,
51705193
QED_SPQ_MODE_EBLOCK, NULL);
5194+
}
51715195
}
51725196
}
51735197

drivers/net/ethernet/qlogic/qed/qed_sriov.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ struct qed_public_vf_info {
6262
bool is_trusted_request;
6363
u8 rx_accept_mode;
6464
u8 tx_accept_mode;
65+
bool accept_any_vlan;
6566
};
6667

6768
struct qed_iov_vf_init_params {

0 commit comments

Comments
 (0)