Skip to content

interfaces/builtin: add lsm self-attr syscall allowances#16665

Open
zyga wants to merge 1 commit intocanonical:masterfrom
zyga:feature/lsm-syscalls-AA-1000
Open

interfaces/builtin: add lsm self-attr syscall allowances#16665
zyga wants to merge 1 commit intocanonical:masterfrom
zyga:feature/lsm-syscalls-AA-1000

Conversation

@zyga
Copy link
Contributor

@zyga zyga commented Feb 25, 2026

Add lsm_get_self_attr to interfaces that read AppArmor current labels and add lsm_set_self_attr where AppArmor allows writing process attr/exec.

Include seccomp coverage updates in tests for system-observe, cups-control, docker-support, and kubernetes-support flavors.

No syscall addition for browser-support: it explicitly denies access to /proc/.../attr/{,apparmor/}current.
No explicit syscall addition for lxd-support: its seccomp policy is @unrestricted.

Jira: https://warthogs.atlassian.net/browse/AA-1000

Thanks for helping us make a better snapd!
Have you signed the license agreement and read the contribution guide?

Copilot AI review requested due to automatic review settings February 25, 2026 09:09
@zyga zyga added the Needs security review Can only be merged once security gave a :+1: label Feb 25, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds syscall allowances for the new LSM (Linux Security Module) self-attribute APIs to several snapd interfaces. These syscalls (lsm_get_self_attr and lsm_set_self_attr) are the modern kernel APIs for reading and writing process LSM attributes, replacing direct /proc file access. The changes ensure interfaces that read or write AppArmor labels via /proc/.../attr/ files also have the corresponding syscall permissions.

Changes:

  • Add lsm_get_self_attr to interfaces that read AppArmor current labels (system-observe, cups-control, kubernetes-support kubelet/default flavors)
  • Add lsm_set_self_attr to docker-support which writes to attr/exec
  • Update all relevant test files to verify the new syscall permissions are present

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
interfaces/builtin/system_observe.go Adds lsm_get_self_attr syscall for reading AppArmor current labels
interfaces/builtin/system_observe_test.go Adds test assertion verifying lsm_get_self_attr is present in seccomp profile
interfaces/builtin/kubernetes_support.go Adds lsm_get_self_attr to kubelet seccomp snippet for reading process attributes
interfaces/builtin/kubernetes_support_test.go Adds test assertions for kubelet/default flavors having the syscall, and kubeproxy/autobind-unix not having it
interfaces/builtin/docker_support.go Adds lsm_set_self_attr syscall for writing to attr/exec
interfaces/builtin/docker_support_test.go Adds test assertion verifying lsm_set_self_attr is present in seccomp profile
interfaces/builtin/cups_control.go Adds seccomp import and SecCompPermanentSlot method with lsm_get_self_attr syscall
interfaces/builtin/cups_control_test.go Adds seccomp import and two test functions verifying syscall presence on core and classic

@zyga zyga requested review from bboozzoo and jslarraz February 25, 2026 09:38
@github-actions
Copy link

github-actions bot commented Feb 25, 2026

Fri Feb 27 11:36:05 UTC 2026
The following results are from: https://github.com/canonical/snapd/actions/runs/22435330358

Failures:

Preparing:

  • openstack:opensuse-15.6-64:
  • openstack:opensuse-15.6-64:

Executing:

  • openstack:opensuse-tumbleweed-64:tests/main/snap-quota
  • openstack:opensuse-tumbleweed-64:tests/main/snap-quota-memory
  • openstack:opensuse-tumbleweed-selinux-64:tests/main/snap-quota
  • openstack:opensuse-tumbleweed-selinux-64:tests/main/selinux-classic-confinement
  • openstack:ubuntu-26.04-64:tests/main/interfaces-firewall-control
  • openstack:ubuntu-26.04-64:tests/main/upgrade-from-release
  • openstack:ubuntu-26.04-64:tests/main/server-snap:pythonServer
  • openstack:ubuntu-26.04-64:tests/main/try
  • openstack:ubuntu-26.04-64:tests/main/desktop-portal-filechooser
  • openstack:ubuntu-26.04-64:tests/main/server-snap:goServer
  • openstack:ubuntu-26.04-64:tests/main/xdg-open-portal
  • openstack:ubuntu-26.04-64:tests/main/desktop-portal-open-file
  • openstack:ubuntu-26.04-64:tests/main/interfaces-network-bind
  • openstack:ubuntu-26.04-64:tests/main/apparmor-prompting-flag-restart
  • openstack:ubuntu-26.04-64:tests/main/interfaces-network
  • openstack:ubuntu-26.04-64:tests/main/desktop-portal-open-uri
  • openstack:ubuntu-26.04-64:tests/main/snapd-state

Restoring:

  • openstack:opensuse-15.6-64:
  • openstack:opensuse-15.6-64:
  • openstack:ubuntu-26.04-64:tests/main/apparmor-prompting-flag-restart
  • openstack:ubuntu-26.04-64:tests/main/
  • openstack:ubuntu-26.04-64:

Skipped tests from snapd-testing-skip

  • openstack-arm:ubuntu-24.04-arm-64:tests/main/i18n
  • openstack-arm:ubuntu-core-24-arm-64:tests/main/i18n
  • openstack:debian-sid-64:tests/main/interfaces-network-status-classic
  • openstack:ubuntu-24.04-64:tests/main/i18n
  • openstack:ubuntu-26.04-64:tests/main/i18n

`

const cupsControlPermanentSlotSecComp = `
lsm_get_self_attr
Copy link
Contributor

Choose a reason for hiding this comment

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

should we allow reading /proc/self/attr/current for consistency?

Choose a reason for hiding this comment

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

maybe, this issue with /proc/self/attr/current is it value will change based on the LSM that has claimed it. For this reason apparmor provides the alternative /proc/self/attr/apparmor/current and smack /proc/self/attr/smack/current

The other question around this, is does access to /proc/self/attr/current belong in a seccomp interface, or should there be an lsm interface.

Choose a reason for hiding this comment

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

I should note that there is work in progress to add more lsm syscalls, both around namespacing and policy loads.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We kind of do via the existing permanent slot:

@{PROC}/[0-9]*/attr/{,apparmor/}current r,

@zyga zyga added this to the 2.75 milestone Feb 25, 2026
Add lsm_get_self_attr to interfaces that read AppArmor current labels
and add lsm_set_self_attr where AppArmor allows writing process
attr/exec.

Include seccomp coverage updates in tests for system-observe,
cups-control, docker-support, and kubernetes-support flavors.

No syscall addition for browser-support: it explicitly denies access to
/proc/.../attr/{,apparmor/}current.

No explicit syscall addition for lxd-support: its seccomp policy is
@unrestricted.

The k8s-support interface has both get and set per advice from John
Johansen.

Jira: https://warthogs.atlassian.net/browse/AA-1000
Signed-off-by: Zygmunt Krynicki <me@zygoon.pl>
@zyga zyga force-pushed the feature/lsm-syscalls-AA-1000 branch from 14ce710 to 1a5360d Compare February 26, 2026 09:09
@codecov
Copy link

codecov bot commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.54%. Comparing base (6755a6f) to head (1a5360d).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #16665      +/-   ##
==========================================
+ Coverage   77.53%   77.54%   +0.01%     
==========================================
  Files        1354     1353       -1     
  Lines      186920   186967      +47     
  Branches     2446     2446              
==========================================
+ Hits       144921   144981      +60     
+ Misses      33236    33219      -17     
- Partials     8763     8767       +4     
Flag Coverage Δ
unittests 77.54% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

Needs security review Can only be merged once security gave a :+1:

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants