linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sit: reload iphdr in ipip6_rcv
@ 2017-06-04  6:43 Haishuang Yan
  2017-06-05  3:05 ` David Miller
  2017-06-05 13:03 ` Eric Dumazet
  0 siblings, 2 replies; 4+ messages in thread
From: Haishuang Yan @ 2017-06-04  6:43 UTC (permalink / raw)
  To: David S. Miller, Jesse Gross, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy
  Cc: netdev, linux-kernel, Haishuang Yan

Since iptunnel_pull_header() can call pskb_may_pull(),
we must reload any pointer that was related to skb->head.

Fixes: a09a4c8dd1ec ("tunnels: Remove encapsulation offloads on decap")
Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
---
 net/ipv6/sit.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 61e5902..af832e7 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -657,6 +657,7 @@ static int ipip6_rcv(struct sk_buff *skb)
 		if (iptunnel_pull_header(skb, 0, htons(ETH_P_IPV6),
 		    !net_eq(tunnel->net, dev_net(tunnel->dev))))
 			goto out;
+		iph = ip_hdr(skb);
 
 		err = IP_ECN_decapsulate(iph, skb);
 		if (unlikely(err)) {
-- 
1.8.3.1

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

* Re: [PATCH] sit: reload iphdr in ipip6_rcv
  2017-06-04  6:43 [PATCH] sit: reload iphdr in ipip6_rcv Haishuang Yan
@ 2017-06-05  3:05 ` David Miller
  2017-06-05 13:03 ` Eric Dumazet
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2017-06-05  3:05 UTC (permalink / raw)
  To: yanhaishuang
  Cc: jesse, kuznet, jmorris, yoshfuji, kaber, netdev, linux-kernel

From: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
Date: Sun,  4 Jun 2017 14:43:43 +0800

> Since iptunnel_pull_header() can call pskb_may_pull(),
> we must reload any pointer that was related to skb->head.
> 
> Fixes: a09a4c8dd1ec ("tunnels: Remove encapsulation offloads on decap")
> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>

Applied and queued up for -stable, thank you.

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

* Re: [PATCH] sit: reload iphdr in ipip6_rcv
  2017-06-04  6:43 [PATCH] sit: reload iphdr in ipip6_rcv Haishuang Yan
  2017-06-05  3:05 ` David Miller
@ 2017-06-05 13:03 ` Eric Dumazet
       [not found]   ` <C9A276FB-FF6E-439A-AFE4-F8A5551DDA30@cmss.chinamobile.com>
  1 sibling, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2017-06-05 13:03 UTC (permalink / raw)
  To: Haishuang Yan
  Cc: David S. Miller, Jesse Gross, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy, netdev, linux-kernel

On Sun, 2017-06-04 at 14:43 +0800, Haishuang Yan wrote:
> Since iptunnel_pull_header() can call pskb_may_pull(),
> we must reload any pointer that was related to skb->head.
> 
> Fixes: a09a4c8dd1ec ("tunnels: Remove encapsulation offloads on decap")
> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
> ---
>  net/ipv6/sit.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
> index 61e5902..af832e7 100644
> --- a/net/ipv6/sit.c
> +++ b/net/ipv6/sit.c
> @@ -657,6 +657,7 @@ static int ipip6_rcv(struct sk_buff *skb)
>  		if (iptunnel_pull_header(skb, 0, htons(ETH_P_IPV6),
>  		    !net_eq(tunnel->net, dev_net(tunnel->dev))))
>  			goto out;
> +		iph = ip_hdr(skb);
>  
>  		err = IP_ECN_decapsulate(iph, skb);
>  		if (unlikely(err)) {

This seems unnecessary.

By the time ipip6_rcv() is called, we already have the guarantee the
IPv4 header is in skb linear part.

Otherwise we could not use iph->saddr and iph->daddr in the call to
ipip6_tunnel_lookup()

Therefore, the pskb_may_pull() is a nop in this particular case.

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

* Re: [PATCH] sit: reload iphdr in ipip6_rcv
       [not found]   ` <C9A276FB-FF6E-439A-AFE4-F8A5551DDA30@cmss.chinamobile.com>
@ 2017-06-06 15:35     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-06-06 15:35 UTC (permalink / raw)
  To: yanhaishuang
  Cc: eric.dumazet, jesse, kuznet, jmorris, yoshfuji, kaber, netdev,
	linux-kernel

From: 严海双 <yanhaishuang@cmss.chinamobile.com>
Date: Tue, 6 Jun 2017 10:09:45 +0800

> 
>> On 5 Jun 2017, at 9:03 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
>> 
>> On Sun, 2017-06-04 at 14:43 +0800, Haishuang Yan wrote:
>>> Since iptunnel_pull_header() can call pskb_may_pull(),
>>> we must reload any pointer that was related to skb->head.
>>> 
>>> Fixes: a09a4c8dd1ec ("tunnels: Remove encapsulation offloads on decap")
>>> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
>>> ---
>>> net/ipv6/sit.c | 1 +
>>> 1 file changed, 1 insertion(+)
>>> 
>>> diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
>>> index 61e5902..af832e7 100644
>>> --- a/net/ipv6/sit.c
>>> +++ b/net/ipv6/sit.c
>>> @@ -657,6 +657,7 @@ static int ipip6_rcv(struct sk_buff *skb)
>>> 		if (iptunnel_pull_header(skb, 0, htons(ETH_P_IPV6),
>>> 		    !net_eq(tunnel->net, dev_net(tunnel->dev))))
>>> 			goto out;
>>> +		iph = ip_hdr(skb);
>>> 
>>> 		err = IP_ECN_decapsulate(iph, skb);
>>> 		if (unlikely(err)) {
>> 
>> This seems unnecessary.
>> 
>> By the time ipip6_rcv() is called, we already have the guarantee the
>> IPv4 header is in skb linear part.
>> 
>> Otherwise we could not use iph->saddr and iph->daddr in the call to
>> ipip6_tunnel_lookup()
>> 
>> Therefore, the pskb_may_pull() is a nop in this particular case.
> 
> Yes, it’s right. Thanks!

Ok, I reverted, thanks everyone.

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

end of thread, other threads:[~2017-06-06 15:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-04  6:43 [PATCH] sit: reload iphdr in ipip6_rcv Haishuang Yan
2017-06-05  3:05 ` David Miller
2017-06-05 13:03 ` Eric Dumazet
     [not found]   ` <C9A276FB-FF6E-439A-AFE4-F8A5551DDA30@cmss.chinamobile.com>
2017-06-06 15:35     ` David Miller

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