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

Re: [PATCH] setup: avoid unconditional open with write flags

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Dec 5, 2022, 22:13 UTC
Message-ID
<Y45tGLaJwg3Lt5uJ@tapette.crustytoothpaste.net>
In-Reply-To
<20221205190019.52829-1-cgzones@googlemail.com>
On 2022-12-05 at 19:00:19, Christian Göttsche wrote:
Show 17 quoted lines
> Commit 57f5d52a942 ("common-main: call sanitize_stdfds()") added the
> sanitization for standard file descriptors (stdin, stdout, stderr) to
> all binaries.  The lead to all binaries unconditionally opening
> /dev/null with the flag O_RDWR (read and write).  Most of the time the
> standard file descriptors should be set up properly and the sanitization
> ends up doing nothing.
> 
> There are many non modifying git operations, like `git status` or `git
> stash list`, which might be called by a parent to gather information
> about the repository.  That parent might run under a seccomp filter to
> avoid accidental modification or unwanted command execution on memory
> corruptions.  As part of that seccomp filter open(2) and openat(2) might
> be only allowed in read-only mode (O_RDONLY), thus preventing git's
> sanitation and stopping the application.
> 
> Check before opening /dev/null to populate a possible non-present
> standard file descriptor if actually any is missing.

I don't think this patch makes anything worse, and so I think it should be fine as it is.

_However_, I will say that `git status` is not a read-only command because it can write the index, and we aren't, in general, going to be able to promise that any portion of Git will work with only O_RDONLY file descriptors. I suspect such a sandbox is going to result in a highly broken Git in general, and so it wouldn't be a good idea.

-- 
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA
Previous: Christian GöttscheNext: Jeff King
Message 2 of 10 in “setup: avoid unconditional open with write flags”
  1. setup: avoid unconditional open with write flagsChristian Göttsche, Dec 5, 2022
  2. brian m. carlsonDec 5, 2022
  3. Jeff KingDec 6, 2022
  4. Christian GöttscheDec 6, 2022
  5. Taylor BlauDec 5, 2022
  6. Junio C HamanoDec 6, 2022
  7. Taylor BlauDec 6, 2022
  8. Junio C HamanoDec 6, 2022
  9. René ScharfeDec 6, 2022
  10. Junio C HamanoDec 6, 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.