89luca89 / 89luca89/distrobox

[Upstream regression / visibility] crun >= 1.29 can break host PTYs when starting a rootful Distrobox

未關閉
#2,203 1 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
bug
主要語言
Go
星號
13k
分支
541
平均合併
20 小時 47 分鐘
30 天內合併 PR
4

描述

Please, before opening a bug:

- [x] I have read the documentation.
- [x] I searched existing open issues.
- [x] I searched existing closed/resolved issues.

**Describe the bug**

This report is a cross-reference for visibility only. The underlying regression
is being tracked by crun:

https://github.com/containers/crun/issues/2197

Starting a rootful Distrobox container through Podman with crun 1.29 or newer
can result in the container's anonymous `/dev/pts` volume appearing over the
host's real `/dev/pts` mount.

Once this happens, `/dev/pts/ptmx` is no longer visible on the host and new
pseudoterminals cannot be allocated. This affects `sudo`, terminal emulators
and other applications that require PTYs.

The upstream report confirms:

- crun 1.28 works.
- crun 1.29 is affected.
- crun 1.29.1 is affected.
- current crun main is affected.

I reproduced this with Distrobox v1.8.2.5. I have not runtime-tested Distrobox
v2 because reproducing the issue disrupts PTY allocation across the host and
requires recovery.

**To Reproduce**

Warning: It can prevent new terminals and `sudo` sessions from working on the host.

1. Use Podman with crun 1.29 or 1.29.1.

2. Create a rootful, initful Distrobox:

```bash
distrobox create \
--root \
--name crun-devpts-repro \
--image docker.io/library/debian:stable \
--init
```

3. Confirm the host initially has a normal devpts mount:

```bash
findmnt -rn -o TARGET,SOURCE,FSTYPE /dev/pts
```

Expected initial output:

```text
/dev/pts devpts devpts
```

4. Start or enter the rootful container:

```bash
distrobox enter --root crun-devpts-repro
```

Starting it directly through Podman can produce the same result:

```bash
sudo podman start crun-devpts-repro
```

5. Inspect the host:

```bash
findmnt -rn -o TARGET,SOURCE,FSTYPE /dev/pts
stat -f -c '%T' /dev/pts
ls -l /dev/pts/ptmx
python3 -c 'import os,pty; a,b=pty.openpty(); print(os.ttyname(b))'
```

6. The anonymous Podman volume appears over the host `/dev/pts`. The
filesystem reports `btrfs` rather than `devpts`, `/dev/pts/ptmx` is
missing, and `openpty()` fails.

**Expected behavior**

The container's `/dev/pts` mount should remain isolated from the host mount
namespace.

**Logs**

Distrobox/entry failure:

```text
sudo: unable to allocate pty: No such device
Error: could not start entrypoint.
sudo: unable to allocate pty: No such device
```

Host mount state after starting the container:

```text
/dev/pts devpts devpts
/dev/pts /dev/sdd1[/@containers/storage/volumes//_data] btrfs
```

Host PTY checks:

```text
$ stat -f -c '%T' /dev/pts
btrfs

$ ls -l /dev/pts/ptmx
ls: cannot access '/dev/pts/ptmx': No such file or directory

$ python3 -c 'import os,pty; a,b=pty.openpty(); print(os.ttyname(b))'
OSError: out of pty devices
```

The kernel was not actually out of PTYs:

```text
$ paste -d/ /proc/sys/kernel/pty/nr /proc/sys/kernel/pty/max
4/4096
```

**Desktop (please complete the following information):**

- Container manager: Podman
- Podman version: 6.1.0-1
- OCI runtime: crun 1.29.1-1
- Distrobox version tested: 1.8.2.5-1
- Distrobox v2: source inspected, not runtime-tested
- Host distribution: Arch Linux
- Kernel: 6.18.44-1-lts
- Installation method: Arch Linux packages via pacman
- Container type: rootful and initful

**Additional context**

The affected container was created before the crun 1.29 update and did not
previously cause this host-wide failure.

The upstream crun report contains version comparisons and tracks the underlying
regression:

https://github.com/containers/crun/issues/2197

This Distrobox issue is intended only as a visibility and cross-reference item.
No Distrobox-side change or workaround is being requested.

This report was created by AI and cross checked by me, apologize if there is any issue with the wording, thanks!

貢獻指南

開啟貢獻指南

研究方向

這是一個可見性問題,用於追蹤 crun >=1.29 中的一個 upstream 回歸;該回歸會在啟動 rootful Distrobox 容器時破壞主機 PTY。該問題已在 containers/crun#2197 中向 upstream 回報。不要求對 Distrobox 端進行變更;這項工作涉及理解容器執行階段內部機制、mount namespaces 以及 PTY 配置。首先,閱讀連結的 crun issue,並檢查 Distrobox 在 rootful 容器中如何與 Podman 和 crun 互動。檢查 Distrobox 的 Go 和 shell 程式碼中的容器 entrypoint 以及 mount 處理。測試具有風險,因為它可能會破壞主機的 PTY 功能。

由索引模型根據 Issue 內容生成。

評估

領域
cli, tooling
Issue 類型
缺陷
難度
5/5
預估耗時
一週以上
活躍度
活躍
描述清晰度
描述清楚
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。