Public bug reported:

Package: linux 7.0.0-43.43 (linux-image-7.0.0-43-generic, Ubuntu 
7.0.0-43.43-generic 7.0.14)
Release: Ubuntu 26.04.1 LTS (host)

On Ubuntu kernel 7.0.0-43-generic, the focal (20.04) apparmor_parser 2.13.3 
cannot load
profiles containing common rule kinds, and the kernel logs
"AppArmor DFA diff encoded transition state without header flag" for each 
rejected load.
The same parser loads the same profiles on a 5.4 kernel, and the 22.04 (3.0.4) 
and
24.04 (4.0.1) parsers load them on 7.0.

Versions
- Host: Ubuntu 26.04.1 LTS, linux-image-generic 7.0.0-43.43, apparmor 
5.0.2-0ubuntu1~26.04.1
- LXD container, Ubuntu 20.04.6: apparmor 2.13.3-7ubuntu5.4, snapd 2.67.1+20.04

What I expected
Profiles compiled by the focal parser load, as they do on kernel 5.4 and on 
earlier
releases' kernels, so snapd starts inside a 20.04 container.

What happened
Reproduce (host on 7.0.0-43-generic, LXD):

  lxc launch ubuntu:20.04 f
  lxc exec f -- sh -c 'printf "profile t /bin/true {\n  ptrace,\n}\n" > 
/tmp/t.prof; apparmor_parser -r /tmp/t.prof'
  apparmor_parser: Unable to replace "t".  Profile doesn't conform to protocol

Kernel log, one line per attempt:

  kernel: AppArmor DFA diff encoded transition state without header flag

Rules, loaded one per profile:
  fail: "ptrace,"  "change_profile,"  "pivot_root,"  "mount,"  "signal (send),"
  ok:   "ptrace (read),"  "mount options=(rw, bind) /a/ -> /b/,"  "umount,"  
"unix,"  "capability sys_admin,"

The same failing rules load on a 20.04 VM (guest kernel 5.4.0-1133-kvm). The 
kernel
reports versions v5..v9 as supported 
(/sys/kernel/security/apparmor/features/policy/versions).
Adding an `abi <...>` header to the profile isn't a workaround: the focal 
parser can't find
abi/ files.

Impact
snapd cannot start whenever it reloads its snap-confine profile:

  snapd: cannot run daemon: state startup errors: [cannot reload snap-confine 
apparmor profile:
    /sbin/apparmor_parser: Unable to replace "/usr/lib/snapd/snap-confine". 
Profile doesn't conform to protocol]

This breaks `charmcraft pack` for [email protected] platforms on 7.0 hosts, 
including GitHub's
ubuntu-latest (now 26.04, kernel 7.0.0-1019-azure per runner image 
20261111.196).

Analysis
The message comes from the DFA validation in security/apparmor/match.c 
(unpack_dfa): a state has
MATCH_FLAG_DIFF_ENCODE set but the table header lacks YYTH_FLAG_DIFF_ENCODE. 
That check is in 5.10
too, so I suspect a newer kernel interprets bits of the old parser's tables 
differently. I haven't
bisected, and I haven't tried a mainline 7.0 kernel, so I can't say whether the 
change is in
upstream AppArmor or in Ubuntu's patches.

Questions
- Is the cut-off for older parser output intended? If not, can compatibility 
with 2.13.x output
  be restored?
- If it is intended, can that be documented and the focal parser updated?

```
∮ cat /tmp/diag/attach/version.log
Ubuntu 7.0.0-43.43-generic 7.0.14
```

Attachments: lspci-vnvn.log (sudo lspci -vnvn).

** Affects: linux (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: apparmor regression-release resolute

** Attachment added: "lspci -vnvn output"
   
https://bugs.launchpad.net/bugs/2174837/+attachment/6019113/+files/lspci-vnvn.log

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2174837

Title:
  AppArmor on 7.0 rejects focal apparmor_parser 2.13.3 policy ("Profile
  doesn't conform to protocol"); snapd in 20.04 containers fails to
  start

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2174837/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to