lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 19 Sep 2016 12:22:05 +0200
From:   Vitaly Kuznetsov <vkuznets@...hat.com>
To:     David Miller <davem@...emloft.net>
Cc:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        ptalbert@...hat.com, boris.ostrovsky@...cle.com,
        david.vrabel@...rix.com, jgross@...e.com,
        xen-devel@...ts.xenproject.org
Subject: Re: [PATCH net-next RESEND] xen-netfront: avoid packet loss when ethernet header crosses page boundary

David Miller <davem@...emloft.net> writes:

> From: Vitaly Kuznetsov <vkuznets@...hat.com>
> Date: Fri, 16 Sep 2016 12:59:14 +0200
>
>> @@ -595,6 +596,19 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
>>  	offset = offset_in_page(skb->data);
>>  	len = skb_headlen(skb);
>>  
>> +	/* The first req should be at least ETH_HLEN size or the packet will be
>> +	 * dropped by netback.
>> +	 */
>> +	if (unlikely(PAGE_SIZE - offset < ETH_HLEN)) {
>> +		nskb = skb_copy(skb, GFP_ATOMIC);
>> +		if (!nskb)
>> +			goto drop;
>> +		dev_kfree_skb_any(skb);
>> +		skb = nskb;
>> +		page = virt_to_page(skb->data);
>> +		offset = offset_in_page(skb->data);
>> +	}
>> +
>>  	spin_lock_irqsave(&queue->tx_lock, flags);
>
> I think you also have to recalculate 'len' in this case too, as
> skb_headlen() will definitely be different for nskb.
>
> In fact, I can't see how this code can work properly without that fix.

Thank you for your feedback David,

in my testing (even when I tried doing skb_copy() for all skbs
unconditionally) skb_headlen(nskb) always equals 'len' so I was under an
impression that both 'skb->len' and 'skb->data_len' remain the same when
we do skb_copy(). However, in case you think there are cases when
headlen changes, I see no problem with re-calculating 'len' as it won't
bring any significant performace penalty compared to the already added
skb_copy().

I'll send 'v2'.

-- 
  Vitaly

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ