Skip to content

environment cleanup --recover can never pass on desktop Linux: setuid and non-dumpable session processes count as "uninspectable same-user processes" #7435

Description

@pablooliva

Summary

bb environment cleanup <id> --recover refuses on an ordinary desktop Linux machine because the same-user process guard counts every process it cannot read as a blocker. Such processes are part of every normal login session, so recovery can never pass there, even when nothing is using the workspace.

Error: HTTP 409: Recovery refused: cannot inspect same-user processes (12520, 1535223, 1843, 484728)

Environment

  • bb 0.48.1 (protocol 258). The server runs on macOS; the environment is on a remote machine enrolled with the manual provider.
  • Remote machine: Linux Mint 21.3, kernel 6.8.0-138-generic, daemon running as uid 1000.

The processes it couldn't inspect

None of them has anything to do with the workspace:

PID Process Why /proc/<pid>/cwd can't be read
12520 fusermount3 … /run/user/1000/doc (document portal) setuid-root binary: real uid is 1000, effective uid is root
1535223 sshd: user@pts/0 sshd per-session process (privilege-separated, not dumpable)
1843 (sd-pam) part of [email protected] and lives for the whole user session
484728 /usr/bin/ssh-agent -D -a /run/user/1000/keyring/.ssh ssh-agent marks itself not dumpable

readlink /proc/<pid>/cwd returns EACCES for each of these, even for the same user. (sd-pam) runs for as long as the user is logged in (or for good, with lingering), so closing shells doesn't help.

Cause (from the bundled daemon code)

environment.inspect_cleanup walks /proc:

  • A process counts as "same-user" when any of its real, effective, saved, or filesystem uids matches the daemon's uid. That includes setuid helpers such as fusermount3.
  • For each one it reads cwd and maps. Any read error other than ENOENT/ESRCH puts the PID in unreadablePids.
  • The server then refuses recovery whenever unreadablePids.length > 0.

On a normal desktop or SSH login that list is never empty, so --recover cannot succeed.

Steps to reproduce

  1. On a Linux machine with a normal login session (systemd user session, ssh-agent, or an SSH login), get a git-worktree environment into "Needs recovery". In my case a container had written root-owned files into the worktree, so teardown hit EACCES on unlink.
  2. Remove the cause (I deleted the root-owned files; the worktree now holds only empty directories owned by the user).
  3. Run bb environment cleanup <id> --recover.

Expected: recovery goes ahead, because no process has its cwd or a mapped file in the workspace.
Actual: HTTP 409, cannot inspect same-user processes (...). The environment stays in "Needs recovery" with no other way to clear it.

Possible fixes

  • Only check a process whose real uid matches the daemon's, so setuid helpers are skipped.
  • Treat processes that aren't dumpable (EACCES on cwd/maps) as not using the workspace, or report them without blocking.
  • Or add an explicit override after inspection (for example --recover --ignore-unreadable), since the user has already inspected the workspace.

Two smaller things seen on the same environment

  • bb environment show reports Teardown: failed (attempt 46759), though the docs say teardown stops after five failed attempts.
  • The teardown message nests each time it fails: Needs recovery: Needs recovery: Needs recovery: EACCES … Inspect the workspace, then run … --recover. Inspect the workspace, then run … --recover. …

Activity

  1. added theissue type on Nov 11, 2026
  2. added
    workspaces
    host
    confirmed-repro
    on Nov 11, 2026
  3. bb-slop-cop commented on Nov 11, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Medium · Effort: High. Added workspaces, host, and confirmed-repro; no existing classifications were replaced.
    • Report: https://get-bb.github.io/reports/issues/7435.html
    • Verdict: REPRODUCED · Confidence: high. A real non-dumpable same-user process outside the workspace blocks inspection in two clean checkouts of trusted main; the existing server recovery tests confirm HTTP 409 for unreadable PIDs.
    • Root cause: the global procfs scan includes unrelated unreadable processes, and any unreadable PID blocks recovery. Real-UID-only filtering is insufficient: the reproduction retains matching UIDs throughout.
    • No pull request: relaxing this fail-closed deletion-safety guard requires a reviewed safety/product decision. A hidden process actually inside the workspace produces the same result. Retry-count and message-nesting symptoms remain unverified.
  4. lanjak commented on Nov 19, 2026

    @lanjak
    Contributor

    Hi, thanks for the detailed report. I reproduced this on a Fedora machine with one SSH session, at main e6f3032d18. With nothing in the workspace, recovery is refused for 6 processes: systemd --user, (sd-pam), sshd-session, gpg-agent and two container processes. All of them run with effective UID 1000, so matching only the real or effective UID would not be enough, as the triage noted.

    What /proc does expose for them is their mount table: mountinfo is readable even when cwd is not. #7854 uses that:

    • An unreadable process under another effective UID (your fusermount3) counts as another user's process, as on macOS since Support environment cleanup recovery on macOS #7520.
    • An unreadable process in the daemon's own mount namespace (systemd, sd-pam, sshd, ssh-agent, gpg-agent) no longer blocks recovery. The cost is that a non-dumpable program running inside the workspace is not detected; the shell that started it still is.
    • A process in another mount namespace, such as a container, is checked through its own mount table. It blocks when its cwd or a mapped file resolves into the workspace, or, if it can't be read, when one of its mounts exposes the workspace or a parent. This also catches something main missed: a rootless podman container with -v <workspace>:/app -w /app reports its cwd as /app, which main compared with the host path and so did not find.

    On the two smaller points:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-reprohostworkspaces

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions