CVE-2025-21731

Severity CVSS v4.0:
Pending analysis
Type:
CWE-416 Use After Free
Publication date:
27/02/2025
Last modified:
24/03/2025

Description

In the Linux kernel, the following vulnerability has been resolved:<br /> <br /> nbd: don&amp;#39;t allow reconnect after disconnect<br /> <br /> Following process can cause nbd_config UAF:<br /> <br /> 1) grab nbd_config temporarily;<br /> <br /> 2) nbd_genl_disconnect() flush all recv_work() and release the<br /> initial reference:<br /> <br /> nbd_genl_disconnect<br /> nbd_disconnect_and_put<br /> nbd_disconnect<br /> flush_workqueue(nbd-&gt;recv_workq)<br /> if (test_and_clear_bit(NBD_RT_HAS_CONFIG_REF, ...))<br /> nbd_config_put<br /> -&gt; due to step 1), reference is still not zero<br /> <br /> 3) nbd_genl_reconfigure() queue recv_work() again;<br /> <br /> nbd_genl_reconfigure<br /> config = nbd_get_config_unlocked(nbd)<br /> if (!config)<br /> -&gt; succeed<br /> if (!test_bit(NBD_RT_BOUND, ...))<br /> -&gt; succeed<br /> nbd_reconnect_socket<br /> queue_work(nbd-&gt;recv_workq, &amp;args-&gt;work)<br /> <br /> 4) step 1) release the reference;<br /> <br /> 5) Finially, recv_work() will trigger UAF:<br /> <br /> recv_work<br /> nbd_config_put(nbd)<br /> -&gt; nbd_config is freed<br /> atomic_dec(&amp;config-&gt;recv_threads)<br /> -&gt; UAF<br /> <br /> Fix the problem by clearing NBD_RT_BOUND in nbd_genl_disconnect(), so<br /> that nbd_genl_reconfigure() will fail.

Vulnerable products and versions

CPE From Up to
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 4.12 (including) 5.4.291 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.5 (including) 5.10.235 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.11 (including) 5.15.179 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.16 (including) 6.1.129 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 6.2 (including) 6.6.76 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 6.7 (including) 6.12.13 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 6.13 (including) 6.13.2 (excluding)