Skip to content

Commit e3ebdb2

Browse files
Richard Hainesdavem330
authored andcommitted
net/ipv6: Fix CALIPSO causing GPF with datagram support
When using CALIPSO with IPPROTO_UDP it is possible to trigger a GPF as the IP header may have moved. Also update the payload length after adding the CALIPSO option. Signed-off-by: Richard Haines <[email protected]> Acked-by: Paul Moore <[email protected]> Signed-off-by: Huw Davies <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5942381 commit e3ebdb2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

net/ipv6/calipso.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,7 @@ static int calipso_skbuff_setattr(struct sk_buff *skb,
13191319
struct ipv6hdr *ip6_hdr;
13201320
struct ipv6_opt_hdr *hop;
13211321
unsigned char buf[CALIPSO_MAX_BUFFER];
1322-
int len_delta, new_end, pad;
1322+
int len_delta, new_end, pad, payload;
13231323
unsigned int start, end;
13241324

13251325
ip6_hdr = ipv6_hdr(skb);
@@ -1346,6 +1346,8 @@ static int calipso_skbuff_setattr(struct sk_buff *skb,
13461346
if (ret_val < 0)
13471347
return ret_val;
13481348

1349+
ip6_hdr = ipv6_hdr(skb); /* Reset as skb_cow() may have moved it */
1350+
13491351
if (len_delta) {
13501352
if (len_delta > 0)
13511353
skb_push(skb, len_delta);
@@ -1355,6 +1357,8 @@ static int calipso_skbuff_setattr(struct sk_buff *skb,
13551357
sizeof(*ip6_hdr) + start);
13561358
skb_reset_network_header(skb);
13571359
ip6_hdr = ipv6_hdr(skb);
1360+
payload = ntohs(ip6_hdr->payload_len);
1361+
ip6_hdr->payload_len = htons(payload + len_delta);
13581362
}
13591363

13601364
hop = (struct ipv6_opt_hdr *)(ip6_hdr + 1);

0 commit comments

Comments
 (0)