From 1d851cf988c54575a47eed7ba2e4c53329452cd0 Mon Sep 17 00:00:00 2001 From: zyfjeff Date: Tue, 29 Aug 2023 11:36:51 +0800 Subject: [PATCH] bugfix: do not fill 0 buffer, and skip validate features 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 Signed-off-by: zyfjeff --- storage/src/meta/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/storage/src/meta/mod.rs b/storage/src/meta/mod.rs index a8d1e23d0a4..5787f5bcf94 100644 --- a/storage/src/meta/mod.rs +++ b/storage/src/meta/mod.rs @@ -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!( @@ -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()