]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: Fix logic in fscrypt hole optimization
authorChristopher Hoffman <choffman@redhat.com>
Tue, 17 Jun 2025 16:44:08 +0000 (16:44 +0000)
committerChristopher Hoffman <choffman@redhat.com>
Wed, 5 Nov 2025 13:59:35 +0000 (13:59 +0000)
In fscrypt decryption code path, ensure if a data block
is hit when there are holes present in adjacent blocks,
that we exit hole traversal and continue on to decrypt the block.

Fixes: https://tracker.ceph.com/issues/71602
Signed-off-by: Christopher Hoffman <choffman@redhat.com>
src/client/FSCrypt.cc

index d3f162c8af2491f1c7d38e0997c0b937964e81ef..edb38898affafe252c62e4c0d11ae86449eae9ad 100644 (file)
@@ -898,11 +898,25 @@ int FSCryptFDataDenc::decrypt_bl(uint64_t off, uint64_t len, uint64_t pos, const
   while (pos < target_end) {
     bool has_hole = false;
 
+    /*
+     * Check to see if cur_block is part of a
+     * hole. We expect holes to ordered by offset.
+     *
+     * There is four states it can be in
+     * 1. If position is before hole offset, it cannot be part of a hole
+     * 2. If hole end is less than position, hole occurs completely before
+     * 3. If hole starts after target_end, hole occurs completely after
+     * 4. No conditionals are met, is a hole
+     */
+
     while (hiter != holes.end()) {
       uint64_t hofs = hiter->first;
       uint64_t hlen = hiter->second;
       uint64_t hend = hofs + hlen - 1;
 
+      if (pos < hofs)
+       break;
+
       if (hend < pos) {
         ++hiter;
         continue;