File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed
drivers/net/ethernet/broadcom/bnxt Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -8279,16 +8279,20 @@ static int bnxt_hwrm_func_qcfg(struct bnxt *bp)
82798279 if (rc )
82808280 goto func_qcfg_exit ;
82818281
8282+ flags = le16_to_cpu (resp -> flags );
82828283#ifdef CONFIG_BNXT_SRIOV
82838284 if (BNXT_VF (bp )) {
82848285 struct bnxt_vf_info * vf = & bp -> vf ;
82858286
82868287 vf -> vlan = le16_to_cpu (resp -> vlan ) & VLAN_VID_MASK ;
8288+ if (flags & FUNC_QCFG_RESP_FLAGS_TRUSTED_VF )
8289+ vf -> flags |= BNXT_VF_TRUST ;
8290+ else
8291+ vf -> flags &= ~BNXT_VF_TRUST ;
82878292 } else {
82888293 bp -> pf .registered_vfs = le16_to_cpu (resp -> registered_vfs );
82898294 }
82908295#endif
8291- flags = le16_to_cpu (resp -> flags );
82928296 if (flags & (FUNC_QCFG_RESP_FLAGS_FW_DCBX_AGENT_ENABLED |
82938297 FUNC_QCFG_RESP_FLAGS_FW_LLDP_AGENT_ENABLED )) {
82948298 bp -> fw_cap |= BNXT_FW_CAP_LLDP_AGENT ;
Original file line number Diff line number Diff line change @@ -2270,6 +2270,11 @@ struct bnxt {
22702270
22712271#define BNXT_PF (bp ) (!((bp)->flags & BNXT_FLAG_VF))
22722272#define BNXT_VF (bp ) ((bp)->flags & BNXT_FLAG_VF)
2273+ #ifdef CONFIG_BNXT_SRIOV
2274+ #define BNXT_VF_IS_TRUSTED (bp ) ((bp)->vf.flags & BNXT_VF_TRUST)
2275+ #else
2276+ #define BNXT_VF_IS_TRUSTED (bp ) 0
2277+ #endif
22732278#define BNXT_NPAR (bp ) ((bp)->port_partition_type)
22742279#define BNXT_MH (bp ) ((bp)->flags & BNXT_FLAG_MULTI_HOST)
22752280#define BNXT_SINGLE_PF (bp ) (BNXT_PF(bp) && !BNXT_NPAR(bp) && !BNXT_MH(bp))
Original file line number Diff line number Diff line change @@ -4375,6 +4375,9 @@ static int bnxt_get_module_info(struct net_device *dev,
43754375 struct bnxt * bp = netdev_priv (dev );
43764376 int rc ;
43774377
4378+ if (BNXT_VF (bp ) && !BNXT_VF_IS_TRUSTED (bp ))
4379+ return - EPERM ;
4380+
43784381 /* No point in going further if phy status indicates
43794382 * module is not inserted or if it is powered down or
43804383 * if it is of type 10GBase-T
@@ -4426,6 +4429,9 @@ static int bnxt_get_module_eeprom(struct net_device *dev,
44264429 u16 start = eeprom -> offset , length = eeprom -> len ;
44274430 int rc = 0 ;
44284431
4432+ if (BNXT_VF (bp ) && !BNXT_VF_IS_TRUSTED (bp ))
4433+ return - EPERM ;
4434+
44294435 memset (data , 0 , eeprom -> len );
44304436
44314437 /* Read A0 portion of the EEPROM */
@@ -4480,6 +4486,12 @@ static int bnxt_get_module_eeprom_by_page(struct net_device *dev,
44804486 struct bnxt * bp = netdev_priv (dev );
44814487 int rc ;
44824488
4489+ if (BNXT_VF (bp ) && !BNXT_VF_IS_TRUSTED (bp )) {
4490+ NL_SET_ERR_MSG_MOD (extack ,
4491+ "Module read not permitted on untrusted VF" );
4492+ return - EPERM ;
4493+ }
4494+
44834495 rc = bnxt_get_module_status (bp , extack );
44844496 if (rc )
44854497 return rc ;
You can’t perform that action at this time.
0 commit comments