diff options
author | Yingxin Cheng <yingxin.cheng@intel.com> | 2022-01-06 09:03:20 +0100 |
---|---|---|
committer | Yingxin Cheng <yingxin.cheng@intel.com> | 2022-01-12 06:43:52 +0100 |
commit | 8aaaeea814c429e9e477f69cb4b5a72fc3192405 (patch) | |
tree | 6fc583f4b57f11aa4b79322c525dc51ea3f3176e /src/crimson/os/seastore/segment_manager | |
parent | crimson/os/seastore/../segment_manager: consolidate logs with structured leve... (diff) | |
download | ceph-8aaaeea814c429e9e477f69cb4b5a72fc3192405.tar.xz ceph-8aaaeea814c429e9e477f69cb4b5a72fc3192405.zip |
crimson/os/seastore/../segment_manager: add more validations
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
Diffstat (limited to 'src/crimson/os/seastore/segment_manager')
-rw-r--r-- | src/crimson/os/seastore/segment_manager/block.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/crimson/os/seastore/segment_manager/block.cc b/src/crimson/os/seastore/segment_manager/block.cc index 320b0620e68..f27942d5d3e 100644 --- a/src/crimson/os/seastore/segment_manager/block.cc +++ b/src/crimson/os/seastore/segment_manager/block.cc @@ -304,6 +304,7 @@ write_superblock( { LOG_PREFIX(block_write_superblock); DEBUG("D{} write {}", device_id, sb); + sb.validate(); assert(ceph::encoded_sizeof<block_sm_superblock_t>(sb) < sb.block_size); return seastar::do_with( @@ -382,7 +383,8 @@ Segment::write_ertr::future<> BlockSegment::write( manager.get_offset(paddr)); if (offset < write_pointer || - offset % manager.superblock.block_size != 0) { + offset % manager.superblock.block_size != 0 || + bl.length() % manager.superblock.block_size != 0) { ERROR("D{} S{} offset={}~{} poffset={} invalid write", id.device_id(), id.device_segment_id(), @@ -460,6 +462,7 @@ BlockSegmentManager::mount_ret BlockSegmentManager::mount() }).safe_then([=](auto sb) { set_device_id(sb.device_id); INFO("D{} read {}", get_device_id(), sb); + sb.validate(); superblock = sb; stats.data_read.increment( ceph::encoded_sizeof<block_sm_superblock_t>(superblock)); @@ -616,6 +619,13 @@ SegmentManager::read_ertr::future<> BlockSegmentManager::read( assert(addr.get_device_id() == get_device_id()); + if (s_off % superblock.block_size != 0 || + len % superblock.block_size != 0) { + ERROR("D{} S{} offset={}~{} poffset={} invalid read", + get_device_id(), s_id, s_off, len, p_off); + return crimson::ct_error::invarg::make(); + } + if (s_id >= get_num_segments()) { ERROR("D{} S{} offset={}~{} poffset={} segment-id out of range {}", get_device_id(), s_id, s_off, len, p_off, |