netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] i40e: proper update of the page_offset field
@ 2017-05-14 17:56 Björn Töpel
  2017-05-15  0:31 ` [Intel-wired-lan] " Alexander Duyck
  0 siblings, 1 reply; 3+ messages in thread
From: Björn Töpel @ 2017-05-14 17:56 UTC (permalink / raw)
  To: netdev, intel-wired-lan
  Cc: Björn Töpel, alexander.h.duyck, jeffrey.t.kirsher

From: Björn Töpel <bjorn.topel@intel.com>

In f8b45b74cc62 ("i40e/i40evf: Use build_skb to build frames")
i40e_build_skb updates the page_offset field with an incorrect offset,
which can lead to data corruption. This patch updates page_offset
correctly.

Note that the bug only appears on architectures where PAGE_SIZE is
8192 or larger.

Fixes: f8b45b74cc62 ("i40e/i40evf: Use build_skb to build frames")
Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_txrx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
index 29321a6167a6..cd894f4023b1 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
@@ -1854,7 +1854,8 @@ static struct sk_buff *i40e_build_skb(struct i40e_ring *rx_ring,
 #if (PAGE_SIZE < 8192)
 	unsigned int truesize = i40e_rx_pg_size(rx_ring) / 2;
 #else
-	unsigned int truesize = SKB_DATA_ALIGN(size);
+	unsigned int truesize = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) +
+				SKB_DATA_ALIGN(I40E_SKB_PAD + size);
 #endif
 	struct sk_buff *skb;
 
-- 
2.11.0

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

* Re: [Intel-wired-lan] [PATCH net] i40e: proper update of the page_offset field
  2017-05-14 17:56 [PATCH net] i40e: proper update of the page_offset field Björn Töpel
@ 2017-05-15  0:31 ` Alexander Duyck
  2017-05-15  4:13   ` Björn Töpel
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Duyck @ 2017-05-15  0:31 UTC (permalink / raw)
  To: Björn Töpel; +Cc: Netdev, intel-wired-lan, Björn Töpel

On Sun, May 14, 2017 at 10:56 AM, Björn Töpel <bjorn.topel@gmail.com> wrote:
> From: Björn Töpel <bjorn.topel@intel.com>
>
> In f8b45b74cc62 ("i40e/i40evf: Use build_skb to build frames")
> i40e_build_skb updates the page_offset field with an incorrect offset,
> which can lead to data corruption. This patch updates page_offset
> correctly.
>
> Note that the bug only appears on architectures where PAGE_SIZE is
> 8192 or larger.
>
> Fixes: f8b45b74cc62 ("i40e/i40evf: Use build_skb to build frames")
> Signed-off-by: Björn Töpel <bjorn.topel@intel.com>

Minor nit. I think i40evf has the same issue and requires the same
fix. Can you add that to this patch and resubmit? Otherwise this fix
looks good to me.

> ---
>  drivers/net/ethernet/intel/i40e/i40e_txrx.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
> index 29321a6167a6..cd894f4023b1 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
> @@ -1854,7 +1854,8 @@ static struct sk_buff *i40e_build_skb(struct i40e_ring *rx_ring,
>  #if (PAGE_SIZE < 8192)
>         unsigned int truesize = i40e_rx_pg_size(rx_ring) / 2;
>  #else
> -       unsigned int truesize = SKB_DATA_ALIGN(size);
> +       unsigned int truesize = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) +
> +                               SKB_DATA_ALIGN(I40E_SKB_PAD + size);
>  #endif
>         struct sk_buff *skb;
>
> --
> 2.11.0
>
> _______________________________________________
> Intel-wired-lan mailing list
> Intel-wired-lan@osuosl.org
> https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

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

* Re: [Intel-wired-lan] [PATCH net] i40e: proper update of the page_offset field
  2017-05-15  0:31 ` [Intel-wired-lan] " Alexander Duyck
@ 2017-05-15  4:13   ` Björn Töpel
  0 siblings, 0 replies; 3+ messages in thread
From: Björn Töpel @ 2017-05-15  4:13 UTC (permalink / raw)
  To: Alexander Duyck; +Cc: Netdev, intel-wired-lan, Björn Töpel

2017-05-15 2:31 GMT+02:00 Alexander Duyck <alexander.duyck@gmail.com>:
> On Sun, May 14, 2017 at 10:56 AM, Björn Töpel <bjorn.topel@gmail.com> wrote:
>> From: Björn Töpel <bjorn.topel@intel.com>
>>
>> In f8b45b74cc62 ("i40e/i40evf: Use build_skb to build frames")
>> i40e_build_skb updates the page_offset field with an incorrect offset,
>> which can lead to data corruption. This patch updates page_offset
>> correctly.
>>
>> Note that the bug only appears on architectures where PAGE_SIZE is
>> 8192 or larger.
>>
>> Fixes: f8b45b74cc62 ("i40e/i40evf: Use build_skb to build frames")
>> Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
>
> Minor nit. I think i40evf has the same issue and requires the same
> fix. Can you add that to this patch and resubmit? Otherwise this fix
> looks good to me.

Good point. I'll send a v2, that addresses i40evf as well.

>
>> ---
>>  drivers/net/ethernet/intel/i40e/i40e_txrx.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
>> index 29321a6167a6..cd894f4023b1 100644
>> --- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
>> +++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
>> @@ -1854,7 +1854,8 @@ static struct sk_buff *i40e_build_skb(struct i40e_ring *rx_ring,
>>  #if (PAGE_SIZE < 8192)
>>         unsigned int truesize = i40e_rx_pg_size(rx_ring) / 2;
>>  #else
>> -       unsigned int truesize = SKB_DATA_ALIGN(size);
>> +       unsigned int truesize = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) +
>> +                               SKB_DATA_ALIGN(I40E_SKB_PAD + size);
>>  #endif
>>         struct sk_buff *skb;
>>
>> --
>> 2.11.0
>>
>> _______________________________________________
>> Intel-wired-lan mailing list
>> Intel-wired-lan@osuosl.org
>> https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

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

end of thread, other threads:[~2017-05-15  4:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-14 17:56 [PATCH net] i40e: proper update of the page_offset field Björn Töpel
2017-05-15  0:31 ` [Intel-wired-lan] " Alexander Duyck
2017-05-15  4:13   ` Björn Töpel

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).