Skip to content

internal/server/util: Recognize named unconfined AppArmor profiles - #3977

Merged
stgraber merged 1 commit into
lxc:mainfrom
fivetime:upstream/apparmor-unconfined-20260911
Sep 14, 2026
Merged

stgraber merged 1 commit into
lxc:mainfrom
fivetime:upstream/apparmor-unconfined-20260911

Conversation

@fivetime

@fivetime fivetime commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

/proc/self/attr/current can contain a named profile in unconfined mode, such as runc (unconfined). Comparing that string with just unconfined makes Incus incorrectly treat its daemon as already confined and disable its own AppArmor profile handling.

Normalize labels ending in (unconfined) inside the existing AppArmorProfile function. Keep enforced, complain and mixed labels unchanged.

Runtime validation on Linux 7.0.0-28 with AppArmor parser 4.0.1 and runc 1.3.4 covered named unconfined and enforced profiles. Kernel stacking with aa-exec reports (unconfined) for two unconfined profiles and (mixed) when one profile is enforced; the latter remains confined after this change.

Validation: go test -v ./... and make static-analysis. The separate helper and added unit test were removed following review.

@fivetime
fivetime requested a review from stgraber as a code owner September 11, 2026 09:15
Comment thread internal/server/util/apparmor_test.go Outdated
"github.com/stretchr/testify/require"
)

func TestAppArmorProfileName(t *testing.T) {

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.

drop the test

Comment thread internal/server/util/apparmor.go Outdated
return ""
}

func appArmorProfileName(profile string) string {

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.

move into the existing function

@stgraber
stgraber self-requested a review September 11, 2026 16:03

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

see inline comments

Signed-off-by: Simon Zhou <jp.zdm2008@gmail.com>
@fivetime
fivetime force-pushed the upstream/apparmor-unconfined-20260911 branch from a51ac34 to de73cd6 Compare September 14, 2026 01:53
@fivetime

Copy link
Copy Markdown
Contributor Author

Moved the label handling into the existing AppArmorProfile function and dropped the added test. The full unit suite and static analysis pass.

@fivetime

Copy link
Copy Markdown
Contributor Author

The System (stable, cluster, dir, ubuntu-24.04) job failed at test/suites/clustering.sh:542: incus launch testimage bar succeeds after node2 is stopped, but the expected Location: node1 assertion fails. This is the same assertion failure seen in the independent Ceph-only PR #3976 (tip/cluster/dir); it appears unrelated to this AppArmor parsing change, though the root cause is not yet established.

Could you rerun the failed job when convenient? The rerun API requires upstream repository admin rights, which my account does not have.

Failed job: https://github.com/lxc/incus/actions/runs/34797365780/job/103832961518

@stgraber
stgraber merged commit 4f17132 into lxc:main Sep 14, 2026
91 of 92 checks passed
@fivetime
fivetime deleted the upstream/apparmor-unconfined-20260911 branch September 17, 2026 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants