Skip to content

Commit 72ad724

Browse files
committed
Merge: tunnels: Second round of upstream fixes for RHEL 9.4.
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/3580 JIRA: https://issues.redhat.com/browse/RHEL-21363 Upstream Status: net.git Signed-off-by: Guillaume Nault <[email protected]> Approved-by: Antoine Tenart <[email protected]> Approved-by: Marcelo Ricardo Leitner <[email protected]> Approved-by: Hangbin Liu <[email protected]> Signed-off-by: Scott Weaver <[email protected]>
2 parents 794deed + 17a1c6b commit 72ad724

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

net/ipv4/ip_gre.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -634,15 +634,18 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
634634
}
635635

636636
if (dev->header_ops) {
637+
int pull_len = tunnel->hlen + sizeof(struct iphdr);
638+
637639
if (skb_cow_head(skb, 0))
638640
goto free_skb;
639641

640642
tnl_params = (const struct iphdr *)skb->data;
641643

642-
/* Pull skb since ip_tunnel_xmit() needs skb->data pointing
643-
* to gre header.
644-
*/
645-
skb_pull(skb, tunnel->hlen + sizeof(struct iphdr));
644+
if (!pskb_network_may_pull(skb, pull_len))
645+
goto free_skb;
646+
647+
/* ip_tunnel_xmit() needs skb->data pointing to gre header. */
648+
skb_pull(skb, pull_len);
646649
skb_reset_mac_header(skb);
647650

648651
if (skb->ip_summed == CHECKSUM_PARTIAL &&

net/ipv6/ip6_tunnel.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ __u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw)
401401
const struct ipv6hdr *ipv6h = (const struct ipv6hdr *)raw;
402402
unsigned int nhoff = raw - skb->data;
403403
unsigned int off = nhoff + sizeof(*ipv6h);
404-
u8 next, nexthdr = ipv6h->nexthdr;
404+
u8 nexthdr = ipv6h->nexthdr;
405405

406406
while (ipv6_ext_hdr(nexthdr) && nexthdr != NEXTHDR_NONE) {
407407
struct ipv6_opt_hdr *hdr;
@@ -412,25 +412,25 @@ __u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw)
412412

413413
hdr = (struct ipv6_opt_hdr *)(skb->data + off);
414414
if (nexthdr == NEXTHDR_FRAGMENT) {
415-
struct frag_hdr *frag_hdr = (struct frag_hdr *) hdr;
416-
if (frag_hdr->frag_off)
417-
break;
418415
optlen = 8;
419416
} else if (nexthdr == NEXTHDR_AUTH) {
420417
optlen = ipv6_authlen(hdr);
421418
} else {
422419
optlen = ipv6_optlen(hdr);
423420
}
424-
/* cache hdr->nexthdr, since pskb_may_pull() might
425-
* invalidate hdr
426-
*/
427-
next = hdr->nexthdr;
428-
if (nexthdr == NEXTHDR_DEST) {
429-
u16 i = 2;
430421

431-
/* Remember : hdr is no longer valid at this point. */
432-
if (!pskb_may_pull(skb, off + optlen))
422+
if (!pskb_may_pull(skb, off + optlen))
423+
break;
424+
425+
hdr = (struct ipv6_opt_hdr *)(skb->data + off);
426+
if (nexthdr == NEXTHDR_FRAGMENT) {
427+
struct frag_hdr *frag_hdr = (struct frag_hdr *)hdr;
428+
429+
if (frag_hdr->frag_off)
433430
break;
431+
}
432+
if (nexthdr == NEXTHDR_DEST) {
433+
u16 i = 2;
434434

435435
while (1) {
436436
struct ipv6_tlv_tnl_enc_lim *tel;
@@ -451,7 +451,7 @@ __u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw)
451451
i++;
452452
}
453453
}
454-
nexthdr = next;
454+
nexthdr = hdr->nexthdr;
455455
off += optlen;
456456
}
457457
return 0;

0 commit comments

Comments
 (0)