Skip to content

Conversation

@the-ancient-1
Copy link
Member

Changelog entry

...

Changelog category

  • Not for changelog (changelog entry is not required)

Description for reviewers

Metadata was unencrypted and format sector obliteration did not render it unreadable. Hash the key so that obliteration works once again.

@github-actions
Copy link

github-actions bot commented Apr 7, 2025

🟢 2025-04-07 22:41:21 UTC The validation of the Pull Request description is successful.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (3)

ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl_metadata.cpp:44

  • The inline reinterpret_cast of 'PDisk->Format.ChunkKey' to 'ui64*' may violate strict aliasing rules and lead to undefined behavior; consider using a helper function or a safer conversion method to extract the magic value.
if (header->CheckHash((ui64*)(void*)&PDisk->Format.ChunkKey)) {

ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl_metadata.cpp:596

  • The reinterpret_cast used to pass the magic value from 'Format.ChunkKey' is repeated here; consider abstracting this conversion into a helper function to improve safety and maintainability.
CreateMetadataPayload(write.Metadata, offset, payloadSize, Format.SectorSize, Cfg->EnableSectorEncryption, Format.ChunkKey, Meta.NextSequenceNumber, i, numSlotsRequired, (ui64*)(void*)&Format.ChunkKey);

ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl_metadata.cpp:620

  • The repeated pattern of reinterpret_cast to obtain a pointer to the magic value from 'fmt.DataKey' could be refactored into a well-defined helper for improved clarity and to avoid potential undefined behavior.
CreateMetadataPayload(write.Metadata, 0, write.Metadata.size(), DefaultSectorSize, true, fmt.DataKey, 0, 0, 1, (ui64*)(void*)&fmt.DataKey);

auto *header = reinterpret_cast<TMetadataHeader*>(Buffer.GetDataMut());
header->Encrypt(cypher);
if (!header->CheckHash()) {
if (!header->CheckHash((ui64*)(void*)&Format.DataKey)) {
Copy link

Copilot AI Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the previous instance, using reinterpret_cast to pass 'Format.DataKey' as a magic pointer may lead to undefined behavior; a safer, more explicit conversion method is recommended.

Suggested change
if (!header->CheckHash((ui64*)(void*)&Format.DataKey)) {
ui64 dataKey;
std::memcpy(&dataKey, &Format.DataKey, sizeof(ui64));
if (!header->CheckHash(&dataKey)) {

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Apr 7, 2025

2025-04-07 22:52:50 UTC Pre-commit check linux-x86_64-relwithdebinfo for d707615 has started.
2025-04-07 22:53:07 UTC Artifacts will be uploaded here
2025-04-07 22:55:49 UTC ya make is running...
🟡 2025-04-07 23:52:52 UTC Some tests failed, follow the links below. Going to retry failed tests...

Details

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
20397 19044 0 1 1244 108

2025-04-07 23:54:32 UTC ya make is running... (failed tests rerun, try 2)
🟢 2025-04-08 00:04:51 UTC Tests successful.

Test history | Ya make output | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
151 (only retried tests) 49 0 0 0 102

🟢 2025-04-08 00:04:58 UTC Build successful.
🟢 2025-04-08 00:05:17 UTC ydbd size 2.2 GiB changed* by +8 Bytes, which is < 100.0 KiB vs main: OK

ydbd size dash main: d39b14f merge: d707615 diff diff %
ydbd size 2 355 855 744 Bytes 2 355 855 752 Bytes +8 Bytes +0.000%
ydbd stripped size 492 562 912 Bytes 492 562 912 Bytes 0 Bytes 0.000%

*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation

@github-actions
Copy link

github-actions bot commented Apr 7, 2025

2025-04-07 22:52:56 UTC Pre-commit check linux-x86_64-release-asan for d707615 has started.
2025-04-07 22:53:11 UTC Artifacts will be uploaded here
2025-04-07 22:55:54 UTC ya make is running...
🟡 2025-04-08 00:09:36 UTC Some tests failed, follow the links below. This fail is not in blocking policy yet Going to retry failed tests...

Details

Test history | Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
12910 12735 0 112 28 35

2025-04-08 00:10:41 UTC ya make is running... (failed tests rerun, try 2)
🟡 2025-04-08 00:23:39 UTC Some tests failed, follow the links below. This fail is not in blocking policy yet Going to retry failed tests...

Details

Test history | Ya make output | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
232 (only retried tests) 161 0 36 4 31

2025-04-08 00:23:48 UTC ya make is running... (failed tests rerun, try 3)
🟡 2025-04-08 00:37:47 UTC Some tests failed, follow the links below. This fail is not in blocking policy yet

Test history | Ya make output | Test bloat | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
100 (only retried tests) 34 0 34 1 31

🟢 2025-04-08 00:37:54 UTC Build successful.
🟢 2025-04-08 00:38:21 UTC ydbd size 3.8 GiB changed* by -88 Bytes, which is <= 0 Bytes vs main: OK

ydbd size dash main: d39b14f merge: d707615 diff diff %
ydbd size 4 133 646 784 Bytes 4 133 646 696 Bytes -88 Bytes -0.000%
ydbd stripped size 1 427 982 408 Bytes 1 427 982 344 Bytes -64 Bytes -0.000%

*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation

mregrock
mregrock approved these changes Apr 8, 2025
@mregrock mregrock merged commit 9e501b4 into ydb-platform:main Apr 9, 2025
13 checks passed
mregrock added a commit that referenced this pull request Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants