DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] i40e: workaround for Security issue in SR-IOV mode
@ 2015-09-25  8:44 Jingjing Wu
  2015-09-25 12:28 ` Vladislav Zolotarov
  2015-10-13  7:18 ` [dpdk-dev] [PATCH v2] i40e: Add a workaround to drop flow control frames from VFs Jingjing Wu
  0 siblings, 2 replies; 9+ messages in thread
From: Jingjing Wu @ 2015-09-25  8:44 UTC (permalink / raw)
  To: dev; +Cc: yulong.pei

In SR-IOV mode a VF sending LFC or PFC would throttle the entire port.
The workaround is to add a filter to drop pause frames from VFs from
sending pause frames.

Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 2dd9fdc..6cc2172 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -382,6 +382,30 @@ static inline void i40e_flex_payload_reg_init(struct i40e_hw *hw)
 	I40E_WRITE_REG(hw, I40E_GLQF_PIT(17), 0x00007440);
 }
 
+#define I40E_FLOW_CONTROL_ETHERTYPE  0x8808
+
+/*
+ * Add a ethertype filter to drop all flow control frames transimited
+ * from VSIs.
+*/
+static void
+i40e_add_tx_flow_control_drop_filter(struct i40e_pf *pf)
+{
+	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+	uint16_t flags = I40E_AQC_ADD_CONTROL_PACKET_FLAGS_IGNORE_MAC |
+			I40E_AQC_ADD_CONTROL_PACKET_FLAGS_DROP |
+			I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TX;
+	int ret;
+
+	ret = i40e_aq_add_rem_control_packet_filter(hw, NULL,
+				I40E_FLOW_CONTROL_ETHERTYPE, flags,
+				pf->main_vsi_seid, 0,
+				TRUE, NULL, NULL);
+	if (ret)
+		PMD_INIT_LOG(ERR, "Failed to add filter to drop flow control "
+				  " frames from VSIs.");
+}
+
 static int
 eth_i40e_dev_init(struct rte_eth_dev *dev)
 {
@@ -584,6 +608,12 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 
 	/* enable uio intr after callback register */
 	rte_intr_enable(&(pci_dev->intr_handle));
+	/*
+	 * Add a ethertype filter to drop all flow control frames transimited
+	 * from VSIs. This is used to workaround the issue -- in SR-IOV mode
+	 * where a VF sending LFC or PFC would throttle the entire port.
+	 */
+	i40e_add_tx_flow_control_drop_filter(pf);
 
 	/* initialize mirror rule list */
 	TAILQ_INIT(&pf->mirror_list);
-- 
2.4.0

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [dpdk-dev] [PATCH] i40e: workaround for Security issue in SR-IOV mode
  2015-09-25  8:44 [dpdk-dev] [PATCH] i40e: workaround for Security issue in SR-IOV mode Jingjing Wu
@ 2015-09-25 12:28 ` Vladislav Zolotarov
  2015-10-08  2:17   ` Wu, Jingjing
  2015-10-13  7:18 ` [dpdk-dev] [PATCH v2] i40e: Add a workaround to drop flow control frames from VFs Jingjing Wu
  1 sibling, 1 reply; 9+ messages in thread
From: Vladislav Zolotarov @ 2015-09-25 12:28 UTC (permalink / raw)
  To: Jingjing Wu; +Cc: dev, yulong.pei

On Sep 25, 2015 11:44 AM, "Jingjing Wu" <jingjing.wu@intel.com> wrote:
>
> In SR-IOV mode a VF sending LFC or PFC would throttle the entire port.
> The workaround is to add a filter to drop pause frames from VFs from
> sending pause frames.

This is a very strange approach - this would silently disable the Tx FC
while a user would think it's enabled. Wouldn't the right approach be to
let the user decide weather to enable this feature or even better - allow
PF to disable this feature in the VF?

>
> Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
> ---
>  drivers/net/i40e/i40e_ethdev.c | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
>
> diff --git a/drivers/net/i40e/i40e_ethdev.c
b/drivers/net/i40e/i40e_ethdev.c
> index 2dd9fdc..6cc2172 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
> @@ -382,6 +382,30 @@ static inline void i40e_flex_payload_reg_init(struct
i40e_hw *hw)
>         I40E_WRITE_REG(hw, I40E_GLQF_PIT(17), 0x00007440);
>  }
>
> +#define I40E_FLOW_CONTROL_ETHERTYPE  0x8808
> +
> +/*
> + * Add a ethertype filter to drop all flow control frames transimited
> + * from VSIs.
> +*/
> +static void
> +i40e_add_tx_flow_control_drop_filter(struct i40e_pf *pf)
> +{
> +       struct i40e_hw *hw = I40E_PF_TO_HW(pf);
> +       uint16_t flags = I40E_AQC_ADD_CONTROL_PACKET_FLAGS_IGNORE_MAC |
> +                       I40E_AQC_ADD_CONTROL_PACKET_FLAGS_DROP |
> +                       I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TX;
> +       int ret;
> +
> +       ret = i40e_aq_add_rem_control_packet_filter(hw, NULL,
> +                               I40E_FLOW_CONTROL_ETHERTYPE, flags,
> +                               pf->main_vsi_seid, 0,
> +                               TRUE, NULL, NULL);
> +       if (ret)
> +               PMD_INIT_LOG(ERR, "Failed to add filter to drop flow
control "
> +                                 " frames from VSIs.");
> +}
> +
>  static int
>  eth_i40e_dev_init(struct rte_eth_dev *dev)
>  {
> @@ -584,6 +608,12 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
>
>         /* enable uio intr after callback register */
>         rte_intr_enable(&(pci_dev->intr_handle));
> +       /*
> +        * Add a ethertype filter to drop all flow control frames
transimited
> +        * from VSIs. This is used to workaround the issue -- in SR-IOV
mode
> +        * where a VF sending LFC or PFC would throttle the entire port.
> +        */
> +       i40e_add_tx_flow_control_drop_filter(pf);
>
>         /* initialize mirror rule list */
>         TAILQ_INIT(&pf->mirror_list);
> --
> 2.4.0
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [dpdk-dev] [PATCH] i40e: workaround for Security issue in SR-IOV mode
  2015-09-25 12:28 ` Vladislav Zolotarov
@ 2015-10-08  2:17   ` Wu, Jingjing
  2015-10-08 14:53     ` Vlad Zolotarov
  0 siblings, 1 reply; 9+ messages in thread
From: Wu, Jingjing @ 2015-10-08  2:17 UTC (permalink / raw)
  To: Vladislav Zolotarov; +Cc: dev, Pei, Yulong

>>
>> In SR-IOV mode a VF sending LFC or PFC would throttle the entire port.
>> The workaround is to add a filter to drop pause frames from VFs from
>> sending pause frames.
>This is a very strange approach - this would silently disable the Tx FC while a user would think it's enabled. Wouldn't the right approach be to let the user decide weather to enable this feature or even better - allow PF to disable this feature in the VF? 

So, even we let VF sending Tx, it does not make sense at all.  As my understanding, Flow control is used for full-duplex point-to-point connections. How about VF? What is its peer for the point-to-point connect? So if we enable it, it will be a security risk if attacker sends FC on VFs. 

Thanks
Jingjing

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [dpdk-dev] [PATCH] i40e: workaround for Security issue in SR-IOV mode
  2015-10-08  2:17   ` Wu, Jingjing
@ 2015-10-08 14:53     ` Vlad Zolotarov
  0 siblings, 0 replies; 9+ messages in thread
From: Vlad Zolotarov @ 2015-10-08 14:53 UTC (permalink / raw)
  To: Wu, Jingjing; +Cc: dev, Pei, Yulong



On 10/08/15 05:17, Wu, Jingjing wrote:
>>> In SR-IOV mode a VF sending LFC or PFC would throttle the entire port.
>>> The workaround is to add a filter to drop pause frames from VFs from
>>> sending pause frames.
>> This is a very strange approach - this would silently disable the Tx FC while a user would think it's enabled. Wouldn't the right approach be to let the user decide weather to enable this feature or even better - allow PF to disable this feature in the VF?
> So, even we let VF sending Tx, it does not make sense at all.  As my understanding, Flow control is used for full-duplex point-to-point connections. How about VF? What is its peer for the point-to-point connect? So if we enable it, it will be a security risk if attacker sends FC on VFs.

I'll start start from the end: AFAIR FC frames are not forwarded, they 
only throttle the sender on the side that receives the PAUSE frame. 
Therefore it's quite trickery to create a PAUSE-frame attack as I see it 
- u'll have to hack the switch next to the host u attack. So, let's drop 
the "security" risk argument for now... ;)

Regarding VF sending FC frames being useless: this depends on the setup 
demands. If drops in the VF on the MAC level are not acceptable then it 
makes the whole lot of sense, just like it makes sense with a PF in the 
same situation. Of course, as a result the whole (switch) link will be 
throttled however that's the price to pay and System Administrators 
should be well aware of it.

If, on the other hand, System Administrator doesn't want FC it may just 
not enable it on this VF. If memory serves me well FC is disabled by 
default in DPDK.

thanks,
vlad

>
> Thanks
> Jingjing

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [dpdk-dev] [PATCH v2] i40e: Add a workaround to drop flow control frames from VFs
  2015-09-25  8:44 [dpdk-dev] [PATCH] i40e: workaround for Security issue in SR-IOV mode Jingjing Wu
  2015-09-25 12:28 ` Vladislav Zolotarov
@ 2015-10-13  7:18 ` Jingjing Wu
  2015-10-19  6:31   ` [dpdk-dev] [PATCH v3] " Jingjing Wu
  1 sibling, 1 reply; 9+ messages in thread
From: Jingjing Wu @ 2015-10-13  7:18 UTC (permalink / raw)
  To: dev; +Cc: yulong.pei

This patch adds a workaround to drop flow control frames from being
transmitted from VSIs.
With this patch in place a malicious VF cannot send flow control or PFC
packets out on the wire.

Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
v2:
 - reword comments

 drivers/net/i40e/i40e_ethdev.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 2dd9fdc..3d19f42 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -382,6 +382,30 @@ static inline void i40e_flex_payload_reg_init(struct i40e_hw *hw)
 	I40E_WRITE_REG(hw, I40E_GLQF_PIT(17), 0x00007440);
 }
 
+#define I40E_FLOW_CONTROL_ETHERTYPE  0x8808
+
+/*
+ * Add a ethertype filter to drop all flow control frames transimited
+ * from VSIs.
+*/
+static void
+i40e_add_tx_flow_control_drop_filter(struct i40e_pf *pf)
+{
+	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+	uint16_t flags = I40E_AQC_ADD_CONTROL_PACKET_FLAGS_IGNORE_MAC |
+			I40E_AQC_ADD_CONTROL_PACKET_FLAGS_DROP |
+			I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TX;
+	int ret;
+
+	ret = i40e_aq_add_rem_control_packet_filter(hw, NULL,
+				I40E_FLOW_CONTROL_ETHERTYPE, flags,
+				pf->main_vsi_seid, 0,
+				TRUE, NULL, NULL);
+	if (ret)
+		PMD_INIT_LOG(ERR, "Failed to add filter to drop flow control "
+				  " frames from VSIs.");
+}
+
 static int
 eth_i40e_dev_init(struct rte_eth_dev *dev)
 {
@@ -584,6 +608,12 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 
 	/* enable uio intr after callback register */
 	rte_intr_enable(&(pci_dev->intr_handle));
+	/*
+	 * Add an ethertype filter to drop all flow control frames transimited
+	 * from VSIs. By doing so, we stop VF from sening out PAUSE or PFC
+	 * frames to wire.
+	 */
+	i40e_add_tx_flow_control_drop_filter(pf);
 
 	/* initialize mirror rule list */
 	TAILQ_INIT(&pf->mirror_list);
-- 
2.4.0

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [dpdk-dev] [PATCH v3] i40e: Add a workaround to drop flow control frames from VFs
  2015-10-13  7:18 ` [dpdk-dev] [PATCH v2] i40e: Add a workaround to drop flow control frames from VFs Jingjing Wu
@ 2015-10-19  6:31   ` Jingjing Wu
  2015-10-19  8:31     ` Lu, Wenzhuo
  2015-10-30  5:31     ` Zhang, Helin
  0 siblings, 2 replies; 9+ messages in thread
From: Jingjing Wu @ 2015-10-19  6:31 UTC (permalink / raw)
  To: dev; +Cc: yulong.pei

This patch adds a workaround to drop flow control frames from being
transmitted from VSIs.
With this patch in place a malicious VF cannot send flow control or PFC
packets out on the wire.

Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
v3:
 - fix typo
v2:
 - reword comments

 drivers/net/i40e/i40e_ethdev.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 2dd9fdc..963e501 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -382,6 +382,30 @@ static inline void i40e_flex_payload_reg_init(struct i40e_hw *hw)
 	I40E_WRITE_REG(hw, I40E_GLQF_PIT(17), 0x00007440);
 }
 
+#define I40E_FLOW_CONTROL_ETHERTYPE  0x8808
+
+/*
+ * Add a ethertype filter to drop all flow control frames transmitted
+ * from VSIs.
+*/
+static void
+i40e_add_tx_flow_control_drop_filter(struct i40e_pf *pf)
+{
+	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+	uint16_t flags = I40E_AQC_ADD_CONTROL_PACKET_FLAGS_IGNORE_MAC |
+			I40E_AQC_ADD_CONTROL_PACKET_FLAGS_DROP |
+			I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TX;
+	int ret;
+
+	ret = i40e_aq_add_rem_control_packet_filter(hw, NULL,
+				I40E_FLOW_CONTROL_ETHERTYPE, flags,
+				pf->main_vsi_seid, 0,
+				TRUE, NULL, NULL);
+	if (ret)
+		PMD_INIT_LOG(ERR, "Failed to add filter to drop flow control "
+				  " frames from VSIs.");
+}
+
 static int
 eth_i40e_dev_init(struct rte_eth_dev *dev)
 {
@@ -584,6 +608,12 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 
 	/* enable uio intr after callback register */
 	rte_intr_enable(&(pci_dev->intr_handle));
+	/*
+	 * Add an ethertype filter to drop all flow control frames transmitted
+	 * from VSIs. By doing so, we stop VF from sending out PAUSE or PFC
+	 * frames to wire.
+	 */
+	i40e_add_tx_flow_control_drop_filter(pf);
 
 	/* initialize mirror rule list */
 	TAILQ_INIT(&pf->mirror_list);
-- 
2.4.0

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [dpdk-dev] [PATCH v3] i40e: Add a workaround to drop flow control frames from VFs
  2015-10-19  6:31   ` [dpdk-dev] [PATCH v3] " Jingjing Wu
@ 2015-10-19  8:31     ` Lu, Wenzhuo
  2015-10-30  5:31     ` Zhang, Helin
  1 sibling, 0 replies; 9+ messages in thread
From: Lu, Wenzhuo @ 2015-10-19  8:31 UTC (permalink / raw)
  To: Wu, Jingjing, dev; +Cc: Pei, Yulong

Hi,

> -----Original Message-----
> From: Wu, Jingjing
> Sent: Monday, October 19, 2015 2:32 PM
> To: dev@dpdk.org
> Cc: Wu, Jingjing; Lu, Wenzhuo; Pei, Yulong
> Subject: [PATCH v3] i40e: Add a workaround to drop flow control frames
> from VFs
> 
> This patch adds a workaround to drop flow control frames from being
> transmitted from VSIs.
> With this patch in place a malicious VF cannot send flow control or PFC
> packets out on the wire.
> 
> Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [dpdk-dev] [PATCH v3] i40e: Add a workaround to drop flow control frames from VFs
  2015-10-19  6:31   ` [dpdk-dev] [PATCH v3] " Jingjing Wu
  2015-10-19  8:31     ` Lu, Wenzhuo
@ 2015-10-30  5:31     ` Zhang, Helin
  2015-10-30 11:24       ` Thomas Monjalon
  1 sibling, 1 reply; 9+ messages in thread
From: Zhang, Helin @ 2015-10-30  5:31 UTC (permalink / raw)
  To: Wu, Jingjing, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jingjing Wu
> Sent: Monday, October 19, 2015 2:32 PM
> To: dev@dpdk.org
> Cc: Pei, Yulong
> Subject: [dpdk-dev] [PATCH v3] i40e: Add a workaround to drop flow control
> frames from VFs
> 
> This patch adds a workaround to drop flow control frames from being
> transmitted from VSIs.
> With this patch in place a malicious VF cannot send flow control or PFC packets
> out on the wire.
> 
> Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
Acked-by: Helin Zhang <helin.zhang@intel.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [dpdk-dev] [PATCH v3] i40e: Add a workaround to drop flow control frames from VFs
  2015-10-30  5:31     ` Zhang, Helin
@ 2015-10-30 11:24       ` Thomas Monjalon
  0 siblings, 0 replies; 9+ messages in thread
From: Thomas Monjalon @ 2015-10-30 11:24 UTC (permalink / raw)
  To: Wu, Jingjing; +Cc: dev

> > This patch adds a workaround to drop flow control frames from being
> > transmitted from VSIs.
> > With this patch in place a malicious VF cannot send flow control or PFC packets
> > out on the wire.
> > 
> > Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
> Acked-by: Helin Zhang <helin.zhang@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-10-30 11:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-25  8:44 [dpdk-dev] [PATCH] i40e: workaround for Security issue in SR-IOV mode Jingjing Wu
2015-09-25 12:28 ` Vladislav Zolotarov
2015-10-08  2:17   ` Wu, Jingjing
2015-10-08 14:53     ` Vlad Zolotarov
2015-10-13  7:18 ` [dpdk-dev] [PATCH v2] i40e: Add a workaround to drop flow control frames from VFs Jingjing Wu
2015-10-19  6:31   ` [dpdk-dev] [PATCH v3] " Jingjing Wu
2015-10-19  8:31     ` Lu, Wenzhuo
2015-10-30  5:31     ` Zhang, Helin
2015-10-30 11:24       ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).