]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commit
ceph: fix potentail race condition of operations with CEPH_I_ODIRECT flag
authorViacheslav Dubeyko <Slava.Dubeyko@ibm.com>
Wed, 16 Jul 2025 18:40:49 +0000 (11:40 -0700)
committerViacheslav Dubeyko <Slava.Dubeyko@ibm.com>
Wed, 16 Jul 2025 18:51:00 +0000 (11:51 -0700)
commit3fc204a98449661db6bd1d484582f5c8392b0f18
treeeae87dbb87245b879764ba173ff91c5d0fbaf280
parentcecb25b9bb86a955a155a36c459c85c6cdd83def
ceph: fix potentail race condition of operations with CEPH_I_ODIRECT flag

The Coverity Scan service has detected potential
race conditions in ceph_block_o_direct(), ceph_start_io_read(),
ceph_block_buffered(), and ceph_start_io_direct() [1 - 4].

The CID 1590942159066515896641590377 contain explanation:
"The value of the shared data will be determined by
the interleaving of thread execution. Thread shared data is accessed
without holding an appropriate lock, possibly causing
a race condition (CWE-366)".

This patch reworks the pattern of accessing/modification of
CEPH_I_ODIRECT flag by means of adding smp_mb__before_atomic()
before reading the status of CEPH_I_ODIRECT flag and
smp_mb__after_atomic() after clearing set/clear this flag.
Also, it was reworked the pattern of using of ci->i_ceph_lock
in ceph_block_o_direct(), ceph_start_io_read(),
ceph_block_buffered(), and ceph_start_io_direct() methods.

[1] https://scan5.scan.coverity.com/#/project-view/64304/10063?selectedIssue=1590942
[2] https://scan5.scan.coverity.com/#/project-view/64304/10063?selectedIssue=1590665
[3] https://scan5.scan.coverity.com/#/project-view/64304/10063?selectedIssue=1589664
[4] https://scan5.scan.coverity.com/#/project-view/64304/10063?selectedIssue=1590377

Signed-off-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
cc: Alex Markuze <amarkuze@redhat.com>
cc: Ilya Dryomov <idryomov@gmail.com>
cc: Ceph Development <ceph-devel@vger.kernel.org>
fs/ceph/io.c
fs/ceph/super.h