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

Re: [PATCH] Avoid infinite loop in malformed packfiles

From
Oori@eigenstate.org <ori@eigenstate.org>
Date
Aug 23, 2020, 02:52 UTC
Message-ID
<5374D56FBAB7F3BCD976B433934DEFCA@eigenstate.org>
In-Reply-To
<20200823005236.10386-1-ori@eigenstate.org>
Show 15 quoted lines
> In packfile.c:1680, there's an infinite loop that tries to get
> to the base of a packfile. With offset deltas, the offset needs
> to be greater than 0, so it's always walking backwards, and the
> search is guaranteed to terminate.
> 
> With reference deltas, there's no check for a cycle in the
> references, so a cyclic reference will cause git to loop
> infinitely, growing the delta_stack infinitely, which will
> cause it to consume all available memory as as a full CPU
> core.
> 
> This change puts an arbitrary limit of 10,000 on the number
> of iterations we make when chasing down a base commit, to
> prevent looping forever, using all available memory growing
> the delta stack.

For context, I discovered this accidentally when I introduced a bug in pack deltification in git9 (my implementation of git for plan 9). An example of a packfile and index that will reproduce this issue is available here:

https://eigenstate.org/tmp/95a0f4f3f3f21d723d501552eaf22ff4055e13a4.pack https://eigenstate.org/tmp/95a0f4f3f3f21d723d501552eaf22ff4055e13a4.idx

The suggestion to just cap the depth instead of doing full cycle detection came from Jeff King (peff@peff.net)

Previous: Ori BernsteinNext: Eric Sunshine
Message 2 of 20 in “Avoid infinite loop in malformed packfiles”
  1. Avoid infinite loop in malformed packfilesOri Bernstein, Aug 23, 2020
  2. ori@eigenstate.orgAug 23, 2020
  3. Eric SunshineAug 23, 2020
  4. Avoid infinite loop in malformed packfilesOri Bernstein, Aug 23, 2020
  5. René ScharfeAug 23, 2020
  6. Ori BernsteinAug 23, 2020
  7. René ScharfeAug 24, 2020
  8. Jeff KingAug 24, 2020
  9. Junio C HamanoAug 24, 2020
  10. Jeff KingAug 24, 2020
  11. Junio C HamanoAug 24, 2020
  12. ori@eigenstate.orgAug 30, 2020
  13. René ScharfeAug 30, 2020
  14. Junio C HamanoAug 30, 2020
  15. Jeff KingAug 31, 2020
  16. Junio C HamanoAug 31, 2020
  17. Jeff KingAug 31, 2020
  18. ori@eigenstate.orgAug 31, 2020
  19. Junio C HamanoAug 24, 2020
  20. Junio C HamanoAug 24, 2020

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.