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

[PATCH 0/6] harden tree-walking against integer overflow

From
Jeff King <peff@peff.net>
Date
Jul 31, 2019, 04:37 UTC
Message-ID
<20190731043659.GA27028@sigill.intra.peff.net>

I noticed that it's possible to get funny integer over/underflows with tree-walk's traverse_info (with specially-crafted absurdly-sized tree paths). I wasn't able to turn this into an actual buffer overflow because the funky sizes cause allocation failures way before we ever get into make_traverse_path(). But it makes sense to protect ourselves anyway.

The first two patches are an unrelated memory problem I found (and they're here in the same series because I build on the cleanups). I don't think it's security-relevant, though; it involves reading from uninitialized heap memory, but we don't actually _do_ anything with the result. We just copy uninitialized bytes from one heap buffer to the other, and then never look at them again.

  [1/6]: setup_traverse_info(): stop copying oid
  [2/6]: tree-walk: drop oid from traverse_info
  [3/6]: tree-walk: use size_t consistently
  [4/6]: tree-walk: accept a raw length for traverse_path_len()
  [5/6]: tree-walk: add a strbuf wrapper for make_traverse_path()
  [6/6]: tree-walk: harden make_traverse_path() length computations
 Documentation/technical/api-tree-walking.txt |  8 ++-
 builtin/merge-tree.c                         |  5 +-
 cache-tree.c                                 |  2 +-
 tree-walk.c                                  | 64 +++++++++++------
 tree-walk.h                                  | 18 +++--
 unpack-trees.c                               | 74 +++++++++++---------
 6 files changed, 103 insertions(+), 68 deletions(-)
-Peff
Next: Jeff King
Message 1 of 8 in “harden tree-walking against integer overflow”
  1. 0/6 harden tree-walking against integer overflowJeff King, Jul 31, 2019
  2. 1/6 setup_traverse_info(): stop copying oidJeff King, Jul 31, 2019
  3. 2/6 tree-walk: drop oid from traverse_infoJeff King, Jul 31, 2019
  4. 3/6 tree-walk: use size_t consistentlyJeff King, Jul 31, 2019
  5. Derrick StoleeAug 1, 2019
  6. 4/6 tree-walk: accept a raw length for traverse_path_len()Jeff King, Jul 31, 2019
  7. 5/6 tree-walk: add a strbuf wrapper for make_traverse_path()Jeff King, Jul 31, 2019
  8. 6/6 tree-walk: harden make_traverse_path() length computationsJeff King, Jul 31, 2019

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.