]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/cbj: fix a potential overflow bug 53230/head
authorMyoungwon Oh <myoungwon.oh@samsung.com>
Thu, 31 Aug 2023 02:43:24 +0000 (11:43 +0900)
committermyoungwon oh <ohmyoungwon@gmail.com>
Tue, 12 Sep 2023 03:16:04 +0000 (03:16 +0000)
CircularBoundedJournal is similar to circular queue, so segment_seq
increases after rolling. However, current implementation always
increases segment_seq_t when rolling occurs, resulting in
the overflow if segment_seq_t hits MAX_SEG_SEQ.

To mitigate this, this commit changes the type of the segment_seq_t
to uint64_t.

Signed-off-by: Myoungwon Oh <myoungwon.oh@samsung.com>
src/crimson/os/seastore/journal/circular_journal_space.cc
src/crimson/os/seastore/seastore_types.h

index c36064acb12efb616763946a7a36d6bb58ae8d31..123bb91353c2e6b8ce73ddf69635a93700a35a28 100644 (file)
@@ -42,8 +42,10 @@ CircularJournalSpace::roll_ertr::future<> CircularJournalSpace::roll() {
     get_records_start(),
     get_device_id());
   auto seq = get_written_to();
+  seq.segment_seq++;
+  assert(seq.segment_seq < MAX_SEG_SEQ);
   set_written_to(
-    journal_seq_t{++seq.segment_seq, paddr});
+    journal_seq_t{seq.segment_seq, paddr});
   return roll_ertr::now();
 }
 
index 26c5017aadb3f174598b2765c5d439779c62b24c..0b4ad853687fe650de0b1186fdc65efae331c6a9 100644 (file)
@@ -210,7 +210,7 @@ constexpr segment_id_t NULL_SEG_ID = MAX_SEG_ID;
 
 /* Monotonically increasing segment seq, uniquely identifies
  * the incarnation of a segment */
-using segment_seq_t = uint32_t;
+using segment_seq_t = uint64_t;
 static constexpr segment_seq_t MAX_SEG_SEQ =
   std::numeric_limits<segment_seq_t>::max();
 static constexpr segment_seq_t NULL_SEG_SEQ = MAX_SEG_SEQ;