From 0b6ecbf06be16849b2bfff45c795fc9f54e6a6ec Mon Sep 17 00:00:00 2001 From: Sergey Belyakov Date: Fri, 31 Oct 2025 11:15:30 +0300 Subject: [PATCH] Validate CrcMode of extreme queries in DSProxy and VDisk Skeleton (#27960) --- ydb/core/base/blobstorage.h | 2 ++ ydb/core/blobstorage/vdisk/query/query_public.cpp | 9 +++++++++ ydb/core/erasure/erasure.cpp | 10 ++++++++++ ydb/core/erasure/erasure.h | 1 + 4 files changed, 22 insertions(+) diff --git a/ydb/core/base/blobstorage.h b/ydb/core/base/blobstorage.h index 1ed0a65fc8dc..7c5d105f457b 100644 --- a/ydb/core/base/blobstorage.h +++ b/ydb/core/base/blobstorage.h @@ -1128,6 +1128,8 @@ struct TEvBlobStorage { Y_ABORT_UNLESS(sh < id.BlobSize(), "Please, don't read behind the end of the blob! BlobSize# %" PRIu32 " sh# %" PRIu32, (ui32)id.BlobSize(), (ui32)sh); + Y_ABORT_UNLESS(TErasureType::IsCrcModeValid(id.CrcMode()), + "Please, set correct CrcMode for query, CrcMode# %" PRIu32, id.CrcMode()); } TString ToString() const { diff --git a/ydb/core/blobstorage/vdisk/query/query_public.cpp b/ydb/core/blobstorage/vdisk/query/query_public.cpp index 91fbaf4be64d..bbf8cd1df32e 100644 --- a/ydb/core/blobstorage/vdisk/query/query_public.cpp +++ b/ydb/core/blobstorage/vdisk/query/query_public.cpp @@ -138,6 +138,15 @@ namespace NKikimr { if (record.ExtremeQueriesSize() == 0) return false; // we need to have one + for (const auto& query : record.GetExtremeQueries()) { + TLogoBlobID blobId = LogoBlobIDFromLogoBlobID(query.GetId()); + if (!TErasureType::IsCrcModeValid(blobId.CrcMode())) { + // We shouldn't be able to create TEvGet request with invalid CrcMode at all + // something went wrong + return false; + } + } + return true; } diff --git a/ydb/core/erasure/erasure.cpp b/ydb/core/erasure/erasure.cpp index 21030ca7434f..a5c7550cdf5f 100644 --- a/ydb/core/erasure/erasure.cpp +++ b/ydb/core/erasure/erasure.cpp @@ -3206,6 +3206,16 @@ void TErasureType::RestoreData(ECrcMode crcMode, TDataPartSet& partSet, bool res } } +bool TErasureType::IsCrcModeValid(ui32 crcModeRaw) { + switch (crcModeRaw) { + case static_cast(ECrcMode::CrcModeNone): + case static_cast(ECrcMode::CrcModeWholePart): + return true; + default: + return false; + } +} + } // NKikimr Y_DECLARE_OUT_SPEC(, NKikimr::TErasureType::EErasureSpecies, stream, value) { diff --git a/ydb/core/erasure/erasure.h b/ydb/core/erasure/erasure.h index 183584d2dc18..ffde4f28b604 100644 --- a/ydb/core/erasure/erasure.h +++ b/ydb/core/erasure/erasure.h @@ -369,6 +369,7 @@ struct TErasureType { ui64 BlockSplitPartUsedSize(ui64 dataSize, ui32 partIdx) const; ui32 BlockSplitPartIndex(ui64 offset, ui64 dataSize, ui64 &outPartOffset) const; ui64 BlockSplitWholeOffset(ui64 dataSize, ui64 partIdx, ui64 offset) const; + static bool IsCrcModeValid(ui32 crcModeRaw); static const std::array ErasureName; protected: