Skip to content

Privileged mode fuse-only supports buildkit-based container building - #9612

Merged
taylorsilva merged 1 commit into
concourse:masterfrom
Kump3r:oci-build-fuse-only
Jun 22, 2026
Merged

taylorsilva merged 1 commit into
concourse:masterfrom
Kump3r:oci-build-fuse-only

Conversation

@Kump3r

@Kump3r Kump3r commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Problem

The fuse-only privileged mode introduced in #9017 does not work with
oci-build-task or any BuildKit-based image build. Any Dockerfile
containing a RUN step fails with:

runc run failed: unable to start container process: error spawning
mount remapping thread: mount source thread: join container mntns:
setns: operation not permitted

This is because BuildKit's runc needs to join the container's mount
namespace for each RUN step, which requires setns — a syscall not
present in the fuse-only allowlist.

Changes

Added three syscalls to fuse_syscalls in worker/runtime/spec/seccomp.go:

  • setns — scoped to mount namespaces only via OpEqualTo CLONE_NEWNS
    (arg index 1). This allows runc to join mount namespaces for build steps
    without permitting user namespace joins, which would be the dangerous
    escalation path.
  • keyctl — needed by runc container init to create and configure a
    session keyring. Kernel keyrings are session-scoped and cannot affect
    the host or other container sessions.
  • sethostname — needed by runc container init. Operates within the
    container's own UTS namespace.

Security verification

Tested inside a fuse-only privileged container after the change:

  • unshare --user succeeds but produces CapEff: 0000000000000000 —
    no capabilities gained
  • unshare --user sh -c "mount -t proc proc /tmp/x" — blocked, mount
    inside a user namespace is not permitted
  • mount -t proc proc /tmp/escape — blocked
  • echo h > /proc/sysrq-trigger — blocked
  • Host keyrings not visible (/proc/keys empty)
  • setns to user namespace blocked by argument filter

The known container escape vectors remain closed. unshare --user is
permitted by the existing fuse_syscalls list but is harmless — the
resulting user namespace has zero capabilities and cannot mount.

Testing

Verified end-to-end oci-build-task build with a Dockerfile containing
RUN, COPY, ARG, WORKDIR, USER, ENTRYPOINT and LABEL steps
succeeds under fuse-only mode. Only RUN steps were affected by the
missing syscalls — all other Dockerfile instructions work without changes
as they do not spawn container processes via runc.

Pipeline used for the tests Before/After docker compose rebuild:

---
resources:
- name: my-image
  type: registry-image
  source:
    repository: ((dockerhub_username))/test-image # create the Repo on DockerHub before running the pipeline
    tag: poc-oci-build
    username: ((dockerhub_username))
    password: ((dockerhub_password))

jobs:
- name: build-and-push
  plan:
  - task: create-dockerfile
    config:
      platform: linux
      image_resource:
        type: registry-image
        source:
          repository: busybox
      outputs:
      - name: build-context
      run:
        path: sh
        args:
        - -c
        - |
          cat > build-context/Dockerfile <<'EOF'
          FROM alpine
          ARG BUILD_VERSION=1.0.0
          LABEL test=poc-oci-build-task version=${BUILD_VERSION}
          WORKDIR /app
          COPY Dockerfile /app/Dockerfile
          RUN echo "Hello, World!" && echo "Build version: ${BUILD_VERSION}"
          USER nobody
          ENTRYPOINT ["echo", "container started"]
          EOF
          cp build-context/Dockerfile build-context/Dockerfile.bak

  - task: build
    privileged: true 
    config:
      platform: linux
      image_resource:
        type: registry-image
        source:
          repository: concourse/oci-build-task
      inputs:
      - name: build-context
        path: .
      outputs:
      - name: image
      run:
        path: build

  - put: my-image
    params:
      image: image/image.tar

Note: #9017 was only tested with buildah/podman. This change extends
compatibility to BuildKit-based workflows.

@Kump3r
Kump3r requested a review from a team June 22, 2026 10:18
@Kump3r Kump3r added the bug label Jun 22, 2026
@taylorsilva taylorsilva changed the title fix: fuse-mode should be able to build Dockerfiles with RUN Privileged mode fuse-only supports buildkit-based container building Jun 22, 2026
@taylorsilva

Copy link
Copy Markdown
Member

Re-labelled as an enhancement since the original PR never had it as a goal to support buildkit. This was a known gap with the fuse-only privileged mode.

@taylorsilva taylorsilva left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM. I locally tested by adding CONCOURSE_CONTAINERD_PRIVILEGED_MODE: fuse-only to my worker. I tested the given example pipeline and a few other more complex Dockerfiles from our CI. They all built without issue.

@taylorsilva
taylorsilva merged commit 4874cf0 into concourse:master Jun 22, 2026
11 checks passed
@Kump3r

Kump3r commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the quick review! Sorry I was wondering between bug and enhancement, but since most dockerfiles require run, I decided on bug.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants