Skip to content

Commit 77874c7

Browse files
committed
ndisc: use RCU protection in ndisc_alloc_skb()
jira LE-3467 cve CVE-2025-21764 Rebuild_History Non-Buildable kernel-4.18.0-553.58.1.el8_10 commit-author Eric Dumazet <edumazet@google.com> 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 <edumazet@google.com> Reviewed-by: David Ahern <dsahern@kernel.org> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com> Link: https://patch.msgid.link/20250207135841.1948589-3-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> (cherry picked from commit 628e6d1) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 59ff24e commit 77874c7

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
@@ -400,15 +400,11 @@ static struct sk_buff *ndisc_alloc_skb(struct net_device *dev,
400400
{
401401
int hlen = LL_RESERVED_SPACE(dev);
402402
int tlen = dev->needed_tailroom;
403-
struct sock *sk = dev_net(dev)->ipv6.ndisc_sk;
404403
struct sk_buff *skb;
405404

406405
skb = alloc_skb(hlen + sizeof(struct ipv6hdr) + len + tlen, GFP_ATOMIC);
407-
if (!skb) {
408-
ND_PRINTK(0, err, "ndisc: %s failed to allocate an skb\n",
409-
__func__);
406+
if (!skb)
410407
return NULL;
411-
}
412408

413409
skb->protocol = htons(ETH_P_IPV6);
414410
skb->dev = dev;
@@ -419,7 +415,9 @@ static struct sk_buff *ndisc_alloc_skb(struct net_device *dev,
419415
/* Manually assign socket ownership as we avoid calling
420416
* sock_alloc_send_pskb() to bypass wmem buffer limits
421417
*/
422-
skb_set_owner_w(skb, sk);
418+
rcu_read_lock();
419+
skb_set_owner_w(skb, dev_net_rcu(dev)->ipv6.ndisc_sk);
420+
rcu_read_unlock();
423421

424422
return skb;
425423
}

0 commit comments

Comments
 (0)