Skip to content

heavy facts: machine tier misses the caller's own cgroup cap; cache folder squat and TMPDIR nits #951

Open

Description

@scuttletoby

Follow-up from the #945 reviews. These are small points in the heavy kit's heavy facts. None of them blocks #945. Each one is listed so it is not lost.

  1. The machine tier does not see the caller's own memory cap. With no systemd user manager (heavy capacity: callers without a systemd user manager always get NOT OK (CI runner users) #844), heavy facts answers from machine-wide numbers only. It does not read the cgroup that the caller itself runs in. A caller inside a container or a capped slice (for example a CI runner with MemoryMax=) can be told OK for a size that fits the machine but not its own cap. It also sends pieceCaps: true, although the caller's own work does not run in a heavy scope. The full tier has the same blind spot for user-<uid>.slice. Fix idea: read memory.max and memory.current of the caller's own cgroup (/proc/self/cgroup) and take the smaller room.

  2. Someone else can take the /tmp/heavy-facts-<uid> name first. When there is no /run/user/<uid>, the cache goes in heavy-facts-<uid> under the temp folder. Another user can make that folder (or a file with that name) before this user does. heavy then refuses it and runs without a cache, so every call starts "elevated". That is safe, but it is a denial of the cache that anyone can cause. Fix idea: on refusal, try a name with a random part, or a folder under the user's home.

  3. The cache folder is checked, then used by path. In a temp folder that is not sticky and that others can write (a $TMPDIR set that way), the cache folder is checked and then opened by its path. A swap between the two steps could point heavy at another folder. Fix idea: open the folder once with O_DIRECTORY | O_NOFOLLOW and do every later step with dir_fd.

  4. A resolved home inside a non-sticky folder that others can write. HOME is resolved with realpath before it is checked (heavy: minors from the #770 reviews (~/.local mode, README repair line, linked ~/.local) #771). If the resolved home sits inside a folder that others can write and that is not sticky, a parent can still be swapped after the check. Fix idea: walk the path with O_NOFOLLOW folder handles, or refuse a home whose parents others can write.

🤖 Generated with Claude Code

Activity

  1. scuttletoby commented on Nov 22, 2026

    @scuttletoby
    OwnerAuthor

    Two more leftovers from the #945 round-2 reviews. Neither blocks #945; the README's Tiers paragraph now names both limits.

    1. NSS users with no session are not read. In the machine tier, heavy facts reads other people's reserve.d for the users in /etc/passwd (UID in UID_MIN..UID_MAX) and for anyone with a user.slice session. A person whose account comes only from NSS (LDAP, sssd) and who has no session or linger right now is not read, so a reservation of theirs is not seen. This is the one fail-open gap left in the machine tier, and it is narrow. Fix idea: also read pwd.getpwall() (bounded, and only when NSS is configured), or keep it documented.

    2. Every machine-tier call lists every passwd home. Each fresh read (every 5 s at most, through the cache) looks at each person's ~/.config/t3-capacity/reserve.d. On a host with autofs homes, that mounts every home each time. Fix idea: skip homes under an autofs mount point unless that user has a session, or read a machine-wide reservations folder instead (the heavy capacity: callers without a systemd user manager always get NOT OK (CI runner users) #844 follow-up).

    🤖 Generated with Claude Code

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions