]> git.apps.os.sepia.ceph.com Git - ceph-client.git/commit
ceph: fix potential race condition in ceph_ioctl_lazyio()
authorViacheslav Dubeyko <Slava.Dubeyko@ibm.com>
Fri, 13 Jun 2025 18:31:08 +0000 (11:31 -0700)
committerViacheslav Dubeyko <Slava.Dubeyko@ibm.com>
Tue, 17 Jun 2025 19:20:55 +0000 (12:20 -0700)
commit1abcbcd5e3b1cd298288d2aa4e8454e3d64bfe09
treea8dad4e85b5468e82d6f2404fe75b3947421718f
parent01232c8b99f68879981bb27ef4262772de4b7dcd
ceph: fix potential race condition in ceph_ioctl_lazyio()

The Coverity Scan service has detected potential
race condition in ceph_ioctl_lazyio() [1].

The CID 1591046 contains explanation: "Check of thread-shared
field evades lock acquisition (LOCK_EVASION). Thread1 sets
fmode to a new value. Now the two threads have an inconsistent
view of fmode and updates to fields correlated with fmode
may be lost. The data guarded by this critical section may
be read while in an inconsistent state or modified by multiple
racing threads. In ceph_ioctl_lazyio: Checking the value of
a thread-shared field outside of a locked region to determine
if a locked operation involving that thread shared field
has completed. (CWE-543)".

The patch places fi->fmode field access under ci->i_ceph_lock
protection. Also, it introduces the is_file_already_lazy
variable that is set under the lock and it is checked later
out of scope of critical section.

[1] https://scan5.scan.coverity.com/#/project-view/64304/10063?selectedIssue=1591046

Signed-off-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
fs/ceph/ioctl.c