--sandbox_block_path: help doesn't say an absent path isn't blocked, or that replacing the path unblocks a running action

Aperta Adatta ai principianti
#31,318 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Documentazione
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
linux
Ambito
build-system

Direzione di ricerca

Cerca nel codice sorgente di Bazel il testo della guida esistente per --sandbox_block_path e ispeziona il punto di ingresso dell'opzione linux-sandbox. Aggiorna la guida o la documentazione per indicare quando il percorso è bloccato e quando una sostituzione può sbloccarlo, quindi esegui l'output --help pertinente per verificare la formulazione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

team-Local-Exec type: documentation (cleanup)

The reporter of #4963 wanted --sandbox_block_path "to prevent likely cases of loss of hermeticity". Its help is one line: "For sandboxed actions, disallow access to this path." On Linux I found two cases where an action read a path passed to this flag. Neither is in the flag's help or in the docs.

The first is a path that does not exist when an action's sandbox is set up. linux-sandbox skips it. That is what #4963 asked for, and b6bb800 made it so, released in 7.3.0. The same issue asked for the flag's description to "document what this is", and the help still reads as quoted above. I'm not asking for a warning. I mention the silence because it leaves the build no way to show that the path wasn't blocked. On 9.2.0 the console output with the flag and an absent path was the same as without the flag, apart from timings and the output directory's name. It was still the same at --sandbox_debug -s once timestamps and PIDs are removed, and at that verbosity an applied block prints a bind mount line naming the path. 7.2.1 failed the build instead: "Mount target '...' does not exist."

Because the check runs for each action, a path that appears during the build was blocked for some actions and not others. I ran two genrules, B depending on A, with the blocked file absent at the start. A host process created it after A had started. Action A read it. B, set up afterwards, got Permission denied. With the file present from the start both were denied, and without the flag both read it.

The second case is a block that was applied. While an action ran, I replaced the blocked file from outside the sandbox, once by renaming a new file over it and once by deleting and recreating it. Both times the running action read the new file. Rewriting the file in place kept it blocked, and actions started afterwards were blocked again. With a blocked directory on 9.1.1, the action's /proc/self/mountinfo listed the bind mount before the replacement and not after. That matches mount_namespaces(7): a mount point replaced from another mount namespace is detached, as the kernel has done since Linux 3.18. Renaming a new file over the old one is the usual way to update a file atomically. So a blocked file that a host process updates that way while an action runs becomes an undeclared input of that action.

The mechanism isn't new. The kernel documents it, and another sandbox that hides paths with bind mounts ran into it and wrote it down when it changed its own cleanup (https://github.com/anthropics/sandbox-runtime/pull/184). What I couldn't find in Bazel's help or tracker is that an action already running can read a blocked path that appears, or is replaced, after its sandbox was set up. The nearest issue, #24514, is a different limit of the same flag, which a maintainer traced to symlink resolution.

All of this was on Linux, Debian 13 with kernel 6.12, under linux-sandbox. On 9.2.0 I ran every case twice, each from a fresh workspace and output root. The absent path and the path that appeared mid-build gave the same results on 8.8.0, and on 9.1.1 with a blocked directory. I didn't run macOS, where these paths are passed to sandbox-exec (#4963), and I didn't run the hermetic sandbox. processwrapper-sandbox ignores the flag altogether: under it the file was readable with the flag set.

For linux-sandbox, one sentence in the help would cover both: for each action, the path is blocked only if it exists when that action's sandbox is set up, and only until something replaces it while the action runs.

Lingua principale
Java
Stelle
26.2k
Fork
4.7k
Merge medio
3g 11h
PR unite (30g)
125

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di bazelbuild/bazel

Tutte le issue di bazelbuild/bazel

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.