Skip to content

apparmor: Set abi conditionally#13268

Merged
samuelkarp merged 1 commit into
containerd:mainfrom
cpuguy83:fix_apparmor_old
Apr 23, 2026
Merged

apparmor: Set abi conditionally#13268
samuelkarp merged 1 commit into
containerd:mainfrom
cpuguy83:fix_apparmor_old

Conversation

@cpuguy83

Copy link
Copy Markdown
Member

The "abi" keyword was added for apparmor 3.0
The original change to add this ended up breaking versions < 3.0. The abi itself is a macro in /etc/apparmor.d so we can check if the macro exists to determine if we can set an abi in the template.

The "abi" keyword was added for apparmor 3.0
The original change to add this ended up breaking versions < 3.0.
The abi itself is a macro in /etc/apparmor.d so we can check if the
macro exists to determine if we *can* set an abi in the template.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the AppArmor default profile generator to only emit the abi <...>, directive when the corresponding ABI macro exists on the host, avoiding breakage on AppArmor versions older than 3.0.

Changes:

  • Make the template’s abi <...>, line conditional on a new Abi template field.
  • Detect support by checking for /etc/apparmor.d/abi/3.0 and set Abi accordingly during template data construction.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread contrib/apparmor/template.go

@thaJeztah thaJeztah 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.

LGTM

@github-project-automation github-project-automation Bot moved this from Needs Triage to Review In Progress in Pull Request Review Apr 23, 2026
@thaJeztah

Copy link
Copy Markdown
Member

@cpuguy83 if you have time; could you also open a PR in https://github.com/moby/profiles ?

@samuelkarp samuelkarp added this pull request to the merge queue Apr 23, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 23, 2026
@samuelkarp samuelkarp added this pull request to the merge queue Apr 23, 2026
Merged via the queue into containerd:main with commit b3e484a Apr 23, 2026
96 of 100 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Apr 23, 2026
@cpuguy83

Copy link
Copy Markdown
Member Author

/cherry-pick release/1.7
/cherry-pick release/2.0
/cherry-pick release/2.1
/cherry-pick release/2.2

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@cpuguy83: new pull request created: #13273

Details

In response to this:

/cherry-pick release/1.7
/cherry-pick release/2.0
/cherry-pick release/2.1
/cherry-pick release/2.2

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@cpuguy83: #13268 failed to apply on top of branch "release/2.0":

Applying: apparmor: Set abi conditionally
Using index info to reconstruct a base tree...
M	contrib/apparmor/template.go
Falling back to patching base and 3-way merge...
Auto-merging contrib/apparmor/template.go
CONFLICT (content): Merge conflict in contrib/apparmor/template.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 apparmor: Set abi conditionally

Details

In response to this:

/cherry-pick release/1.7
/cherry-pick release/2.0
/cherry-pick release/2.1
/cherry-pick release/2.2

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@cpuguy83

Copy link
Copy Markdown
Member Author

/cherry-pick release/2.0 release/2.1 release/2.2

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@cpuguy83: new pull request created: #13274

Details

In response to this:

/cherry-pick release/1.7
/cherry-pick release/2.0
/cherry-pick release/2.1
/cherry-pick release/2.2

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@cpuguy83: #13268 failed to apply on top of branch "release/2.0":

Applying: apparmor: Set abi conditionally
Using index info to reconstruct a base tree...
M	contrib/apparmor/template.go
Falling back to patching base and 3-way merge...
Auto-merging contrib/apparmor/template.go
CONFLICT (content): Merge conflict in contrib/apparmor/template.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 apparmor: Set abi conditionally

Details

In response to this:

/cherry-pick release/2.0 release/2.1 release/2.2

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown

@cpuguy83: new pull request created: #13275

Details

In response to this:

/cherry-pick release/1.7
/cherry-pick release/2.0
/cherry-pick release/2.1
/cherry-pick release/2.2

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@samuelkarp

Copy link
Copy Markdown
Member

@cpuguy83 I think we're missing a cherrypick to 2.0 (seems to have failed the auto-creation). Do you plan to do that manually?

@samuelkarp samuelkarp added cherry-pick/1.7.x Change to be cherry picked to release/1.7 branch cherry-pick/2.0.x Change to be cherry picked to release/2.0 branch cherry-pick/2.1.x Change to be cherry picked to release/2.1 branch cherry-pick/2.2.x Change to be cherry picked to release/2.2 branch cherry-picked/2.2.x PR commits are cherry-picked into release/2.2 branch cherry-picked/2.1.x PR commits are cherry picked into the release/2.1 branch and removed cherry-pick/2.2.x Change to be cherry picked to release/2.2 branch cherry-pick/2.1.x Change to be cherry picked to release/2.1 branch labels Apr 23, 2026
@cpuguy83

Copy link
Copy Markdown
Member Author

Ah, 2.0 didn't have the original change.
I brought it in anyway: #13277

@cpuguy83 cpuguy83 deleted the fix_apparmor_old branch April 23, 2026 18:29
@thaJeztah

Copy link
Copy Markdown
Member

Found another bug by accident; if the current profile is not enforcing (so doesn't have (enforce) as suffix, we didn't strip the trailing newline, producing an invalid profile 😅

ricolin added a commit to ricolin/ansible-collection-containers that referenced this pull request Apr 28, 2026
containerd 1.7.31 unconditionally emits `abi <abi/3.0>,` as line 2 of its
default AppArmor profile template (see contrib/apparmor/template.go in
v1.7.31). Ubuntu 20.04 (focal) ships AppArmor 2.13.x which does not
understand the `abi <...>,` directive, so every container creation on
focal fails:

    AppArmor parser error for /tmp/cri-containerd.apparmor.dXXX at line 2:
    Could not open 'abi/3.0': No such file or directory

The regression has already been fixed upstream and backported to the
release/1.7 branch:

  - containerd/containerd#13268
  - containerd/containerd#13273

so 1.7.32 will work fine on focal again. Rather than hard-pinning focal
to 1.7.30 (which would also have to be bumped manually for every future
1.7.x release), this introduces a `containerd_focal_excluded_versions`
list and selects the latest 1.7.x that is **not** in it. Today that
yields 1.7.30; once 1.7.32 ships it will be picked up automatically and
this workaround can be dropped.

Note: v1.6.6 has already been released with the broken default, so we
intentionally do not rewrite history or roll back any deployments --
existing focal hosts that ended up on 1.7.31 will heal on their next
run once 1.7.32 lands (or by manually overriding
`containerd_focal_excluded_versions`).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ricolin added a commit to ricolin/ansible-collection-containers that referenced this pull request Apr 28, 2026
containerd 1.7.31 unconditionally emits `abi <abi/3.0>,` as line 2 of its
default AppArmor profile template (see contrib/apparmor/template.go in
v1.7.31). Ubuntu 20.04 (focal) ships AppArmor 2.13.x which does not
understand the `abi <...>,` directive, so every container creation on
focal fails:

    AppArmor parser error for /tmp/cri-containerd.apparmor.dXXX at line 2:
    Could not open 'abi/3.0': No such file or directory

The regression has already been fixed upstream and backported to the
release/1.7 branch:

  - containerd/containerd#13268
  - containerd/containerd#13273

so 1.7.32 will work fine on focal again. Rather than hard-pinning focal
to 1.7.30 (which would also have to be bumped manually for every future
1.7.x release), this introduces a `containerd_focal_excluded_versions`
list and selects the latest 1.7.x that is **not** in it. Today that
yields 1.7.30; once 1.7.32 ships it will be picked up automatically and
this workaround can be dropped.

Note: v1.6.6 has already been released with the broken default, so we
intentionally do not rewrite history or roll back any deployments --
existing focal hosts that ended up on 1.7.31 will heal on their next
run once 1.7.32 lands (or by manually overriding
`containerd_focal_excluded_versions`).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: ricolin <rlin@vexxhost.com>
ricolin added a commit to ricolin/ansible-collection-containers that referenced this pull request Apr 28, 2026
containerd 1.7.31 unconditionally emits `abi <abi/3.0>,` as line 2 of its
default AppArmor profile template (see contrib/apparmor/template.go in
v1.7.31). Ubuntu 20.04 (focal) ships AppArmor 2.13.x which does not
understand the `abi <...>,` directive, so every container creation on
focal fails:

    AppArmor parser error for /tmp/cri-containerd.apparmor.dXXX at line 2:
    Could not open 'abi/3.0': No such file or directory

The regression has already been fixed upstream and backported to the
release/1.7 branch:

  - containerd/containerd#13268
  - containerd/containerd#13273

so 1.7.32 will work fine on focal again. Rather than hard-pinning focal
to 1.7.30 (which would also have to be bumped manually for every future
1.7.x release), this introduces a `containerd_focal_excluded_versions`
list and selects the latest 1.7.x that is **not** in it. Today that
yields 1.7.30; once 1.7.32 ships it will be picked up automatically and
this workaround can be dropped.

Note: v1.6.6 has already been released with the broken default, so we
intentionally do not rewrite history or roll back any deployments --
existing focal hosts that ended up on 1.7.31 will heal on their next
run once 1.7.32 lands (or by manually overriding
`containerd_focal_excluded_versions`).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: ricolin <rlin@vexxhost.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick/1.7.x Change to be cherry picked to release/1.7 branch cherry-pick/2.0.x Change to be cherry picked to release/2.0 branch cherry-picked/2.1.x PR commits are cherry picked into the release/2.1 branch cherry-picked/2.2.x PR commits are cherry-picked into release/2.2 branch kind/bug size/S

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants