git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 5/9] commit-graph: abort as soon as we see a bogus chunk
Date: Thu, 9 Nov 2023 16:18:24 -0500	[thread overview]
Message-ID: <ZU1L8qdIjz/OIAfR@nand.local> (raw)
In-Reply-To: <20231109071711.GE2698043@coredump.intra.peff.net>

On Thu, Nov 09, 2023 at 02:17:11AM -0500, Jeff King wrote:
> The code to read commit-graph files tries to read all of the required
> chunks, but doesn't abort if we can't find one (or if it's corrupted).
> It's only at the end of reading the file that we then do some sanity
> checks for NULL entries. But it's preferable to detect the errors and
> bail immediately, for a few reasons:
>
>   1. It's less error-prone. It's easy in the reader functions to flag an
>      error but still end up setting some struct fields (an error I in
>      fact made while working on this patch series).
>
>   2. It's safer. Since verifying some chunks depends on the values of
>      other chunks, we may be depending on not-yet-verified data. I don't
>      know offhand of any case where this can cause problems, but it's
>      one less subtle thing to worry about in the reader code.
>
>   3. It prevents the user from seeing nonsense errors. If we're missing
>      an OIDL chunk, then g->num_commits will be zero. And so we may
>      complain that the size of our CDAT chunk (which should have a
>      fixed-size record for each commit) is wrong unless it's also zero.
>      But that's misleading; the problem is the missing OIDL chunk; the
>      CDAT one might be fine!
>
> So let's just check the return value from read_chunk(). This is exactly
> how the midx chunk-reading code does it.

All very well explained. I hit that same snag as you did when I was
working on the few patches I proposed we put on top of your earlier
chunk-format hardening series.

I'm glad to see this getting cleaned up, and I'm very happy with the
post-image of this patch.

Thanks,
Taylor

  reply	other threads:[~2023-11-09 21:18 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-09  7:03 [PATCH 0/9] some more chunk-file bounds-checks fixes Jeff King
2023-11-09  7:09 ` [PATCH 1/9] commit-graph: handle overflow in chunk_size checks Jeff King
2023-11-09 21:13   ` Taylor Blau
2023-11-09 21:27     ` Jeff King
2023-11-09  7:12 ` [PATCH 2/9] midx: check consistency of fanout table Jeff King
2023-11-09  7:13 ` [PATCH 3/9] commit-graph: drop redundant call to "lite" verification Jeff King
2023-11-09  7:14 ` [PATCH 4/9] commit-graph: clarify missing-chunk error messages Jeff King
2023-11-09  7:17 ` [PATCH 5/9] commit-graph: abort as soon as we see a bogus chunk Jeff King
2023-11-09 21:18   ` Taylor Blau [this message]
2023-11-09  7:24 ` [PATCH 6/9] commit-graph: use fanout value for graph size Jeff King
2023-11-09 21:20   ` Taylor Blau
2023-11-09 21:38     ` Jeff King
2023-11-09 22:15       ` Taylor Blau
2023-11-10 21:52         ` Jeff King
2023-11-09  7:25 ` [PATCH 7/9] commit-graph: check order while reading fanout chunk Jeff King
2023-11-09  7:25 ` [PATCH 8/9] commit-graph: drop verify_commit_graph_lite() Jeff King
2023-11-09  7:26 ` [PATCH 9/9] commit-graph: mark chunk error messages for translation Jeff King
2023-11-09 21:22 ` [PATCH 0/9] some more chunk-file bounds-checks fixes Taylor Blau
2023-11-09 22:34 ` [PATCH 0/7] chunk-format: introduce `pair_chunk_expect()` Taylor Blau
2023-11-09 22:34   ` [PATCH 1/7] chunk-format: introduce `pair_chunk_expect()` helper Taylor Blau
2023-11-10  4:55     ` Junio C Hamano
2023-11-10 16:27       ` Taylor Blau
2023-11-10 22:01         ` Jeff King
2023-11-10 23:39           ` Junio C Hamano
2023-11-10 23:38         ` Junio C Hamano
2023-11-10 21:57       ` Jeff King
2023-11-10 22:09         ` Jeff King
2023-11-10 22:08     ` Jeff King
2024-01-15 22:31     ` Linus Arver
2024-01-15 22:53       ` Linus Arver
2024-01-16 15:10       ` Jeff King
2024-01-18 23:59         ` Linus Arver
2023-11-09 22:34   ` [PATCH 2/7] commit-graph: read `OIDL` chunk with `pair_chunk_expect()` Taylor Blau
2023-11-10 22:10     ` Jeff King
2023-11-09 22:34   ` [PATCH 3/7] commit-graph: read `CDAT` " Taylor Blau
2023-11-09 22:34   ` [PATCH 4/7] commit-graph: read `GDAT` " Taylor Blau
2023-11-09 22:34   ` [PATCH 5/7] commit-graph: read `BIDX` " Taylor Blau
2023-11-09 22:34   ` [PATCH 6/7] midx: read `OIDL` " Taylor Blau
2023-11-09 22:34   ` [PATCH 7/7] midx: read `OOFF` " Taylor Blau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZU1L8qdIjz/OIAfR@nand.local \
    --to=me@ttaylorr.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).