netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] ipv6: re-enable fragment header matching in ipv6_find_hdr
@ 2016-03-01 15:15 Florian Westphal
  2016-03-03 21:35 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Westphal @ 2016-03-01 15:15 UTC (permalink / raw)
  To: netdev; +Cc: Florian Westphal

When ipv6_find_hdr is used to find a fragment header
(caller specifies target NEXTHDR_FRAGMENT) we erronously return
-ENOENT for all fragments with nonzero offset.

Before commit 9195bb8e381d, when target was specified, we did not
enter the exthdr walk loop as nexthdr == target so this used to work.

Now we do (so we can skip empty route headers). When we then stumble upon
a frag with nonzero frag_off we must return -ENOENT ("header not found")
only if the caller did not specifically request NEXTHDR_FRAGMENT.

This allows nfables exthdr expression to match ipv6 fragments, e.g. via

nft add rule ip6 filter input frag frag-off gt 0

Fixes: 9195bb8e381d ("ipv6: improve ipv6_find_hdr() to skip empty routing headers")
Signed-off-by: Florian Westphal <fw@strlen.de>
---
 net/ipv6/exthdrs_core.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/exthdrs_core.c b/net/ipv6/exthdrs_core.c
index 5c5d23e..9508a20 100644
--- a/net/ipv6/exthdrs_core.c
+++ b/net/ipv6/exthdrs_core.c
@@ -257,7 +257,11 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
 						*fragoff = _frag_off;
 					return hp->nexthdr;
 				}
-				return -ENOENT;
+				if (!found)
+					return -ENOENT;
+				if (fragoff)
+					*fragoff = _frag_off;
+				break;
 			}
 			hdrlen = 8;
 		} else if (nexthdr == NEXTHDR_AUTH) {
-- 
2.4.10

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

* Re: [PATCH net] ipv6: re-enable fragment header matching in ipv6_find_hdr
  2016-03-01 15:15 [PATCH net] ipv6: re-enable fragment header matching in ipv6_find_hdr Florian Westphal
@ 2016-03-03 21:35 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-03-03 21:35 UTC (permalink / raw)
  To: fw; +Cc: netdev

From: Florian Westphal <fw@strlen.de>
Date: Tue,  1 Mar 2016 16:15:16 +0100

> When ipv6_find_hdr is used to find a fragment header
> (caller specifies target NEXTHDR_FRAGMENT) we erronously return
> -ENOENT for all fragments with nonzero offset.
> 
> Before commit 9195bb8e381d, when target was specified, we did not
> enter the exthdr walk loop as nexthdr == target so this used to work.
> 
> Now we do (so we can skip empty route headers). When we then stumble upon
> a frag with nonzero frag_off we must return -ENOENT ("header not found")
> only if the caller did not specifically request NEXTHDR_FRAGMENT.
> 
> This allows nfables exthdr expression to match ipv6 fragments, e.g. via
> 
> nft add rule ip6 filter input frag frag-off gt 0
> 
> Fixes: 9195bb8e381d ("ipv6: improve ipv6_find_hdr() to skip empty routing headers")
> Signed-off-by: Florian Westphal <fw@strlen.de>

Applied and queued up for -stable, thanks Florian.

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

end of thread, other threads:[~2016-03-03 21:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-01 15:15 [PATCH net] ipv6: re-enable fragment header matching in ipv6_find_hdr Florian Westphal
2016-03-03 21: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).