CVE-2021-46933

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

Description

In the Linux kernel, the following vulnerability has been resolved:<br /> <br /> usb: gadget: f_fs: Clear ffs_eventfd in ffs_data_clear.<br /> <br /> ffs_data_clear is indirectly called from both ffs_fs_kill_sb and<br /> ffs_ep0_release, so it ends up being called twice when userland closes ep0<br /> and then unmounts f_fs.<br /> If userland provided an eventfd along with function&amp;#39;s USB descriptors, it<br /> ends up calling eventfd_ctx_put as many times, causing a refcount<br /> underflow.<br /> NULL-ify ffs_eventfd to prevent these extraneous eventfd_ctx_put calls.<br /> <br /> Also, set epfiles to NULL right after de-allocating it, for readability.<br /> <br /> For completeness, ffs_data_clear actually ends up being called thrice, the<br /> last call being before the whole ffs structure gets freed, so when this<br /> specific sequence happens there is a second underflow happening (but not<br /> being reported):<br /> <br /> /sys/kernel/debug/tracing# modprobe usb_f_fs<br /> /sys/kernel/debug/tracing# echo ffs_data_clear &gt; set_ftrace_filter<br /> /sys/kernel/debug/tracing# echo function &gt; current_tracer<br /> /sys/kernel/debug/tracing# echo 1 &gt; tracing_on<br /> (setup gadget, run and kill function userland process, teardown gadget)<br /> /sys/kernel/debug/tracing# echo 0 &gt; tracing_on<br /> /sys/kernel/debug/tracing# cat trace<br /> smartcard-openp-436 [000] ..... 1946.208786: ffs_data_clear

Vulnerable products and versions

CPE From Up to
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 4.0.0 (including) 4.4.298 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 4.5.0 (including) 4.9.296 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 4.10.0 (including) 4.14.261 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 4.15.0 (including) 4.19.224 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 4.20.0 (including) 5.4.170 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.5.0 (including) 5.10.90 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.11.0 (including) 5.15.13 (excluding)