git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: SHA1 collision in production repo?! (probably not)

From
Jeff King <peff@peff.net>
Date
Apr 1, 2017, 08:03 UTC
Message-ID
<20170401080349.lccextuc3l6fgs6j@sigill.intra.peff.net>
In-Reply-To
<xmqq37dtxi36.fsf@gitster.mtv.corp.google.com>
On Fri, Mar 31, 2017 at 02:16:29PM -0700, Junio C Hamano wrote:
Show 16 quoted lines
> Before we forget...
> 
> -- >8 --
> From: Jeff King <peff@peff.net>
> 
> When sha1_loose_object_info() finds that a loose object file cannot
> be stat(2)ed or mmap(2)ed, it returns -1 to signal an error to the
> caller.  However, if it found that the loose object file is corrupt
> and the object data cannot be used from it, it forgets to return -1.
> 
> This can confuse the caller, who may be lead to mistakenly think
> that there is a loose object and possibly gets an incorrect type and
> size from the function.  The SHA-1 collision detection codepath, for
> example, when it gets an object over the wire and tries to see the
> data is the same as what is available as a loose object locally, can
> get confused when the loose object is correupted due to this bug.

Unfortunately this isn't quite right. I was able to reproduce the problem that Lars saw, and this patch doesn't fix it.

So here's a two-patch series. The first fixes the problem described above, along with a simpler test that demonstrates it. The second fixes Lars's problem on top.

I know you're heading out for a week, so I'll post it now for review, and then hold and repost when you get back.

  [1/2]: sha1_loose_object_info: return error for corrupted objects
  [2/2]: index-pack: detect local corruption in collision check
 builtin/index-pack.c         |  2 ++
 sha1_file.c                  |  2 +-
 t/t1060-object-corruption.sh | 24 ++++++++++++++++++++++++
 3 files changed, 27 insertions(+), 1 deletion(-)
-Peff
Previous: Junio C HamanoNext: Jeff King
Message 9 of 15 in “SHA1 collision in production repo?! (probably not)”
  1. Lars SchneiderMar 31, 2017
  2. Jeff KingMar 31, 2017
  3. Junio C HamanoMar 31, 2017
  4. Jeff KingMar 31, 2017
  5. Jeff KingMar 31, 2017
  6. Junio C HamanoMar 31, 2017
  7. Jeff KingMar 31, 2017
  8. Junio C HamanoMar 31, 2017
  9. Jeff KingApr 1, 2017
  10. 1/2 sha1_loose_object_info: return error for corrupted objectsJeff King, Apr 1, 2017
  11. Junio C HamanoApr 1, 2017
  12. 2/2 index-pack: detect local corruption in collision checkJeff King, Apr 1, 2017
  13. Junio C HamanoApr 1, 2017
  14. Lars SchneiderSep 12, 2017
  15. Jeff KingSep 12, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.