[PATCH 0/4] midx: verify MIDX checksum before reusing
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Jun 23, 2021, 18:39 UTC
- Message-ID
- <cover.1624473543.git.me@ttaylorr.com>
Here is a small series that came out of a corruption we noticed at GitHub. The corruption is described in the third patch, but the gist is this:
- After writing a MIDX, we experience a disk failure that corrupts the
contents of the repository's MIDX. - We later go to write another MIDX, notice that one is already there, and
then blindly reuse its data without checking its validity, resulting in a
MIDX that contains corrupt data, but whose trailing checksum matches the
preceding contents.This series checks the validity of the trailing checksum when reusing a MIDX while writing a new one, as well as a few other related fix-ups. That should be sufficient to avoid propagating corrupt data forward while writing a MIDX.
We could go further here and run 'git multi-pack-index verify' on the existing MIDX while writing a new one, but the point of this reuse is to avoid having to re-compute/verify the contents of an existing MIDX. So a more lightweight option is pursued here, but alternatives are discussed in 3/4.
Thanks in advance for your review.
Taylor Blau (4): csum-file: introduce checksum_valid() commit-graph: rewrite to use checksum_valid() midx: don't reuse corrupt MIDXs when writing midx: report checksum mismatches during 'verify'
commit-graph.c | 14 ++++++-------- csum-file.c | 16 ++++++++++++++++ csum-file.h | 3 +++ midx.c | 13 +++++++++++++ pack-check.c | 11 +---------- t/t5319-multi-pack-index.sh | 13 +++++++++++++ 6 files changed, 52 insertions(+), 18 deletions(-)
-- 2.31.1.163.ga65ce7f831