Skip to content

Commit

Permalink
bugfix: do not fill 0 buffer, and skip validate features
Browse files Browse the repository at this point in the history
1. Buffer reset to 0 will cause race during concurrency.

2. Previously, the second validate_header did not actually take effect. Now
it is repaired, and it is found that the features of blob info do not
set the --inline-bootstrap position to true, so the check of features is
temporarily skipped. Essentially needs to be fixed from nydus-image from
upstream.

Signed-off-by: zhaoshang <[email protected]>
Signed-off-by: zyfjeff <[email protected]>
  • Loading branch information
zyfjeff authored and imeoer committed Aug 29, 2023
1 parent 49cc3f9 commit 0e2d72c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions storage/src/meta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,10 @@ impl BlobCompressionContextInfo {
if let Some(reader) = reader {
let buffer =
unsafe { std::slice::from_raw_parts_mut(base as *mut u8, expected_size) };
buffer[0..].fill(0);
Self::read_metadata(blob_info, reader, buffer)?;
Self::validate_header(blob_info, header)?;
if !Self::validate_header(blob_info, header)? {
return Err(enoent!(format!("double check blob_info still invalid",)));
}
filemap.sync_data()?;
} else {
return Err(enoent!(format!(
Expand Down Expand Up @@ -851,7 +852,6 @@ impl BlobCompressionContextInfo {
if u32::from_le(header.s_magic) != BLOB_CCT_MAGIC
|| u32::from_le(header.s_magic2) != BLOB_CCT_MAGIC
|| u32::from_le(header.s_ci_entries) != blob_info.chunk_count()
|| u32::from_le(header.s_features) != blob_info.features().bits()
|| u32::from_le(header.s_ci_compressor) != blob_info.meta_ci_compressor() as u32
|| u64::from_le(header.s_ci_offset) != blob_info.meta_ci_offset()
|| u64::from_le(header.s_ci_compressed_size) != blob_info.meta_ci_compressed_size()
Expand Down

0 comments on commit 0e2d72c

Please sign in to comment.