Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a latent issue with chunkmemset #1196

Merged
merged 1 commit into from
Mar 18, 2022

Conversation

KungFuJesus
Copy link
Contributor

It would seem that on some platforms, namely those which are
!UNALIGNED64_OK, there was a likelihood of chunkmemset_safe_c copying all
the bytes before passing control flow to chunkcopy, a function which is
explicitly unsafe to be called with a zero length copy.

This fixes that bug for those platforms.

It would seem that on some platforms, namely those which are
!UNALIGNED64_OK, there was a likelihood of chunkmemset_safe_c copying all
the bytes before passing control flow to chunkcopy, a function which is
explicitly unsafe to be called with a zero length copy.

This fixes that bug for those platforms.
@nmoinvaz nmoinvaz added the bug label Mar 18, 2022
@codecov
Copy link

codecov bot commented Mar 18, 2022

Codecov Report

Merging #1196 (754e0d9) into develop (1f87fac) will increase coverage by 0.01%.
The diff coverage is 66.66%.

@@             Coverage Diff             @@
##           develop    #1196      +/-   ##
===========================================
+ Coverage    87.06%   87.08%   +0.01%     
===========================================
  Files          113      113              
  Lines         9698     9700       +2     
  Branches      2464     2465       +1     
===========================================
+ Hits          8444     8447       +3     
- Misses         997     1002       +5     
+ Partials       257      251       -6     
Flag Coverage Δ
macos_clang 26.66% <ø> (ø)
macos_gcc 70.25% <50.00%> (-0.02%) ⬇️
ubuntu_clang 84.38% <66.66%> (-0.66%) ⬇️
ubuntu_clang_debug 84.82% <66.66%> (+0.60%) ⬆️
ubuntu_clang_inflate_allow_invalid_dist 84.88% <66.66%> (-0.01%) ⬇️
ubuntu_clang_inflate_strict 84.97% <66.66%> (-0.01%) ⬇️
ubuntu_clang_mmap 85.08% <66.66%> (-0.01%) ⬇️
ubuntu_clang_pigz 39.72% <33.33%> (-0.02%) ⬇️
ubuntu_clang_pigz_no_optim 40.20% <33.33%> (-0.03%) ⬇️
ubuntu_clang_pigz_no_threads 39.31% <33.33%> (-0.02%) ⬇️
ubuntu_clang_reduced_mem 85.21% <66.66%> (+0.63%) ⬆️
ubuntu_gcc 72.21% <50.00%> (-0.02%) ⬇️
ubuntu_gcc_aarch64 71.85% <50.00%> (-0.02%) ⬇️
ubuntu_gcc_aarch64_compat_no_opt 69.13% <50.00%> (-0.02%) ⬇️
ubuntu_gcc_aarch64_no_acle 70.04% <50.00%> (-0.02%) ⬇️
ubuntu_gcc_aarch64_no_neon 70.00% <50.00%> (-0.02%) ⬇️
ubuntu_gcc_armhf 71.94% <100.00%> (+<0.01%) ⬆️
ubuntu_gcc_armhf_compat_no_opt 69.06% <100.00%> (+<0.01%) ⬆️
ubuntu_gcc_armhf_no_acle 71.96% <100.00%> (+<0.01%) ⬆️
ubuntu_gcc_armhf_no_neon 71.88% <100.00%> (+<0.01%) ⬆️
ubuntu_gcc_armsf 72.54% <100.00%> (+<0.01%) ⬆️
ubuntu_gcc_armsf_compat_no_opt 69.61% <100.00%> (+<0.01%) ⬆️
ubuntu_gcc_benchmark 73.77% <50.00%> (-0.02%) ⬇️
ubuntu_gcc_compat_no_opt 71.13% <50.00%> (-0.02%) ⬇️
ubuntu_gcc_compat_sprefix 73.12% <50.00%> (-0.02%) ⬇️
ubuntu_gcc_m32 72.96% <100.00%> (+0.39%) ⬆️
ubuntu_gcc_mingw_i686 0.00% <0.00%> (ø)
ubuntu_gcc_mingw_x86_64 0.00% <0.00%> (ø)
ubuntu_gcc_no_avx2 70.92% <50.00%> (-0.02%) ⬇️
ubuntu_gcc_no_ctz 73.04% <50.00%> (-0.02%) ⬇️
ubuntu_gcc_no_ctzll 72.80% <50.00%> (-0.02%) ⬇️
ubuntu_gcc_no_pclmulqdq 69.69% <50.00%> (-0.02%) ⬇️
ubuntu_gcc_no_sse2 70.68% <50.00%> (-0.02%) ⬇️
ubuntu_gcc_no_sse4 70.53% <50.00%> (-0.02%) ⬇️
ubuntu_gcc_o3 73.24% <100.00%> (+0.39%) ⬆️
ubuntu_gcc_osb ∅ <ø> (∅)
ubuntu_gcc_pigz 37.67% <50.00%> (-0.07%) ⬇️
ubuntu_gcc_pigz_aarch64 38.33% <50.00%> (-0.02%) ⬇️
ubuntu_gcc_ppc 72.62% <100.00%> (+<0.01%) ⬆️
ubuntu_gcc_ppc64 73.41% <100.00%> (+<0.01%) ⬆️
ubuntu_gcc_ppc64le 72.54% <50.00%> (-0.02%) ⬇️
ubuntu_gcc_ppc_no_power8 73.52% <100.00%> (+<0.01%) ⬆️
ubuntu_gcc_s390x 73.54% <100.00%> (+<0.01%) ⬆️
ubuntu_gcc_s390x_dfltcc 72.31% <100.00%> (-0.02%) ⬇️
ubuntu_gcc_s390x_dfltcc_compat 69.90% <100.00%> (-0.02%) ⬇️
ubuntu_gcc_s390x_no_crc32 73.29% <100.00%> (+<0.01%) ⬆️
ubuntu_gcc_sparc64 73.42% <100.00%> (+<0.01%) ⬆️
ubuntu_gcc_sprefix 72.94% <50.00%> (-0.02%) ⬇️
win64_gcc 72.12% <50.00%> (-0.05%) ⬇️
win64_gcc_compat_no_opt 71.83% <50.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
chunkset_tpl.h 98.92% <66.66%> (-1.08%) ⬇️
deflate.c 82.49% <0.00%> (ø)
test/minigzip.c 55.97% <0.00%> (ø)
test/minideflate.c 56.14% <0.00%> (ø)
arch/s390/dfltcc_deflate.c 70.58% <0.00%> (ø)
test/fuzz/fuzzer_example_flush.c 91.93% <0.00%> (ø)
arch/x86/adler32_avx512.c 100.00% <0.00%> (+4.34%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1f87fac...754e0d9. Read the comment docs.

if (len)
return CHUNKMEMSET(out, dist, len);

return out;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hah, interesting that the coverage check shows this as never being hit until we revert the window layout. It definitely explains why we don't hit this issue until then. In any case, this coverage drop will disappear after #1178 so it's definitely not something that bothers me.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's why some bugs can take years to manifest and are hard to reproduce... Sometimes it's matter of hitting cascade event before all bugs are found.

@Dead2 Dead2 merged commit e81c083 into zlib-ng:develop Mar 18, 2022
@Dead2 Dead2 mentioned this pull request Dec 27, 2022
Dead2 added a commit that referenced this pull request Mar 7, 2023
Changes since 2.0.6:
- Fix CVE-2022-37434 #1328
- Fix chunkmemset #1196
- Fix deflateBound too small #1236
- Fix Z_SOLO #1263
- Fix ACLE variant of crc32 #1274
- Fix inflateBack #1311
- Fix deflate_quick windowsize #1431
- Fix DFLTCC bugs related to adler32 #1349 and #1390
- Fix warnings #1194 #1312 #1362
- MacOS build fix #1198
- Add invalid windowBits handling #1293
- Support for Force TZCNT #1186
- Support for aligned_alloc() #1360
- Minideflate improvements #1175 #1238
- Dont use unaligned access for memcpy #1309
- Build system #1209 #1233 #1267 #1273 #1278 #1292 #1316 #1318 #1365
- Test improvements #1208 #1227 #1241 #1353
- Cleanup #1266
- Documentation #1205 #1359
- Misc improvements #1294 #1297 #1306 #1344 #1348
- Backported zlib fixes
- Backported CI workflows from Develop branch
Dead2 added a commit that referenced this pull request Mar 17, 2023
Changes since 2.0.6:
- Fix CVE-2022-37434 #1328
- Fix chunkmemset #1196
- Fix deflateBound too small #1236
- Fix Z_SOLO #1263
- Fix ACLE variant of crc32 #1274
- Fix inflateBack #1311
- Fix deflate_quick windowsize #1431
- Fix DFLTCC bugs related to adler32 #1349 and #1390
- Fix warnings #1194 #1312 #1362
- MacOS build fix #1198
- Add invalid windowBits handling #1293
- Support for Force TZCNT #1186
- Support for aligned_alloc() #1360
- Minideflate improvements #1175 #1238
- Dont use unaligned access for memcpy #1309
- Build system #1209 #1233 #1267 #1273 #1278 #1292 #1316 #1318 #1365
- Test improvements #1208 #1227 #1241 #1353
- Cleanup #1266
- Documentation #1205 #1359
- Misc improvements #1294 #1297 #1306 #1344 #1348
- Backported zlib fixes
- Backported CI workflows from Develop branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants