ixgbe: Add malicious driver detection support
Subsystems (2)
PATCH v2 1/1 ixgbe: Add malicious driver detection support
Add malicious driver detection (MDD) support for X550, X550em_a, and X550em_x devices.
MDD is a hardware SR-IOV security feature which the driver enables by default, but can be controlled on|off by ethtool set-priv-flags parameter. When enabled MDD disables a VF drivers transmit queue when a malformed descriptor is detected. The PF will log the event and re-enable the VF queue.
---
v2: Changed new function declarations to static.
drivers/net/ethernet/intel/ixgbe/ixgbe.h | 3 + drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c | 25 +++- drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 13 ++- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 6 + drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c | 50 ++++++++ drivers/net/ethernet/intel/ixgbe/ixgbe_type.h | 8 ++ drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c | 138 +++++++++++++++++++++++ 7 files changed, 241 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe.h +3 -0
@@ -563,6 +563,8 @@ struct ixgbe_mac_addr {#define IXGBE_TRY_LINK_TIMEOUT (4 * HZ)#define IXGBE_SFP_POLL_JIFFIES (2 * HZ)/* SFP poll every 2 seconds */ +#define IXGBE_MDD_Q_BITMAP_DEPTH 2 +/* board specific private data structure */ struct ixgbe_adapter {unsigned long active_vlans[BITS_TO_LONGS (VLAN_N_VID )];
@@ -603,6 +605,7 @@ struct ixgbe_adapter {#define IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER BIT(26)#define IXGBE_FLAG_DCB_CAPABLE BIT(27)#define IXGBE_FLAG_GENEVE_OFFLOAD_CAPABLE BIT(28) +#define IXGBE_FLAG_MDD_ENABLED BIT(29)u32 flags2;#define IXGBE_FLAG2_RSC_CAPABLE BIT(0)
drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c +24 -1
@@ -379,10 +379,22 @@ static u8 ixgbe_dcbnl_set_all(struct net_device *netdev) }else { hw->mac.ops.fc_enable (hw); } +/* Disable MDD before updating SRRCTL, because modifying the +* SRRCTL register while the queue is enabled will generate an +* MDD event. +*/ +if ((adapter->num_vfs) && (hw->mac.ops.disable_mdd) && + (adapter->flags &IXGBE_FLAG_MDD_ENABLED )) + hw->mac.ops.disable_mdd (hw);ixgbe_set_rx_drop_en (adapter); - ret =DCB_HW_CHG ; +if ((adapter->num_vfs) && (hw->mac.ops.enable_mdd) && + (adapter->flags &IXGBE_FLAG_MDD_ENABLED )) + hw->mac.ops.enable_mdd (hw); + +if (ret !=DCB_HW_CHG_RST ) + ret =DCB_HW_CHG ; }#ifdef IXGBE_FCOE
@@ -634,8 +646,19 @@ static int ixgbe_dcbnl_ieee_setpfc(struct net_device *dev,else err = hw->mac.ops.fc_enable (hw); +/* Disable MDD before updating SRRCTL, because modifying the SRRCTL +* register while the queue is enabled will generate an MDD event. +*/ +if ((adapter->num_vfs) && (hw->mac.ops.disable_mdd) && + (adapter->flags &IXGBE_FLAG_MDD_ENABLED )) + hw->mac.ops.disable_mdd (hw); +ixgbe_set_rx_drop_en (adapter); +if ((adapter->num_vfs) && (hw->mac.ops.enable_mdd) && + (adapter->flags &IXGBE_FLAG_MDD_ENABLED )) + hw->mac.ops.enable_mdd (hw); +return err; }
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +12 -1
@@ -157,6 +157,8 @@ static const char ixgbe_gstrings_test[][ETH_GSTRING_LEN] = {static const char ixgbe_priv_flags_strings[][ETH_GSTRING_LEN ] = { #define IXGBE_PRIV_FLAGS_LEGACY_RX BIT(0)"legacy-rx" , +#define IXGBE_PRIV_FLAG_MDD_ENABLED BIT(1) +"mdd" , };#define IXGBE_PRIV_FLAGS_STR_LEN ARRAY_SIZE(ixgbe_priv_flags_strings)
@@ -3420,6 +3422,9 @@ static u32 ixgbe_get_priv_flags(struct net_device *netdev)struct ixgbe_adapter *adapter =netdev_priv (netdev);u32 priv_flags =0 ; +if (adapter->flags &IXGBE_FLAG_MDD_ENABLED ) + priv_flags |=IXGBE_PRIV_FLAG_MDD_ENABLED ; +if (adapter->flags2 &IXGBE_FLAG2_RX_LEGACY ) priv_flags |=IXGBE_PRIV_FLAGS_LEGACY_RX ;
@@ -3430,13 +3435,19 @@ static int ixgbe_set_priv_flags(struct net_device *netdev, u32 priv_flags) {struct ixgbe_adapter *adapter =netdev_priv (netdev);unsigned int flags2 = adapter->flags2; +unsigned int flags = adapter->flags; + + flags &= ~IXGBE_FLAG_MDD_ENABLED ; +if (priv_flags &IXGBE_PRIV_FLAG_MDD_ENABLED ) + flags |=IXGBE_FLAG_MDD_ENABLED ; flags2 &= ~IXGBE_FLAG2_RX_LEGACY ;if (priv_flags &IXGBE_PRIV_FLAGS_LEGACY_RX ) flags2 |=IXGBE_FLAG2_RX_LEGACY ; -if (flags2 != adapter->flags2) { +if (flags2 != adapter->flags2 || flags != adapter->flags) { adapter->flags2 = flags2; + adapter->flags = flags;/* reset interface to repopulate queues */ if (netif_running (netdev))
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +6 -0
@@ -6101,6 +6101,7 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter, adapter->flags &= ~IXGBE_FLAG_DCA_CAPABLE ;#endif adapter->flags |=IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE ; + adapter->flags |=IXGBE_FLAG_MDD_ENABLED ;break ;default :break ;
@@ -7214,6 +7215,11 @@ static void ixgbe_watchdog_link_is_up(struct ixgbe_adapter *adapter)netif_carrier_on (netdev);ixgbe_check_vf_rate_limit (adapter); +/* Turn on malicious driver detection */ +if ((adapter->num_vfs) && (hw->mac.ops.enable_mdd) && + (adapter->flags &IXGBE_FLAG_MDD_ENABLED )) + hw->mac.ops.enable_mdd (hw); +/* enable transmits */ netif_tx_wake_all_queues (adapter->netdev);
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +50 -0
67 lines not on this page · raw message
drivers/net/ethernet/intel/ixgbe/ixgbe_type.h +8 -0
@@ -380,6 +380,8 @@ struct ixgbe_thermal_sensor_data {#define IXGBE_MRCTL (_i) (0x0F600 + ((_i) * 4))#define IXGBE_VMRVLAN (_i) (0x0F610 + ((_i) * 4))#define IXGBE_VMRVM (_i) (0x0F630 + ((_i) * 4)) +#define IXGBE_LVMMC_RX 0x2FA8 +#define IXGBE_LVMMC_TX 0x8108#define IXGBE_WQBR_RX (_i) (0x2FB0 + ((_i) * 4))/* 4 total */ #define IXGBE_WQBR_TX (_i) (0x8130 + ((_i) * 4))/* 4 total */ #define IXGBE_L34T_IMIR (_i) (0x0E800 + ((_i) * 4))/*128 of these (0-127)*/
@@ -3462,6 +3464,12 @@ struct ixgbe_mac_operations {s32 (*dmac_config_tcs)(struct ixgbe_hw *hw);s32 (*read_iosf_sb_reg)(struct ixgbe_hw *,u32 ,u32 ,u32 *);s32 (*write_iosf_sb_reg)(struct ixgbe_hw *,u32 ,u32 ,u32 ); + +/* Malicious driver detection */ +void (*disable_mdd)(struct ixgbe_hw *hw); +void (*enable_mdd)(struct ixgbe_hw *hw); +void (*mdd_event)(struct ixgbe_hw *hw,u32 *vf_bitmap); +void (*restore_mdd_vf)(struct ixgbe_hw *hw,u32 vf); };struct ixgbe_phy_operations {
drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c +138 -0
150 lines not on this page · raw message
Signature · 1 line
2.7.4
Bowers
PATCH v2 1/1 ixgbe: Add malicious driver detection support
Quoted 20 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Paul Greenwalt
Sent: Friday, June 9, 2017 7:57 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH v2] ixgbe: Add malicious driver detection supportAdd malicious driver detection (MDD) support for X550,
X550em_a, andX550em_xdevices.MDD is a hardware SR-IOV security feature which the driver enables by default, but can be controlled on|off by ethtool set-priv-flags parameter. When enabled MDD disables a VF drivers transmit queue when a malformed descriptor is detected. The PF will log the event and re-enable the VF queue.
Signed-off-by Paul Greenwalt <[email protected]>---
v2: Changed new function declarations to static.
Quoted 9 lines
drivers/net/ethernet/intel/ixgbe/ixgbe.h | 3 + drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c | 25 +++- drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 13 ++- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 6 + drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c | 50 ++++++++ drivers/net/ethernet/intel/ixgbe/ixgbe_type.h | 8 ++ drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c | 138 +++++++++++++++++++++++ 7 files changed, 241 insertions(+), 2 deletions(-)