Skip to content

Commit 4b0ef1f

Browse files
Dang Hongwudavem330
authored andcommitted
ah: reload pointers to skb data after calling skb_cow_data()
skb_cow_data() may allocate a new data buffer, so pointers on skb should be set after this function. Bug was introduced by commit dff3bb0 ("ah4: convert to ahash") and 8631e9b ("ah6: convert to ahash"). Signed-off-by: Wang Xuefu <[email protected]> Acked-by: Krzysztof Witek <[email protected]> Signed-off-by: Nicolas Dichtel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e44f391 commit 4b0ef1f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

net/ipv4/ah4.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,15 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
314314

315315
skb->ip_summed = CHECKSUM_NONE;
316316

317-
ah = (struct ip_auth_hdr *)skb->data;
318-
iph = ip_hdr(skb);
319-
ihl = ip_hdrlen(skb);
320317

321318
if ((err = skb_cow_data(skb, 0, &trailer)) < 0)
322319
goto out;
323320
nfrags = err;
324321

322+
ah = (struct ip_auth_hdr *)skb->data;
323+
iph = ip_hdr(skb);
324+
ihl = ip_hdrlen(skb);
325+
325326
work_iph = ah_alloc_tmp(ahash, nfrags, ihl + ahp->icv_trunc_len);
326327
if (!work_iph)
327328
goto out;

net/ipv6/ah6.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,14 +538,16 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb)
538538
if (!pskb_may_pull(skb, ah_hlen))
539539
goto out;
540540

541-
ip6h = ipv6_hdr(skb);
542-
543-
skb_push(skb, hdr_len);
544541

545542
if ((err = skb_cow_data(skb, 0, &trailer)) < 0)
546543
goto out;
547544
nfrags = err;
548545

546+
ah = (struct ip_auth_hdr *)skb->data;
547+
ip6h = ipv6_hdr(skb);
548+
549+
skb_push(skb, hdr_len);
550+
549551
work_iph = ah_alloc_tmp(ahash, nfrags, hdr_len + ahp->icv_trunc_len);
550552
if (!work_iph)
551553
goto out;

0 commit comments

Comments
 (0)