CVE-2024-41012

filelock: Remove locks reliably when fcntl/close race is detected

State
Published
Severity
7.8 High
Published
Jul 23, 2024
Updated
Aug 5, 2026
Reserved
Jul 12, 2024

Read the record on cve.org

Description

In the Linux kernel, the following vulnerability has been resolved:

filelock: Remove locks reliably when fcntl/close race is detected

When fcntl_setlk() races with close(), it removes the created lock with do_lock_file_wait(). However, LSMs can allow the first do_lock_file_wait() that created the lock while denying the second do_lock_file_wait() that tries to remove the lock. Separately, posix_lock_file() could also fail to remove a lock due to GFP_KERNEL allocation failure (when splitting a range in the middle).

After the bug has been triggered, use-after-free reads will occur in lock_get_status() when userspace reads /proc/locks. This can likely be used to read arbitrary kernel memory, but can't corrupt kernel memory.

Fix it by calling locks_remove_posix() instead, which is designed to reliably get rid of POSIX locks associated with the given file and files_struct and is also used by filp_flush().

Scores

CVSSScoreVectorSource
3.17.8 HighCVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:HLinux

Weaknesses

The record names no weakness.

Affected Products

ProductVersions
LinuxLinux
  • c293621bbf678a3d85e3ed721c3921c8a670610d to before d30ff33040834c3b9eee29740acd92f9c7ba2250Affected
  • c293621bbf678a3d85e3ed721c3921c8a670610d to before dc2ce1dfceaa0767211a9d963ddb029ab21c4235Affected
  • c293621bbf678a3d85e3ed721c3921c8a670610d to before 5661b9c7ec189406c2dde00837aaa4672efb6240Affected
  • c293621bbf678a3d85e3ed721c3921c8a670610d to before 52c87ab18c76c14d7209646ccb3283b3f5d87b22Affected
  • c293621bbf678a3d85e3ed721c3921c8a670610d to before ef8fc41cd6f95f9a4a3470f085aecf350569a0b3Affected
  • c293621bbf678a3d85e3ed721c3921c8a670610d to before 5f5d0799eb0a01d550c21b7894e26b2d9db55763Affected
  • c293621bbf678a3d85e3ed721c3921c8a670610d to before b6d223942c34057fdfd8f149e763fa823731b224Affected
  • c293621bbf678a3d85e3ed721c3921c8a670610d to before 3cad1bc010416c6dd780643476bc59ed742436b9Affected
LinuxLinux
  • 2.6.13Affected
  • before 2.6.13Not affected
  • 4.19.319 through 4.19.*Not affected
  • 5.4.281 through 5.4.*Not affected
  • 5.10.223 through 5.10.*Not affected
  • 5.15.164 through 5.15.*Not affected
  • 6.1.101 through 6.1.*Not affected
  • 6.6.42 through 6.6.*Not affected
  • 6.9.9 through 6.9.*Not affected
  • 6.10 and laterNot affected

References

Every record here comes from the CVE Program’s CVE List. © 1999–2026 The MITRE Corporation. CVE is a registered trademark of The MITRE Corporation. The records are reproduced under the CVE Program terms of use.