All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Hangbin Liu <liuhangbin@gmail.com>
Cc: netdev@vger.kernel.org, "David S . Miller" <davem@davemloft.net>,
	Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
	Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Willem de Bruijn <willemb@google.com>
Subject: Re: [PATCH net 2/2] IPv6: reply ICMP error if the first fragment don't include all headers
Date: Thu, 8 Oct 2020 11:47:00 +0200	[thread overview]
Message-ID: <f7272dda-0383-c7d0-1a8a-4a70a1aadb77@gmail.com> (raw)
In-Reply-To: <20201008083034.GI2531@dhcp-12-153.nay.redhat.com>



On 10/8/20 10:30 AM, Hangbin Liu wrote:
> Hi Eric,
> 
> Thanks for the comments. I should add "RFC" in subject next time for the
> uncertain fix patch.
> 
> On Wed, Oct 07, 2020 at 11:35:41AM +0200, Eric Dumazet wrote:
>>
>>
>> On 10/7/20 5:55 AM, Hangbin Liu wrote:
>>
>>>  		kfree_skb(skb);
>>> @@ -282,6 +285,21 @@ static struct sk_buff *ip6_rcv_core(struct sk_buff *skb, struct net_device *dev,
>>>  		}
>>>  	}
>>>  
>>> +	/* RFC 8200, Section 4.5 Fragment Header:
>>> +	 * If the first fragment does not include all headers through an
>>> +	 * Upper-Layer header, then that fragment should be discarded and
>>> +	 * an ICMP Parameter Problem, Code 3, message should be sent to
>>> +	 * the source of the fragment, with the Pointer field set to zero.
>>> +	 */
>>> +	nexthdr = hdr->nexthdr;
>>> +	offset = ipv6_skip_exthdr(skb, skb_transport_offset(skb), &nexthdr, &frag_off);
>>> +	if (frag_off == htons(IP6_MF) && !pskb_may_pull(skb, offset + 1)) {
>>> +		__IP6_INC_STATS(net, idev, IPSTATS_MIB_INHDRERRORS);
>>> +		icmpv6_param_prob(skb, ICMPV6_HDR_INCOMP, 0);
>>> +		rcu_read_unlock();
>>> +		return NULL;
>>> +	}
>>> +
>>>  	rcu_read_unlock();
>>>  
>>>  	/* Must drop socket now because of tproxy. */
>>>
>>
>> Ouch, this is quite a buggy patch.
>>
>> I doubt we want to add yet another ipv6_skip_exthdr() call in IPv6 fast path.
>>
>> Surely the presence of NEXTHDR_FRAGMENT is already tested elsewhere ?
> 
> Would you like to help point where NEXTHDR_FRAGMENT was tested before IPv6
> defragment?
I think we have to ask the question : Should routers enforce the rule, or
only end points ?

End points must handle NEXTHDR_FRAGMENT, in ipv6_frag_rcv()


> 
>>
>> Also, ipv6_skip_exthdr() does not pull anything in skb->head, it would be strange
>> to force a pull of hundreds of bytes just because you want to check if an extra byte is there,
>> if the packet could be forwarded as is, without additional memory allocations.
>>
>> Testing skb->len should be more than enough at this stage.
> 
> Ah, yes, I shouldn't call pskb_may_pull here.
>>
>> Also ipv6_skip_exthdr() can return an error.
> 
> it returns -1 as error, If we tested it by (offset + 1 > skb->len), does
> that count as an error handler?

If there is an error, then you want to send the ICMP, right ?

The (offset + 1) expression will become 0, and surely the test will be false,
so you wont send the ICMP...

> 
> Thanks
> Hangbin
> 

  reply	other threads:[~2020-10-08  9:47 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-07  3:55 [PATCH net 0/2] IPv6: reply ICMP error with fragment doesn't contain all headers Hangbin Liu
2020-10-07  3:55 ` [PATCH net 1/2] ICMPv6: Add ICMPv6 Parameter Problem, code 3 definition Hangbin Liu
2020-10-07  3:55 ` [PATCH net 2/2] IPv6: reply ICMP error if the first fragment don't include all headers Hangbin Liu
2020-10-07  9:35   ` Eric Dumazet
2020-10-08  8:30     ` Hangbin Liu
2020-10-08  9:47       ` Eric Dumazet [this message]
2020-10-09 10:07         ` Hangbin Liu
2020-10-07 14:58   ` Jakub Kicinski
2020-10-08  8:36     ` Hangbin Liu
2020-10-21  4:20 ` [PATCHv2 net 0/2] IPv6: reply ICMP error with fragment doesn't contain " Hangbin Liu
2020-10-21  4:20   ` [PATCHv2 net 1/2] ICMPv6: Add ICMPv6 Parameter Problem, code 3 definition Hangbin Liu
2020-10-21  4:20   ` [PATCHv2 net 2/2] IPv6: reply ICMP error if the first fragment don't include all headers Hangbin Liu
2020-10-21 14:02     ` Willem de Bruijn
2020-10-22  9:12       ` Hangbin Liu
2020-10-22 15:46         ` Willem de Bruijn
2020-10-23  6:43   ` [PATCHv3 net 0/2] IPv6: reply ICMP error if fragment doesn't contain " Hangbin Liu
2020-10-23  6:43     ` [PATCHv3 net 1/2] ICMPv6: Add ICMPv6 Parameter Problem, code 3 definition Hangbin Liu
2020-10-23  6:43     ` [PATCHv3 net 2/2] IPv6: reply ICMP error if the first fragment doesn't include all headers Hangbin Liu
2020-10-23 18:18       ` Jakub Kicinski
2020-10-26  7:29     ` [PATCHv4 net 0/2] IPv6: reply ICMP error if fragment doesn't contain " Hangbin Liu
2020-10-26  7:29       ` [PATCHv4 net 1/2] ICMPv6: Add ICMPv6 Parameter Problem, code 3 definition Hangbin Liu
2020-10-26  7:29       ` [PATCHv4 net 2/2] IPv6: reply ICMP error if the first fragment don't include all headers Hangbin Liu
2020-10-26  8:09         ` Georg Kohmann (geokohma)
2020-10-26 12:55           ` Hangbin Liu
2020-10-26 14:49             ` Georg Kohmann (geokohma)
2020-10-27  2:28       ` [PATCHv5 net 0/2] IPv6: reply ICMP error if fragment doesn't contain " Hangbin Liu
2020-10-27  2:28         ` [PATCHv5 net 1/2] ICMPv6: Add ICMPv6 Parameter Problem, code 3 definition Hangbin Liu
2020-10-27  2:28         ` [PATCHv5 net 2/2] IPv6: reply ICMP error if the first fragment don't include all headers Hangbin Liu
2020-10-27  7:57           ` Georg Kohmann (geokohma)
2020-10-27  9:57             ` Hangbin Liu
2020-10-27 10:20               ` Georg Kohmann (geokohma)
2020-10-30 15:31               ` Willem de Bruijn
2020-10-30 18:39                 ` Georg Kohmann (geokohma)
2020-10-27 12:33         ` [PATCHv6 net 0/2] IPv6: reply ICMP error if fragment doesn't contain " Hangbin Liu
2020-10-27 12:33           ` [PATCHv6 net 1/2] ICMPv6: Add ICMPv6 Parameter Problem, code 3 definition Hangbin Liu
2020-10-27 12:33           ` [PATCHv6 net 2/2] IPv6: reply ICMP error if the first fragment don't include all headers Hangbin Liu
2020-10-31 21:12           ` [PATCHv6 net 0/2] IPv6: reply ICMP error if fragment doesn't contain " Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f7272dda-0383-c7d0-1a8a-4a70a1aadb77@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=liuhangbin@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=willemb@google.com \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.