lkml.org 
[lkml]   [2020]   [Aug]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] net: exit immediately when encounter ipv6 fragment in skb_checksum_setup_ipv6()
Date
skb_checksum_setup_ipv6() always return -EPROTO if ipv6 packet is fragment.
So we should not continue to parse other header type in this case. Also
remove unnecessary local variable 'fragment'.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
net/core/skbuff.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index c3496bd8e99e..4dc92290becd 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4894,11 +4894,9 @@ static int skb_checksum_setup_ipv6(struct sk_buff *skb, bool recalculate)
u8 nexthdr;
unsigned int off;
unsigned int len;
- bool fragment;
bool done;
__sum16 *csum;

- fragment = false;
done = false;

off = sizeof(struct ipv6hdr);
@@ -4956,8 +4954,11 @@ static int skb_checksum_setup_ipv6(struct sk_buff *skb, bool recalculate)

hp = OPT_HDR(struct frag_hdr, skb, off);

- if (hp->frag_off & htons(IP6_OFFSET | IP6_MF))
- fragment = true;
+ /* Exit immediately when encounter ipv6 fragment. */
+ if (hp->frag_off & htons(IP6_OFFSET | IP6_MF)) {
+ err = -EPROTO;
+ goto out;
+ }

nexthdr = hp->nexthdr;
off += sizeof(struct frag_hdr);
@@ -4970,8 +4971,7 @@ static int skb_checksum_setup_ipv6(struct sk_buff *skb, bool recalculate)
}

err = -EPROTO;
-
- if (!done || fragment)
+ if (!done)
goto out;

csum = skb_checksum_setup_ip(skb, nexthdr, off);
--
2.19.1
\
 
 \ /
  Last update: 2020-08-27 13:57    [W:0.030 / U:1.252 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site