]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
misc: fastrpc: fix use-after-free race in fastrpc_map_create
authorZhenghang Xiao <kipreyyy@gmail.com>
Sat, 30 May 2026 20:45:28 +0000 (21:45 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 Jun 2026 15:20:51 +0000 (17:20 +0200)
commit07ebe87915d8accdaba20c4f88c5ae430fe62fbb
tree7ee945410c34ff7879be453678c38a708add9cba
parent5401fb4fe10fac6134c308495df18ed74aebb9c4
misc: fastrpc: fix use-after-free race in fastrpc_map_create

fastrpc_map_lookup returns a raw pointer after releasing fl->lock. The
caller fastrpc_map_create then calls fastrpc_map_get (kref_get_unless_zero)
on this unprotected pointer. A concurrent MEM_UNMAP can free the map
between the lock release and the kref operation, resulting in a
use-after-free on the freed slab object.

Restore the take_ref parameter to fastrpc_map_lookup so the reference
is acquired atomically under fl->lock before the pointer is exposed to
the caller.

Fixes: 10df039834f8 ("misc: fastrpc: Skip reference for DMA handles")
Cc: stable@vger.kernel.org
Signed-off-by: Zhenghang Xiao <kipreyyy@gmail.com>
Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
Link: https://patch.msgid.link/20260530204528.116920-5-srini@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/fastrpc.c