In the Linux kernel, the following vulnerability has been resolved:
rnbd-srv: fix use-after-free on two CLOSE messages
process_msg_close() looks the sess_dev up with a kref, drops it right
away, and only then takes the session mutex for the teardown. A session
has several connections handled by different workers, so two CLOSE
messages for the same ID both finish the lookup before either one tears
the sess_dev down, and the second one works on freed memory. Any host
that can open a device on the server can do that.
Take the mutex first and look the ID up with xa_load() under it. The
second CLOSE then finds nothing.
CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
CVSS Score: 9.8
AV:N - Two RNBD_MSG_CLOSE messages carrying the same device_id arrive as RTRS RDMA-WRITE-WITH-IMM on two connections of one session; rtrs_srv_rdma_done() -> process_io_req() -> rnbd_srv_rdma_ev() -> process_msg_close(). rtrs_srv_rdma_init() listens with RDMA_PS_TCP on IN6ADDR_ANY port 1234, so RoCEv2/iWARP peers reach it over routable IP.
AC:L - The peer sends both CLOSEs. Each connection has its own IB_POLL_WORKQUEUE CQ, so the handlers run concurrently, and an OPEN on a third connection holds srv_sess->lock while both rnbd_get_sess_dev() lookups succeed. A lost race leaves the second lookup at -ENXIO, which is harmless, so the attacker can retry at will.
PR:N - rtrs_rdma_connect() and process_info_req() check only RTRS_MAGIC, the version, cid and uuid, with no credentials. process_msg_open() then read-only opens any block device under dev_search_path (default "/"), so an unauthenticated peer gets the device_id it needs for the two CLOSEs.
UI:N - The server handles the CLOSE messages in its CQ workqueue as part of normal RTRS operation. No administrator or local user does anything.
S:U - The freed rnbd_srv_sess_dev and everything the second teardown touches is memory of the server's own kernel; no VM, IOMMU or sandbox boundary is crossed.
C:H - The second process_msg_close() runs rnbd_srv_destroy_dev_session_sysfs() on a kfree'd kmalloc-512 rnbd_srv_sess_dev, reading kobj->sd, parent, kset and ktype from freed memory. If another object refills the slot, those pointers are under attacker influence, which can be groomed into a kernel read.
I:H - On the freed object, kobject_del() writes kobj->sd/parent/state and does kobject_put(parent). kobject_put() decrements kobj->kref, and when it reaches zero kobject_cleanup() calls t->release via a ktype pointer loaded from the reclaimed slot: memory corruption plus an indirect call through freed memory.
A:H - Even with no slot reuse, the second teardown triggers a refcount-underflow WARN and KASAN use-after-free reports; with the slot reused, it dereferences wild kernfs and kobject pointers and oopses the storage server. An unauthenticated peer can repeat it.
| Attack Vector |
Network |
Scope |
Unchanged |
| Attack Complexity |
Low |
Confidentiality Impact |
High |
| Privileges Required |
None |
Integrity Impact |
High |
| User Interaction |
None |
Availability Impact |
High |
AV:N - Two RNBD_MSG_CLOSE messages carrying the same device_id arrive as RTRS RDMA-WRITE-WITH-IMM on two connections of one session; rtrs_srv_rdma_done() -> process_io_req() -> rnbd_srv_rdma_ev() -> process_msg_close(). rtrs_srv_rdma_init() listens with RDMA_PS_TCP on IN6ADDR_ANY port 1234, so RoCEv2/iWARP peers reach it over routable IP.
AC:L - The peer sends both CLOSEs. Each connection has its own IB_POLL_WORKQUEUE CQ, so the handlers run concurrently, and an OPEN on a third connection holds srv_sess->lock while both rnbd_get_sess_dev() lookups succeed. A lost race leaves the second lookup at -ENXIO, which is harmless, so the attacker can retry at will.
PR:N - rtrs_rdma_connect() and process_info_req() check only RTRS_MAGIC, the version, cid and uuid, with no credentials. process_msg_open() then read-only opens any block device under dev_search_path (default "/"), so an unauthenticated peer gets the device_id it needs for the two CLOSEs.
UI:N - The server handles the CLOSE messages in its CQ workqueue as part of normal RTRS operation. No administrator or local user does anything.
S:U - The freed rnbd_srv_sess_dev and everything the second teardown touches is memory of the server's own kernel; no VM, IOMMU or sandbox boundary is crossed.
C:H - The second process_msg_close() runs rnbd_srv_destroy_dev_session_sysfs() on a kfree'd kmalloc-512 rnbd_srv_sess_dev, reading kobj->sd, parent, kset and ktype from freed memory. If another object refills the slot, those pointers are under attacker influence, which can be groomed into a kernel read.
I:H - On the freed object, kobject_del() writes kobj->sd/parent/state and does kobject_put(parent). kobject_put() decrements kobj->kref, and when it reaches zero kobject_cleanup() calls t->release via a ktype pointer loaded from the reclaimed slot: memory corruption plus an indirect call through freed memory.
A:H - Even with no slot reuse, the second teardown triggers a refcount-underflow WARN and KASAN use-after-free reports; with the slot reused, it dereferences wild kernfs and kobject pointers and oopses the storage server. An unauthenticated peer can repeat it.
CVSS 3.1