ceph: always call ceph_shift_unused_folios_left()
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
| Linux Linux |
|
|
Original description
In the Linux kernel, the following vulnerability has been resolved:
ceph: always call ceph_shift_unused_folios_left()
The function ceph_process_folio_batch() sets folio_batch entries to NULL, which is an illegal state. Before folio_batch_release() crashes due to this API violation, the function ceph_shift_unused_folios_left() is supposed to remove those NULLs from the array.
However, since commit ce80b76dd327 ("ceph: introduce ceph_process_folio_batch() method"), this shifting doesn't happen anymore because the "for" loop got moved to ceph_process_folio_batch(), and now the `i` variable that remains in ceph_writepages_start() doesn't get incremented anymore, making the shifting effectively unreachable much of the time.
Later, commit 1551ec61dc55 ("ceph: introduce ceph_submit_write() method") added more preconditions for doing the shift, replacing the `i` check (with something that is still just as broken):
- if ceph_process_folio_batch() fails, shifting never happens
- if ceph_move_dirty_page_in_page_array() was never called (because ceph_process_folio_batch() has returned early for some of various reasons), shifting never happens
- if `processed_in_fbatch` is zero (because ceph_process_folio_batch() has returned early for some of the reasons mentioned above or because ceph_move_dirty_page_in_page_array() has failed), shifting never happens
From the CVE record · Linux
References
- git.kernel.org/stable/c/523214f0afa1b3d0e696917bc5a4d0737718e3d7
- git.kernel.org/stable/c/289b6615cf553d98509a9b273195d9936da1cfb2Patch
- git.kernel.org/stable/c/cce7c15faaac79b532a07ed6ab8332280ad83762Patch
- github.com/CVEProject/cvelistV5/tree/main/cves/2025/39xxx/CVE-2025-39879.json
- nvd.nist.gov/vuln/detail/CVE-2025-39879
- git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git