Unverified Commit 710a4bfc authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!11518 ipv6: fix possible UAF in ip6_finish_output2()

parents 620dc634 640fe1be
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -70,11 +70,15 @@ static int ip6_finish_output2(struct net *net, struct sock *sk, struct sk_buff *

	/* Be paranoid, rather than too clever. */
	if (unlikely(hh_len > skb_headroom(skb)) && dev->header_ops) {
		/* Make sure idev stays alive */
		rcu_read_lock();
		skb = skb_expand_head(skb, hh_len);
		if (!skb) {
			IP6_INC_STATS(net, idev, IPSTATS_MIB_OUTDISCARDS);
			rcu_read_unlock();
			return -ENOMEM;
		}
		rcu_read_unlock();
	}

	hdr = ipv6_hdr(skb);