Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 75f89b0

Browse files
committedJun 5, 2025
ndisc: use RCU protection in ndisc_alloc_skb()
jira LE-3187 cve CVE-2025-21764 Rebuild_History Non-Buildable kernel-5.14.0-570.19.1.el9_6 commit-author Eric Dumazet <[email protected]> commit 628e6d1 ndisc_alloc_skb() can be called without RTNL or RCU being held. Add RCU protection to avoid possible UAF. Fixes: de09334 ("ndisc: Introduce ndisc_alloc_skb() helper.") Signed-off-by: Eric Dumazet <[email protected]> Reviewed-by: David Ahern <[email protected]> Reviewed-by: Kuniyuki Iwashima <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> (cherry picked from commit 628e6d1) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 9601d84 commit 75f89b0

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed
 

‎net/ipv6/ndisc.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,15 +414,11 @@ static struct sk_buff *ndisc_alloc_skb(struct net_device *dev,
414414
{
415415
int hlen = LL_RESERVED_SPACE(dev);
416416
int tlen = dev->needed_tailroom;
417-
struct sock *sk = dev_net(dev)->ipv6.ndisc_sk;
418417
struct sk_buff *skb;
419418

420419
skb = alloc_skb(hlen + sizeof(struct ipv6hdr) + len + tlen, GFP_ATOMIC);
421-
if (!skb) {
422-
ND_PRINTK(0, err, "ndisc: %s failed to allocate an skb\n",
423-
__func__);
420+
if (!skb)
424421
return NULL;
425-
}
426422

427423
skb->protocol = htons(ETH_P_IPV6);
428424
skb->dev = dev;
@@ -433,7 +429,9 @@ static struct sk_buff *ndisc_alloc_skb(struct net_device *dev,
433429
/* Manually assign socket ownership as we avoid calling
434430
* sock_alloc_send_pskb() to bypass wmem buffer limits
435431
*/
436-
skb_set_owner_w(skb, sk);
432+
rcu_read_lock();
433+
skb_set_owner_w(skb, dev_net_rcu(dev)->ipv6.ndisc_sk);
434+
rcu_read_unlock();
437435

438436
return skb;
439437
}

0 commit comments

Comments
 (0)
Please sign in to comment.