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

Re: [PATCH 2/2] hooks: fix a TOCTOU in "did we run a hook?" heuristic

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 19, 2022, 00:11 UTC
Message-ID
<xmqq4k4vyata.fsf@gitster.g>
In-Reply-To
<patch-2.2-d01d088073b-20220218T203834Z-avarab@gmail.com>
> -int run_commit_hook(int editor_is_used, const char *index_file, const char *name, ...);
> +int run_commit_hook(int editor_is_used, const char *index_file,
> +		    int *invoked_hook, const char *name, ...);
>  

Even though my gut feeling tells me that turning the "yes/no" integer into an enum that includes "there was no such hook", "I tried to run it, but it failed to run" [*], "I ran it and it was happy". would be a more viable approach for the longer term, I guess this extra and ad-hoc parameter would be sufficient as a shorter term improvement.

    Side note: optionally "failed to run" may be split into "failed
    to even start (e.g. ENOEXEC)" and "started successfully but
    exited with non-zero status".  There may or may not be callers
    that wants to see them as distinct cases right now, but an
    interface based on returned enum value would be easier to extend
    than having to add a pointer to return variable every time we
    need to know more details.
Thanks.
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 5 of 12 in “hooks: fix a race in hook execution”
  1. 0/2 hooks: fix a race in hook executionÆvar Arnfjörð Bjarmason, Feb 18, 2022
  2. 1/2 merge: don't run post-hook logic on --no-verifyÆvar Arnfjörð Bjarmason, Feb 18, 2022
  3. Junio C HamanoFeb 18, 2022
  4. 2/2 hooks: fix a TOCTOU in "did we run a hook?" heuristicÆvar Arnfjörð Bjarmason, Feb 18, 2022
  5. Junio C HamanoFeb 19, 2022
  6. Ævar Arnfjörð BjarmasonFeb 19, 2022
  7. Taylor BlauFeb 19, 2022
  8. Ævar Arnfjörð BjarmasonFeb 19, 2022
  9. 0/2 hooks: fix a race in hook executionÆvar Arnfjörð Bjarmason, Mar 7, 2022
  10. 1/2 merge: don't run post-hook logic on --no-verifyÆvar Arnfjörð Bjarmason, Mar 7, 2022
  11. 2/2 hooks: fix an obscure TOCTOU "did we just run a hook?" raceÆvar Arnfjörð Bjarmason, Mar 7, 2022
  12. Jonathan TanMar 21, 2022

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.