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

Re: [PATCH] wrapper: Fix a errno discrepancy on NetBSD.

From
Junio C Hamano <gitster@pobox.com>
Date
May 6, 2025, 22:58 UTC
Message-ID
<xmqqzffpe48u.fsf@gitster.g>
In-Reply-To
<20250505180311.GA29783@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 23 quoted lines
> On Mon, May 05, 2025 at 08:43:18AM -0700, Junio C Hamano wrote:
>
>> But for other kind of requirements, we want to fulfill them on all
>> platforms that we claim to support.  Using open_nofollow() to
>> achieve hard atomicity requirement would be a bug in such a
>> situation.  Should we somehow warn our developers against its use?
>
> The comment above the declaration says:
>
>   /*
>    * Open with O_NOFOLLOW, or equivalent. Note that the fallback equivalent
>    * may be racy. Do not use this as protection against an attacker who can
>    * simultaneously create paths.
>    */
>   int open_nofollow(const char *path, int flags);
>
> though that may not be enough. 00611d8440 (add open_nofollow() helper,
> 2021-02-16) discusses a way that it could be made less racy, at a
> slightly increased cost.
>
> IMHO that is somewhat orthogonal to the issue here, though, which is
> purely about the case where O_NOFOLLOW does exist (ironically, our
> racy fallback code consistently returns ELOOP ;) ).

Yup. And with the above comment, I would say that my worries above are unfounded.

Show 6 quoted lines
> The issue at hand is that particular errno responses are not always
> portable. The patch discussed here improves that. My point was more that
> I'm not sure to what degree we should care about errno consistency in
> our wrappers (which is inherently a bit whack-a-mole as we find new
> cases), versus trying not to care too hard about specific errno values
> in calling code.

Yeah, it does give me a bad aftertaste having to pretend (by adding compat code to translate as needed) that all systems share the same set of errno, but we live in not-so-ideal world, so I am afraild that it cannot be avoided.

Show 5 quoted lines
> I can see arguments either way (and as I said, an argument for making
> errno values consistent even if we try to rely on them less). Mostly I
> was just a little surprised to see open_nofollow() being used in this
> way (especially since we have to end up stat()-ing anyway to check for
> other cases).
That is true.

The callers in attr.c and dir.c do want to fstat() after they open, but they are more interested in atomicity (with "the best effort on less capable systems" attitude). The one in mailmap.c doesn't do any stat(), but again it is more about atomisity with the same attitude, I think.

Previous: shejialuoNext: Collin Funk
Message 16 of 25 in “wrapper: Fix a errno discrepancy on NetBSD.”
  1. wrapper: Fix a errno discrepancy on NetBSD.Collin Funk, May 2, 2025
  2. brian m. carlsonMay 3, 2025
  3. Junio C HamanoMay 3, 2025
  4. Collin FunkMay 3, 2025
  5. Junio C HamanoMay 3, 2025
  6. Collin FunkMay 3, 2025
  7. Jeff KingMay 3, 2025
  8. shejialuoMay 3, 2025
  9. Jeff KingMay 3, 2025
  10. Patrick SteinhardtMay 5, 2025
  11. shejialuoMay 5, 2025
  12. Collin FunkMay 3, 2025
  13. Junio C HamanoMay 5, 2025
  14. Jeff KingMay 5, 2025
  15. shejialuoMay 6, 2025
  16. Junio C HamanoMay 6, 2025
  17. wrapper: NetBSD gives EFTYPE and FreeBSD gives EMFILE where POSIX uses ELOOPCollin Funk, May 3, 2025
  18. brian m. carlsonMay 3, 2025
  19. Collin FunkMay 3, 2025
  20. Patrick SteinhardtMay 5, 2025
  21. Junio C HamanoMay 5, 2025
  22. Collin FunkMay 6, 2025
  23. Patrick SteinhardtMay 6, 2025
  24. wrapper: NetBSD gives EFTYPE and FreeBSD gives EMFILE where POSIX uses ELOOPCollin Funk, May 6, 2025
  25. Patrick SteinhardtMay 6, 2025

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.