Skip to content

Commit 9a55104

Browse files
CIQ Kernel Automationroxanan1996
authored andcommitted
can: raw: fix ro->uniq use-after-free in raw_rcv()
jira VULN-182364 cve CVE-2026-31532 commit-author Samuel Page <sam@bynar.io> commit a535a92 raw_release() unregisters raw CAN receive filters via can_rx_unregister(), but receiver deletion is deferred with call_rcu(). This leaves a window where raw_rcv() may still be running in an RCU read-side critical section after raw_release() frees ro->uniq, leading to a use-after-free of the percpu uniq storage. Move free_percpu(ro->uniq) out of raw_release() and into a raw-specific socket destructor. can_rx_unregister() takes an extra reference to the socket and only drops it from the RCU callback, so freeing uniq from sk_destruct ensures the percpu area is not released until the relevant callbacks have drained. Fixes: 514ac99 ("can: fix multiple delivery of a single CAN frame for overlapping CAN filters") Cc: stable@vger.kernel.org # v4.1+ Assisted-by: Bynario AI Signed-off-by: Samuel Page <sam@bynar.io> Link: https://patch.msgid.link/26ec626d-cae7-4418-9782-7198864d070c@bynar.io Acked-by: Oliver Hartkopp <socketcan@hartkopp.net> [mkl: applied manually] Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> (cherry picked from commit a535a92) Signed-off-by: CIQ Kernel Automation <ciq_kernel_automation@ciq.com>
1 parent 66fce69 commit 9a55104

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

net/can/raw.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,14 @@ static int raw_notifier(struct notifier_block *nb, unsigned long msg,
329329
return NOTIFY_DONE;
330330
}
331331

332+
static void raw_sock_destruct(struct sock *sk)
333+
{
334+
struct raw_sock *ro = raw_sk(sk);
335+
336+
free_percpu(ro->uniq);
337+
can_sock_destruct(sk);
338+
}
339+
332340
static int raw_init(struct sock *sk)
333341
{
334342
struct raw_sock *ro = raw_sk(sk);
@@ -353,6 +361,8 @@ static int raw_init(struct sock *sk)
353361
if (unlikely(!ro->uniq))
354362
return -ENOMEM;
355363

364+
sk->sk_destruct = raw_sock_destruct;
365+
356366
/* set notifier */
357367
spin_lock(&raw_notifier_lock);
358368
list_add_tail(&ro->notifier, &raw_notifier_list);
@@ -403,7 +413,6 @@ static int raw_release(struct socket *sock)
403413
ro->ifindex = 0;
404414
ro->bound = 0;
405415
ro->count = 0;
406-
free_percpu(ro->uniq);
407416

408417
sock_orphan(sk);
409418
sock->sk = NULL;

0 commit comments

Comments
 (0)