KernelScan.io

HIGH

can raw Socket UAF

CVE-2026-31532

CVSS 7.8 / 10.0 NVD

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

KernelScan AI7.8HIGH

01

In the Linux kernel, the following vulnerability has been resolved: can: raw: fix ro->uniq use-after-free in raw_rcv() 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. [mkl: applied manually]

02

Engine v0.2.0

Risk summary

A use-after-free vulnerability in the CAN raw socket implementation allows local attackers to potentially cause system crashes or execute arbitrary code. The bug occurs when closing CAN sockets while frames are still being processed, creating a race condition where freed memory may be accessed. This affects systems using CAN bus networking.

Affectednet/can/raw.c

Vulnerability analysis

Root Cause: The raw_release() function immediately frees the percpu ro->uniq storage via free_percpu() after calling can_rx_unregister(), but receiver deletion is deferred using call_rcu(). This creates a race window where raw_rcv() callbacks may still be executing in RCU read-side critical sections and accessing the freed ro->uniq memory.

Attack Surface: Local attack surface requiring the ability to create and manipulate CAN raw sockets. The vulnerability is triggered through normal socket operations (socket creation/destruction) combined with CAN frame reception timing, making it accessible to any process with CAN socket privileges.

Fix Mechanism: The patch moves the free_percpu(ro->uniq) call from raw_release() to a new socket destructor function raw_sock_destruct(). Since can_rx_unregister() takes an extra socket reference that is only dropped from the RCU callback, this ensures the percpu area is not freed until all RCU callbacks have completed and no more references to ro->uniq exist.

03

BranchFixed inPatch commit
5.105.10.2581de30576a6df
5.155.15.20964c8553decf5
6.16.1.1753f43f12fde34
6.126.12.83572f0bf536eb
6.186.18.241a0f2de81f7f
6.196.19.147201a531b9a5
6.66.6.1365e9cfffad898
7.07.0.134c1741254ff
mainline7.1-rc1a535a9217ca3