Skip to content

Commit 58652e2

Browse files
committed
Merge branch 'ipv6-fix-possible-uaf-in-output-paths'
Eric Dumazet says: ==================== ipv6: fix possible UAF in output paths First patch fixes an issue spotted by syzbot, and the two other patches fix error paths after skb_expand_head() adoption. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 007d427 + 2d5ff7e commit 58652e2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

net/ipv6/ip6_output.c

+10
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,15 @@ static int ip6_finish_output2(struct net *net, struct sock *sk, struct sk_buff *
7070

7171
/* Be paranoid, rather than too clever. */
7272
if (unlikely(hh_len > skb_headroom(skb)) && dev->header_ops) {
73+
/* Make sure idev stays alive */
74+
rcu_read_lock();
7375
skb = skb_expand_head(skb, hh_len);
7476
if (!skb) {
7577
IP6_INC_STATS(net, idev, IPSTATS_MIB_OUTDISCARDS);
78+
rcu_read_unlock();
7679
return -ENOMEM;
7780
}
81+
rcu_read_unlock();
7882
}
7983

8084
hdr = ipv6_hdr(skb);
@@ -283,11 +287,15 @@ int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6,
283287
head_room += opt->opt_nflen + opt->opt_flen;
284288

285289
if (unlikely(head_room > skb_headroom(skb))) {
290+
/* Make sure idev stays alive */
291+
rcu_read_lock();
286292
skb = skb_expand_head(skb, head_room);
287293
if (!skb) {
288294
IP6_INC_STATS(net, idev, IPSTATS_MIB_OUTDISCARDS);
295+
rcu_read_unlock();
289296
return -ENOBUFS;
290297
}
298+
rcu_read_unlock();
291299
}
292300

293301
if (opt) {
@@ -1956,6 +1964,7 @@ int ip6_send_skb(struct sk_buff *skb)
19561964
struct rt6_info *rt = dst_rt6_info(skb_dst(skb));
19571965
int err;
19581966

1967+
rcu_read_lock();
19591968
err = ip6_local_out(net, skb->sk, skb);
19601969
if (err) {
19611970
if (err > 0)
@@ -1965,6 +1974,7 @@ int ip6_send_skb(struct sk_buff *skb)
19651974
IPSTATS_MIB_OUTDISCARDS);
19661975
}
19671976

1977+
rcu_read_unlock();
19681978
return err;
19691979
}
19701980

0 commit comments

Comments
 (0)