#4312 [TUI] launcher: start the bundled runtime when access(X_OK) is denied (Docker's default seccomp profile)

closed · @XiaoBinGan · 0 评论 · 去 GitHub 看

Setup & installAMD / HIPNVIDIA / CUDASecurityDocumentationWindows

说明

## Problem and result

In the official image on a host whose Docker daemon uses an older default seccomp profile
(19.03.15 here), a container start stops with **"The engine in this image does not match this
computer's graphics card, or the card is not visible to the container"**, and the launcher's text
under it says "no usable Python found". The card is fine and the runtime is there: the same image and
the same command work with `--security-opt seccomp=unconfined`. After this change both places that
decide "is this Python usable?" start the candidate when the permission test says no, so the container
needs no seccomp override to start.

## Related discussion

#4309 — the report with the four-way A/B evidence, and the container-start log.

Cause

`test -x` is not a reliable yes/no here. That daemon's seccomp profile denies `access(X_OK)` /
`faccessat` for `X_OK`, so the test answers false for a file the shell can still execute: in the same
container `[ -e .../python3 ]` is true, `readlink -f` resolves it, and running it prints
`Python 3.12.15`. Two places depend on that test:

- `bin/strata` (`pick_python`) skipped the bundled runtime, found no `python3` on PATH for the same
  reason, and printed "no usable Python found".
- `docker/entrypoint.sh` (`PYBIN=...`) is the one a container start hits first: it set `PYBIN=python3`,
  which is not installed in the image, and the start reported the card mismatch above.

The second one is why this is a user-facing misdiagnosis rather than a bad message: the troubleshooting
section of `docs/DOCKER.md` begins with exactly that card sentence.

## Approach

One helper per file, same shape, keeping the fast path:

```sh
python_usable() {           # entrypoint.sh; is_runnable() in bin/strata
  [ -x "$1" ] && return 0
  [ -f "$1" ] || return 1
  "$1" -c 'pass' 2>/dev/null
}
```

Where `test -x` works — every normal system, and this host with `seccomp=unconfined` — the first line
answers, so the chosen interpreter and the startup cost are unchanged. The refusal for an explicitly
useless `STRATA_PYTHON` keeps its message.

## Validation

**Passed:** the launcher, in the environment where the bug was measured (Docker 19.03.15, default seccomp,
image `ghcr.nju.edu.cn/niko1221/strata:0.2.2-cuda13`, engine 0.1.47; the file under test copied over
`/opt/strata/terminal/bin/strata`):

| Run | Launcher | Daemon seccomp | Result |
| --- | --- | --- | --- |
| A | shipped | default | `strata: no usable Python found.` (the bug) |
| B | this patch | default | `strata 0.2.2 (build 0.1.47; python 3.12.15 at /opt/strata/terminal/python/bin/python3)` |
| C | this patch | `unconfined` | same version line; the bundled interpreter is chosen |
| D | this patch, `STRATA_PYTHON=/nope/python3` | `unconfined` | `strata: STRATA_PYTHON=/nope/python3 is not executable` (unchanged) |

**Passed:** the entrypoint's `PYBIN` resolution, both conditions, replayed in the same image:

| Run | Lines | Daemon seccomp | Result |
| --- | --- | --- | --- |
| A | shipped | default | `PYBIN=python3`, then `python3: not found` |
| B | this patch | default | `PYBIN=/opt/strata/terminal/python/bin/python3`, `Python 3.12.15` |
| C | this patch | `unconfined` | same `PYBIN`, `Python 3.12.15` |

**Passed:** `sh -n docker/entrypoint.sh` and `sh -n bin/strata`.

**Passed:** the diagnostic that separates the two hypotheses, in the same container: `test -x` false,
`test -e` true, `readlink -f` resolves, direct `exec` prints `Python 3.12.15`, `command -v python3` not
found.

**Failed:** none.

**Not run:** a full container **start** with the patched entrypoint (model download and load). The image
downloads tens of GB on first start, so the entrypoint change was validated at the `PYBIN` resolution
and syntax level only, plus the launcher A/B above which exercises the same helper. If you want that
proven end to end, it needs a host whose daemon denies `access(X_OK)` and a prepared data volume; say
so and I will run it here rather than claim it.

**Not run:** no unit test. The condition is a container runtime's seccomp decision on `access(X_OK)`,
which a unit test cannot produce without a seccomp filter of its own, and I did not want to add a test
that only restates the helper. The honest shape is a container-level check like
`docker/smoke-test.sh` behind an opt-in; I can add that instead if you prefer.

**Not run:** macOS and Windows launchers (`bin/strata.ps1`, `bin/strata.cmd`): the change is in the POSIX
launcher and the container entrypoint only. They keep `Test-Path`/`where`, which no container profile
changes.

## Limits

- The fallback starts the candidate once when `test -x` says no. Where the test works the extra start
  never happens, so the normal startup path is unchanged.
- A file that exists, is not executable and cannot be started still ends in the same "no usable Python
  found" message; only the decision in between changed.
- The daemon in this report is old (19.03.15). Newer daemons ship a profile that allows the call, so
  most readers never see this; the fix costs them nothing.

Measured on: Ubuntu 20.04.3 LTS host, kernel 5.15.0-58, glibc 2.31, two-socket Xeon Gold 5218,
125.6 GiB RAM, RTX 5090 32 GB with driver 580.142, Docker 19.03.15 (AppArmor + default seccomp).

本站相关内容

相关页面的快捷入口。