Skip to content

Commit 9ce3a1b

Browse files
committed
Merge: ndisc: use RCU protection in ndisc_alloc_skb()
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6854 JIRA: https://issues.redhat.com/browse/RHEL-81397 CVE: CVE-2025-21764 Tested: compile only Signed-off-by: Xin Long <lxin@redhat.com> Approved-by: Xiubo Li <xiubli@redhat.com> Approved-by: Antoine Tenart <atenart@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Augusto Caringi <acaringi@redhat.com>
2 parents ecbe872 + 0f65a3b commit 9ce3a1b

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)