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

Re: [RFC PATCH 2/3] Make ce_compare_gitlink thread-safe

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 6, 2024, 01:58 UTC
Message-ID
<xmqqzfvcunny.fsf@gitster.g>
In-Reply-To
<20240306012323.GA3817803@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> There is one more, I think: if you _do_ free the allocated string to
> avoid the leak you mention, then some other code which was relying on
> the lifetime of that string to be effectively infinite will now have a
> user-after-free.
Ah, yes, you're right.  I completely forgot about that shallow copy.
Show 17 quoted lines
> A few other things to note, looking at this code:
>
>   - isn't kvi->path in the same boat? We do not duplicate it at all, so
>     it seems like the shallow copy made in the configset could cause a
>     user-after-free.
>
>   - the "fix" I showed above hits your point 2: now we are making a lot
>     more copies of that string. I will note that we're already making a
>     lot of copies of the kvi struct in the first place, so unless you
>     have really long pathnames, it probably isn't a big difference.
>
>     But it possibly could make sense to have the configset own a single
>     duplicate string, and then let the kvi structs it holds point to
>     that string. But IMHO all of this should be details of the configset
>     code, and the main config-iteration code should not have to worry
>     about this at all. I.e., I think kvi_from_source() should not be
>     duplicating anything in the first place.
Thanks for a detailed write-up.
Previous: Jeff KingNext: Atneya Nair
Message 13 of 17 in “Parallel submodule status”
  1. 0/3 Parallel submodule statusAtneya Nair, Mar 5, 2024
  2. 1/3 Make read_gitfile and resolve_gitfile thread safeAtneya Nair, Mar 5, 2024
  3. Junio C HamanoMar 5, 2024
  4. Eric SunshineMar 5, 2024
  5. Atneya NairMar 12, 2024
  6. Jean-Noël AvilaMar 6, 2024
  7. Junio C HamanoMar 6, 2024
  8. Atneya NairMar 12, 2024
  9. 2/3 Make ce_compare_gitlink thread-safeAtneya Nair, Mar 5, 2024
  10. Junio C HamanoMar 5, 2024
  11. Junio C HamanoMar 5, 2024
  12. Jeff KingMar 6, 2024
  13. Junio C HamanoMar 6, 2024
  14. Atneya NairMar 12, 2024
  15. Atneya NairMar 12, 2024
  16. Junio C HamanoMar 13, 2024
  17. 3/3 Preload submodule state in refresh_indexAtneya Nair, Mar 5, 2024

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.