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

Re: [PATCH v4] name-hash: don't reuse cache_entry in dir_entry

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 21, 2015, 19:49 UTC
Message-ID
<xmqqpp08uhn3.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1445450051-7430-1-git-send-email-dturner@twopensource.com>
David Turner <dturner@twopensource.com> writes:
Show 19 quoted lines
> Stop reusing cache_entry in dir_entry; doing so causes a
> use-after-free bug.
>
> During merges, we free entries that we no longer need in the
> destination index.  But those entries might have also been stored in
> the dir_entry cache, and when a later call to add_to_index found them,
> they would be used after being freed.
>
> To prevent this, change dir_entry to store a copy of the name instead
> of a pointer to a cache_entry.  This entails some refactoring of code
> that expects the cache_entry.
>
> Keith McGuigan <kmcguigan@twitter.com> diagnosed this bug and wrote
> the initial patch, but this version does not use any of Keith's code.
>
> Helped-by: Keith McGuigan <kmcguigan@twitter.com>
> Helped-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: David Turner <dturner@twopensource.com>
> ---

The patch looks good to me. Will replace the ce-refcnt one with this.

Thanks for following it through.
Previous: David Turner
Message 2 of 2 in “name-hash: don't reuse cache_entry in dir_entry”
  1. name-hash: don't reuse cache_entry in dir_entryDavid Turner, Oct 21, 2015
  2. Junio C HamanoOct 21, 2015

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.