Kernel features and the policy ABI

kernel vs policy for application developers for administrators

The kernel publishes what its AppArmor can enforce as a directory of feature files. aa-features-abi prints that directory as the text an abi file has. The parser compiles a kind of rule only when the kernel's set and the policy's set both have it and by default prints nothing when a rule is left out. Two options and one parser.conf line choose the sets. The cache directory is named after the kernel's set.

On the map: running the parser

▶ Watch this deck — 9 scenes, ~7 min

Worth seeing first

Part of journeys

01 Accepted, and not enforced

KERNEL FEATURES abi <abi/5.0>, profile demo-all /usr/bin/demo-all { /etc/demo/** r, network inet stream, mqueue (create) type=posix /demo, userns, ... twelve rules, one of each kind } $ apparmor_parser -Q -K demo-all no output, exit status 0 $ apparmor_parser -Q -K --warn=all demo-all Warning from profile demo-all (...): mqueue type=posix rules not enforced the kernel's feature set the policy's feature set compiled only if both have it the idea is in the deck on the abi rule; here: the files, the tool and the options the features directory aa-features-abi the options and parser.conf seeing what was left out
A profile demo-all with twelve rules, among them network inet stream, mqueue (create) type=posix /demo and userns. apparmor_parser -Q -K demo-all prints nothing and exits with status 0. With --warn=all it prints Warning from profile demo-all: mqueue type=posix rules not enforced. A kind of rule is compiled only if the kernel's feature set and the policy's feature set both have it. The deck covers the features directory, aa-features-abi, the options and parser.conf, and seeing what was left out.

A rule the kernel cannot enforce is left out with exit status 0 and no message unless you ask. This deck shows where the kernel publishes its feature set, how to print it, how to choose the two sets and how to see what was left out.

Here's a profile with twelve rules, one of each kind. Compile it, and the parser says nothing. Exit status zero. Ask for every warning, and one line appears: message queue rules are not enforced. The rule was fine. This kernel has no message queue mediation, so the parser left it out, quietly. Whether a kind of rule is compiled depends on two feature lists: the kernel's, and the one the policy was written for. The deck on the abi rule explains why. Here's the administrator's side: where the kernel publishes its list, the tool that prints it, the options that choose the lists, and how to see what's left out.

Details and sources

Details

  • Run in a Debian sid guest (kernel 7.3.4, whose 49 feature files are the entries of the kernel source the map describes less one, network_v8/sctp, which no rule on these slides needs) with the parser built from the AppArmor tree, --config-file=/dev/null -K, the kernel features read from the running kernel.
  • The profile is the twelve-rule profile of the research notes, named demo-all: a file rule, capability net_bind_service,, network inet stream,, network inet tcp ip=127.0.0.1 port=8080,, unix (connect) type=stream peer=(addr=@demo),, dbus send bus=session path=/org/demo,, signal send set=hup,, ptrace read,, mount fstype=tmpfs -> /mnt/demo/,, mqueue (create) type=posix /demo,, userns,, io_uring sqpoll,. The slide shows four of them.
  • apparmor_parser -Q -K demo-all.sd printed nothing and exited with status 0. With --warn=all it printed Warning from profile demo-all (demo-all.sd): mqueue type=posix rules not enforced and exited with status 0. -Q compiles without loading; -K skips the cache, without which a cached profile is not compiled again and prints no warning. The slide shortens the file name.
  • A profile with an mqueue rule also loads without a message: apparmor_parser -a of a profile with mqueue (create, open, read, write, delete) type=posix /demo-ok, exited with status 0 in the same guest.
  • "Left out" means the compiled profile carries nothing for that kind of rule, so the kernel does not consult the profile for it. An allow rule and a deny rule are left out alike.
  • Left out does not mean that the access is open. In the same guest mq_open("/demo-ok", O_CREAT|O_RDWR) under that profile failed with "Permission denied", and so did every other queue name, with and without an mqueue rule. The kernel logged a file record: apparmor="DENIED" operation="open" class="file" info="Failed name lookup - disconnected path" error=-13 profile="demo-mq" name="demo-ok" pid=1455 comm="python3" requested_mask="wrc" denied_mask="wrc" fsuid=0 ouid=0. The queue is opened as a file on a mount that is attached nowhere, and file mediation refuses a path it cannot resolve. Debian 13 logged the same. See Reading a denial; what kernels with message queue mediation do is in Upstream and Ubuntu kernels.
  • Known discrepancy: a POSIX message queue on a kernel without mqueue mediation is refused as a file with a disconnected path.
  • The two sets and the rule that a class needs its entry in both are the scene "Two feature sets, and what is in both" of The abi rule and the abi files.

for AppArmor developers for security researchers

In the code

02 What the kernel publishes

THE FEATURES DIRECTORY $ ls /sys/kernel/security/apparmor/features capability caps dbus domain file io_uring mount namespaces network_v8 network_v9 policy ptrace query rlimit signal one name per area namespaces/mask userns_create user namespace rules network_v9/af_unix yes fine-grained unix rules mount/mask mount umount pivot_root 49 files on the test kernel no ipc directory mqueue type=posix rules not enforced apparmor="DENIED" operation="open" class="file" info="Failed name lookup - disconnected path" left out is not open: this kernel still refuses the queue, as a file
The directory /sys/kernel/security/apparmor/features lists capability, caps, dbus, domain, file, io_uring, mount, namespaces, network_v8, network_v9, policy, ptrace, query, rlimit and signal. Three files: namespaces/mask holds userns_create, network_v9/af_unix holds yes, mount/mask holds mount umount pivot_root. The test kernel has 49 feature files. There is no ipc directory, so mqueue rules are left out. Left out is not open: opening a POSIX message queue under a profile is still refused, with a record of class file and the info Failed name lookup - disconnected path.

/sys/kernel/security/apparmor/features holds one file per fact: 49 files on the test kernel. A missing entry, such as ipc, means rules of that kind are left out. Left out is not open: this kernel still refuses the message queue, as a file with a disconnected path.

The kernel publishes its list as a directory called features, in the AppArmor part of securityfs. Fourteen directories and one file at the top, one per area: file, mount, signal and so on. Inside, each file is one fact. Under namespaces, the mask file says userns_create: user namespace rules. Under network_v9, af_unix says yes: fine-grained unix socket rules. The mount mask lists mount, umount and pivot root. Forty-nine files on our test kernel. What isn't there matters as much. There's no ipc directory: that's the reason for the message queue line. Left out doesn't mean open, though: this kernel still refuses that queue, as a file with a disconnected path.

Details and sources

Details

  • The list was read in a Debian sid guest (kernel 7.3.4): every file under the directory with its content, 49 files. They are the entries of the feature tables of the kernel source the map describes, with policy compression configured in, less one: that source also has network_v8/sctp (net.c:24-36), which makes 50. The ls output on the slide is that list's top level, wrapped over two lines.
  • All 49, with their values: capability 0xffffff; caps/extended yes; caps/mask (the capability names); dbus/mask acquire send receive; domain/attach_conditions/xattr, domain/change_hat, domain/change_hatv, domain/change_onexec, domain/change_profile, domain/computed_longest_left, domain/disconnected.path, domain/fix_binfmt_elf_mmap, domain/kill.signal, domain/post_nnp_subset, domain/stack, domain/unconfined_allowed_children yes; domain/version 1.2; file/mask create read write exec append mmap_exec link lock; io_uring/mask sqpoll override_creds; mount/mask mount umount pivot_root; mount/move_mount detached; namespaces/mask userns_create; namespaces/pivot_root no; namespaces/profile yes; network_v8/af_mask and network_v9/af_mask (the address family names); network_v8/tcp-fast-open, network_v9/tcp-fast-open, network_v9/af_unix yes; policy/compressed_load, policy/diff-encode, policy/extended_policy_header, policy/set_load yes; policy/outofband 0x000001; policy/permstable32 (13 words); policy/permstable32_version 0x000003; policy/state32 0x000001; policy/unconfined_restrictions/change_profile yes; policy/versions/v5 to v9 yes; ptrace/mask read trace; query/label/data, query/label/multi_transaction yes; query/label/perms allow deny audit quiet; rlimit/mask (the limit names); signal/mask (the signal names).
  • Not there, and looked for by the parser: ipc/posix_mqueue (mqueue rules), network_v8/af_inet (ip= and port=), network and network/af_unix (the older network and unix mediation), network_v9_skb (interface=), domain/interruptible, domain/disconnected.ipc.
  • No ipc entry means mqueue rules are left out of every profile compiled for this kernel. It does not mean message queues are open to confined programs: in the same guest, opening a POSIX message queue under a profile was refused, with and without an mqueue rule, and the record on the slide was logged in full as apparmor="DENIED" operation="open" class="file" info="Failed name lookup - disconnected path" error=-13 profile="demo-mq" name="demo-ok" pid=1455 comm="python3" requested_mask="wrc" denied_mask="wrc" fsuid=0 ouid=0.
  • Known discrepancy: a POSIX message queue on a kernel without mqueue mediation is refused as a file with a disconnected path.
  • An entry says the kernel has the code. A class is enforced for a profile only when the profile was compiled with rules for it.
  • dbus/mask is published by the kernel, although D-Bus rules are enforced by the bus daemon: see D-Bus mediation.
  • The files are readable by every user. Other kernels publish other lists: see Upstream and Ubuntu kernels.

for AppArmor developers for security researchers

In the code

03 aa-features-abi: the directory as one text

AA-FEATURES-ABI $ aa-features-abi -x capability {0xffffff } caps {extended {yes } mask {chown dac_override dac_read_search ... } } dbus {mask {acquire send receive ... 116 lines name {value } a file name {child {value } } a directory $ aa-features-abi -x -w kernel.abi saved to a file /etc/apparmor.d/abi/5.0 the same text form: a saved list with a name $ diff kernel.abi /etc/apparmor.d/abi/5.0 > ipc {posix_mqueue {create read write open delete setattr getattr label < tcp-fast-open {yes
aa-features-abi -x prints the kernel's features as text, 116 lines, beginning capability {0xffffff, }, caps {extended {yes, }, mask {chown dac_override ..., }, }, dbus {mask {acquire send receive. The form is a name, a brace, the value or nested names, a closing brace. aa-features-abi -x -w kernel.abi saves it to a file. The file /etc/apparmor.d/abi/5.0 has the same text form. diff kernel.abi /etc/apparmor.d/abi/5.0 shows, among others, ipc posix_mqueue only in abi/5.0 and tcp-fast-open only in the kernel.

aa-features-abi -x prints the kernel's feature set as text; -w FILE saves it. An abi file has the same form, so the two can be compared with diff.

You don't have to walk the directory. The aa-features-abi tool does it. With -x it extracts the running kernel's features and prints them as one text: a name, an opening brace, then the value or the nested names, and a closing brace. A hundred and sixteen lines here. With -w it writes the text to a file instead. That text should look familiar: it's the form of the abi files under /etc/apparmor.d. An abi file is a feature list that somebody saved and gave a name. So you can save your kernel's list, carry it to another machine, or compare it with abi/5.0 using diff.

Details and sources

Details

  • Run in a Debian sid guest (kernel 7.3.4) with the tool built from the AppArmor tree: aa-features-abi -x -w FILE exited with status 0 and wrote 116 lines (2482 bytes); the first nine are the ones on the slide, with the capability list shortened. The distribution's own aa-features-abi -x printed the same bytes.
  • Usage: aa-features-abi [OPTIONS] <SOURCE> [OUTPUT OPTIONS]. Source: -x, --extract (the running kernel) or -f F, --file=F (a file). Output: --stdout (the default) or -w F, --write=F. Options: -d, --debug; -v, --verbose; -h, --help. -x together with -f is refused: options --extract and --file are mutually exclusive.
  • -f reads a feature file and writes it out again, which checks that the file can be parsed.
  • The text form: a directory becomes name { followed by its entries and a } line; a file becomes name { followed by its content, with } on the next line.
  • The diff on the slide was made between the saved text of the guest's kernel and the abi/5.0 file of the AppArmor tree; the two lines shown are two of its lines. Only in abi/5.0: disconnected.ipc, interruptible, the ipc block, userns_create {pciu&, the network block, af_inet, metadata_tagging_version, the notify blocks, and io_uring and userns under unconfined_restrictions. Only in the kernel: tcp-fast-open, compressed_load, diff-encode, extended_policy_header.
  • Not every difference matters: the parser asks for 24 paths and the capability list, and ignores the rest of a policy feature file. Which path switches on which kind of rule is in the reference of The abi rule and the abi files.
  • A feature text can be at most 8192 bytes; the five kernels looked at had 1960 to 3249.

for AppArmor developers for security researchers

In the code

04 Compiling for another kernel

THE KERNEL'S SET the running kernel apparmor_parser its feature set --kernel-features kernel.abi $ apparmor_parser -Q -K --warn=all --kernel-features kernel.abi demo-all Warning from profile demo-all (...): mqueue type=posix rules not enforced on a machine without that kernel: the same warning and the same bytes $ apparmor_parser -Q -K --warn=all --kernel-features /etc/apparmor.d/abi/3.0 demo-all ... mqueue type=posix rules not enforced ... userns rules not enforced ... io_uring rules not enforced the option changes what the parser assumes, not what the kernel can do give it the list of the kernel the policy will run on
The parser normally reads the kernel's feature set from the running kernel. The option --kernel-features FILE replaces it with a file. With the saved file kernel.abi, on a machine without that kernel, the parser prints the same warning, mqueue type=posix rules not enforced, and writes the same bytes. With --kernel-features /etc/apparmor.d/abi/3.0 it also prints userns rules not enforced and io_uring rules not enforced. The option changes what the parser assumes, not what the kernel can do.

--kernel-features FILE replaces the running kernel's feature set with a file, to compile policy for another kernel. It changes what the parser assumes, not what a kernel can do.

By default the parser takes the kernel's list from the running kernel. With the --kernel-features option you replace it with a file. That's for compiling policy somewhere else: a build machine, a container image, a test. We saved our test kernel's list, took it to a machine without an AppArmor kernel, and the parser gave the same warning and the same bytes. Give it an older list, and more is left out: here user namespace and io_uring rules go as well. One caution. The option changes what the parser assumes, not what the kernel can do. So give it the list of the kernel the policy will run on.

Details and sources

Details

  • The first command was run with the tree's parser in a container on a host whose kernel has no part in the run (-Q -K --skip-kernel-load), with the feature text saved from the Debian sid guest as the file. It printed Warning from profile demo-all (/work/demo-all.sd): mqueue type=posix rules not enforced, and -S wrote 1037 bytes. In the guest itself, with the features read from the running kernel, the warning and the 1037 bytes were the same. The slide shortens the file names and the warning prefix.
  • The second command was run in the guest, with the abi/3.0 file of the AppArmor tree as the kernel set (the slide writes the installed path). Output, in full: Warning from profile demo-all (demo-all.sd): mqueue type=posix rules not enforced, ... userns rules not enforced, ... io_uring rules not enforced, exit status 0. The same three lines came out on every kernel tried, because the file replaced the kernel's set.
  • Without the option the parser reads /sys/kernel/security/apparmor/features.
  • The kernel's set decides more than which rules are compiled: the format of the compiled profile (policy version, the form of the permission tables, compression) and the name of the cache directory follow it too. See The binary policy format and the scene "A new kernel, a new cache directory".
  • A file that cannot be read: Failed to load kernel features from 'FILE': ..., exit status 1 (from the source, not run).
  • -M FILE (--features-file) and -m STRING (--match-string) set the kernel's set and pin the policy's set to the same value in one step.
  • Whether a kernel refuses a profile compiled for a larger feature set than it has was not tried.
  • Known discrepancy: apparmor_parser(8) gives /etc/apparmor.d/cache/.features as the default of -M; the parser reads the running kernel when no option is given.

for AppArmor developers for security researchers

In the code

05 The policy's list, from the command line

THE POLICY'S SET the twelve-rule profile without its abi line, with -Q -K --warn=all (no option)falling back to default policy feature abi network, unix, mqueue, userns, io_uring rules not enforced --policy-features /etc/apparmor.d/abi/3.0the unix rule is downgraded mqueue, userns, io_uring not enforced --policy-features '<kernel>'only mqueue not enforced abi <abi/5.0>, in the profile not affected by --policy-features --override-policy-abi /etc/apparmor.d/abi/3.0wins over the abi rule the same four lines as with abi/3.0 above which source wins in general: the deck on the abi rule
The twelve-rule profile without an abi rule, compiled with -Q -K --warn=all. No option: missing feature abi, falling back to default; network, unix, mqueue, userns and io_uring rules are not enforced. --policy-features /etc/apparmor.d/abi/3.0: the unix rule is downgraded; mqueue, userns and io_uring are not enforced. --policy-features <kernel>: only mqueue is not enforced. A profile with an abi rule is not affected by --policy-features. --override-policy-abi /etc/apparmor.d/abi/3.0 on a profile that says abi/5.0: the option wins over the rule and prints the same four lines.

For profiles without an abi rule, --policy-features names the policy set: a file or <kernel>. --override-policy-abi also replaces the set of profiles that have an abi rule.

The other list belongs to the policy. A profile names it with its abi rule. But plenty of profiles have no abi rule. Then the parser falls back to an old built-in list and leaves out a lot: network, unix, message queue, user namespace and io_uring rules. For those profiles there's the --policy-features option. It takes a file, or the word kernel in angle brackets: whatever the running kernel has. With that, only the message queue line remains. It doesn't touch profiles with an abi rule. For that there's the --override-policy-abi option: it beats the rule in the file. Use it knowingly: the author chose that line.

Details and sources

Details

  • Run in a Debian sid guest (kernel 7.3.4, whose 49 feature files are the entries of the kernel source the map describes less one, network_v8/sctp, which no rule on these slides needs) with the parser built from the AppArmor tree, --config-file=/dev/null -K, the kernel features read from the running kernel. The profile is the twelve-rule profile with its first line removed; all runs had -Q --warn=all and exit status 0. The slide writes the installed path of the abi file; the runs used the copy from the AppArmor tree.
  • No option: Warning from demo-all-noabi.sd (demo-all-noabi.sd line 1): .../apparmor_parser: File 'demo-all-noabi.sd' missing feature abi, falling back to default policy feature abi, then network rules not enforced (three times), extended network unix socket rules not enforced, mqueue type=posix rules not enforced, userns rules not enforced, io_uring rules not enforced, and a line profile demo-all network rules not enforced.
  • Without --warn=all the same file prints nothing: the "missing feature abi" warning belongs to the warning class abi, which is off by default (run with the tree's parser outside a guest).
  • --policy-features FILE with abi/3.0: downgrading extended network unix socket rule to generic network rule, mqueue type=posix rules not enforced, userns rules not enforced, io_uring rules not enforced.
  • --policy-features "<kernel>": mqueue type=posix rules not enforced only. The word must reach the parser with its angle brackets, so quote it in a shell. It always means the running kernel, also when --kernel-features names a file: on a machine without an AppArmor kernel the tree's parser stopped with Failed to load kernel features into the policy-features abi: No such file or directory, exit status 1 (run with the tree's parser outside a guest).
  • --override-policy-abi FILE with abi/3.0, on the profile that has abi <abi/5.0>,: the same four lines as --policy-features with abi/3.0 on the profile without the rule. It also accepts <kernel>.
  • --compile-features is the older name of --policy-features.
  • The manual: --policy-features "does not override feature ABI rules"; --override-policy-abi does.
  • A file that cannot be read: Failed to load policy-features from 'FILE': ..., exit status 1 (from the source, not run).
  • The order of all the sources of the policy set, and what the built-in default lacks, is the scene "Who decides the policy ABI" of The abi rule and the abi files.
  • Known discrepancy: Two "not enforced" warnings are printed for rules that are compiled.

for AppArmor developers for security researchers

In the code

06 parser.conf: a pin for the whole system

PARSER.CONF /etc/apparmor/parser.conf every long option, one per line ## Pin older policy to the 5.4 kernel abi #policy-features=/etc/apparmor.d/abi/kernel-5.4-vanilla policy-features=FILE pins every profile without an abi rule, on every load (the first two lines are the shipped example) Debian 13, Debian sid policy-features=/usr/share/apparmor-features/features Ubuntu 24.04, 26.04, 26.10 no active line: a profile without an abi rule gets the built-in default abi <abi/5.0>, in the profile its own line wins over the pin
The file /etc/apparmor/parser.conf as shipped has the commented example #policy-features=/etc/apparmor.d/abi/kernel-5.4-vanilla. A line policy-features=FILE pins every profile without an abi rule, on every load. Debian 13 and Debian sid ship policy-features=/usr/share/apparmor-features/features. Ubuntu 24.04, 26.04 and 26.10 ship no active line. A profile with abi <abi/5.0>, wins over the pin.

policy-features=FILE in /etc/apparmor/parser.conf pins every profile without an abi rule. Debian ships such a line, Ubuntu none. A profile's own abi rule wins over the pin.

Options on a command line are forgotten. The parser's config file isn't: every long option can go into parser.conf, one per line. A policy features line there pins every profile without an abi rule to one list, on every load, including at boot. The shipped file has two examples, commented out. What do real systems do? The Debian systems we looked at ship a pin, to a file of their own. The Ubuntu ones ship none. So the same profile without an abi rule can mean different things on the two. And a profile with an abi rule isn't affected: its own line wins over the pin.

Details and sources

Details

  • The config file is read before the command line, on every run of the parser, so also when policy is loaded at boot. --config-file FILE names another file; --print-config-file prints which one is used.
  • The shipped file has the two commented lines #policy-features=/etc/apparmor.d/abi/kernel-5.4-vanilla and #policy-features=/etc/apparmor.d/abi/kernel-5.4-outoftree-network, and says that only one should be used at a time. It also has #warn=no-abi, to switch the abi warnings off without a pin.
  • Run with the tree's parser outside a guest (kernel set: the tree's abi/5.0 file, --warn=all): with a config file holding policy-features=.../abi/3.0, the twelve-rule profile without an abi rule printed mqueue type=posix rules not enforced, userns rules not enforced and io_uring rules not enforced, and no "missing feature abi" line. The same profile with abi <abi/5.0>, printed nothing: the abi rule won over the pin. With policy-features=.../abi/5.0 and warn=all both in the config file, the profile without an abi rule printed nothing.
  • What distributions ship was read in guests: /etc/apparmor/parser.conf on Debian 13 and Debian sid has one line that is not a comment, policy-features=/usr/share/apparmor-features/features. On Ubuntu 24.04, 26.04 and 26.10 every line is a comment. The content of Debian's features file was not examined.
  • Without a pin and without an abi rule a profile gets the parser's built-in default set: see the scene "The policy's list, from the command line" for what that leaves out.
  • A later policy-features= line replaces an earlier one.
  • Other keys of the file are in parser.conf, warnings and debug flags.

for AppArmor developers for security researchers

Attack surface

  • The file changes which mediation classes every profile without an abi rule gets, on every load and without a message. Who can write it can weaken policy without touching a profile. See Who can change policy.

for AppArmor developers for security researchers

In the code

07 Seeing what was left out

WHAT WAS LEFT OUT $ apparmor_parser -Q -K demo-all no output, exit status 0 $ apparmor_parser -Q -K --warn=all demo-all Warning from profile demo-all (...): mqueue type=posix rules not enforced the classes rule-not-enforced and rule-downgraded are off by default ... -Q -D rule-exprs demo-all 24 rule lines on this kernel 67 on another kernel ... -Q -K --warn=rule-not-enforced --Werror=rule-not-enforced demo-all Warning converted to Error from profile demo-all (...): mqueue type=posix rules not enforced exit status 1: a build stops here ip= and port= the kernel cannot check: no message, with any option
apparmor_parser -Q -K demo-all prints nothing and exits 0; -K skips the cache, so the profile is compiled. With --warn=all it prints mqueue type=posix rules not enforced; the warning classes rule-not-enforced and rule-downgraded are off by default. -D rule-exprs shows 24 rule lines on one kernel and 67 on another for the same profile. With --warn=rule-not-enforced and --Werror=rule-not-enforced the parser prints Warning converted to Error and exits with status 1. ip= and port= conditions the kernel cannot check are dropped with no message at all.

-Q -K --warn=all lists what was left out or downgraded (without -K a cached profile is not compiled again and prints nothing); -D rule-exprs shows what was compiled; --Werror with the warning enabled fails the compile. ip= and port= conditions are dropped with no message.

So how do you find out what your profiles lost? By default you don't: no message, exit status zero. Three things help. --warn=all, with -Q so nothing is loaded and -K to skip the cache, prints a line for each kind of rule left out or downgraded. The rule expression dump shows what was compiled: for our twelve rules, twenty-four lines on one kernel and sixty-seven on another. And --Werror, with the same warning switched on, turns a left-out rule into a failed compile: what a build wants. A gap remains: address and port conditions the kernel can't check go without any message.

Details and sources

Details

  • Run in a Debian sid guest (kernel 7.3.4, whose 49 feature files are the entries of the kernel source the map describes less one, network_v8/sctp, which no rule on these slides needs) with the parser built from the AppArmor tree, --config-file=/dev/null -K, the kernel features read from the running kernel. The slide shortens file names and writes ... for apparmor_parser.
  • apparmor_parser -Q -K demo-all.sd: no output, exit status 0. With --warn=all: Warning from profile demo-all (demo-all.sd): mqueue type=posix rules not enforced, exit status 0.
  • Why -K: the warnings are printed while a profile is compiled. Reading the cache is on by default and -Q does not turn it off, so for a profile that has a fresh cache entry, which is the normal state of the files in /etc/apparmor.d, the parser takes the compiled profile from the cache and prints no warning. -K (--skip-cache) or -T (--skip-read-cache) makes it compile. -D and -S skip reading the cache by themselves. See The policy cache.
  • The two warning classes are rule-not-enforced ("warn if a rule is not enforced") and rule-downgraded ("warn if a rule is downgraded to a lesser but still enforcing rule"). Neither is in the default set. --help=warn lists all classes; --warn=all switches every class on, so it prints other warnings too. A line warn=rule-not-enforced in parser.conf makes it permanent.
  • -D rule-exprs prints one rule: line per compiled rule. For the twelve-rule profile with abi <abi/5.0>,: 24 lines in the Debian sid guest. "Another kernel" is the Ubuntu 26.04 guest (kernel 7.0), where the same command gave 67 and --warn=all printed nothing; Ubuntu 24.04 gave 66 and Debian 13 gave 19. See Upstream and Ubuntu kernels.
  • The --Werror run was made with the tree's parser outside a guest, with the feature text saved from the Debian sid guest as the kernel set. With --warn=rule-not-enforced --Werror=rule-not-enforced it printed Warning converted to Error from profile demo-all (/work/demo-all.sd): mqueue type=posix rules not enforced and exited with status 1.
  • Known discrepancy: --Werror=rule-not-enforced without --warn=rule-not-enforced exits with status 1 and prints nothing. Seen in the same run without the --warn option, and with a bare --Werror.
  • What prints nothing even with --warn=all, recorded in the research notes with the tree's parser: ip= and port= on a network rule when the kernel has no network_v8/af_inet (the rule is kept as a family and type rule), interface= without network_v9_skb/iface, and the flag attach_disconnected.ipc.
  • Known discrepancy: inet conditionals are dropped silently when the kernel has no af_inet, so deny rules get wider. Seen on the running Debian sid kernel: with network inet stream, and deny network (connect) inet stream peer=(ip=127.0.0.1 port=25), a connect to port 22 was refused as well as one to port 25.
  • Known discrepancy: attach_disconnected.ipc is dropped without a warning and its bit is written anyway.
  • Known discrepancy: Only the first "Ignoring" warning of a profile is printed.
  • A kind of rule that was left out leaves no audit record of its own class at run time: the kernel does not consult the profile for it. That does not make the access open. On this kernel a POSIX message queue is still refused, and the record is a file record with info="Failed name lookup - disconnected path". See the scene "What the kernel publishes" and Reading a denial.
  • Known discrepancy: a POSIX message queue on a kernel without mqueue mediation is refused as a file with a disconnected path.

for AppArmor developers for security researchers

In the code

08 A new kernel, a new cache directory

FEATURES AND THE CACHE $ apparmor_parser --print-cache-dir /var/cache/apparmor/48da56f3.0 a hash of the kernel's feature text eight hexadecimal digits kernel 6.12979b3ac6.0kernel 6.8b8ec2925.0kernel 7.0f6da0254.0kernel 7.348da56f3.0another 7.30bd21c56.0 five kernels, five names a kernel upgrade, a different feature set a new directory every profile compiled again the old directory stays for the old kernel --print-cache-dir: which directory this kernel uses
apparmor_parser --print-cache-dir prints /var/cache/apparmor/48da56f3.0. The eight hexadecimal digits are a hash of the kernel's feature text. Five kernels gave five names: 979b3ac6.0, b8ec2925.0, f6da0254.0, 48da56f3.0 and 0bd21c56.0. After a kernel upgrade with a different feature set there is a new directory, every profile is compiled again, and the old directory stays.

The cache directory is named after a hash of the kernel's feature text. A kernel with a different feature set gets a new directory and every profile is compiled again. --print-cache-dir prints the one in use.

One more place where the kernel's list shows up: the cache. The parser keeps compiled profiles in a directory named after a hash of the kernel's feature text. Five kernels, five different names. A compiled profile is only right for the list it was compiled against, so a kernel with a different list gets a directory of its own. For you it explains two things. After a kernel upgrade that changes the list, the first load is slower, because every profile is compiled again. And the old directory stays behind, ready if you boot the old kernel. To see which one is in use, there's the --print-cache-dir option.

Details and sources

Details

  • apparmor_parser --print-cache-dir was run with the distribution's parser in five guests. Debian 13 (kernel 6.12.116): /var/cache/apparmor/979b3ac6.0. Ubuntu 24.04 (6.8.0-147): b8ec2925.0. Ubuntu 26.04 (7.0.0-43): f6da0254.0. Debian sid (7.3.4): 48da56f3.0. Ubuntu 26.10 (7.3.0-10): 0bd21c56.0. "Another 7.3" on the slide is the Ubuntu 26.10 kernel: the same kernel version as Debian sid's with a different feature set. Each guest's /var/cache/apparmor/ held exactly that one directory.
  • The tree's parser, run outside a guest with --kernel-features naming the feature text saved from the Debian sid guest, printed /var/cache/apparmor/48da56f3.0 as well: the name depends on the feature text and on nothing else of the machine.
  • The name is the hash as eight hexadecimal digits, a dot and a number. The number is 0 unless two different feature texts have the same hash; then the next free number is used.
  • Two kernel versions with the same feature text share a directory. The feature text is the kernel's set, whether read from the running kernel or given with --kernel-features. The policy set does not enter the name.
  • "Every profile is compiled again" follows from the new directory being empty; it was not timed. Whether old directories are ever removed is a matter of the distribution's packaging and was not examined.
  • How the cache decides that an entry is fresh, and the options that control it, are in The policy cache.

for AppArmor developers for security researchers

In the code

09 From the feature files to the rules they switch on

ROADS /sys/kernel/security/apparmor/features syn-abi the line in a profile, the shipped files adm-parseradm-configadm-cache the parser, its config, the cache upstream-and-ubuntu the lists of other kernels adm-denialslib-featuresk-apparmorfsre-blob the rules that did make it in
The features directory in the centre. Roads to syn-abi, the line inside a profile and the shipped files; to adm-parser, adm-config and adm-cache, the parser, its config file and the cache; to upstream-and-ubuntu, the lists of other kernels; to adm-denials, the rules that are enforced; and to lib-features, k-apparmorfs and re-blob.

The feature directory, aa-features-abi, --kernel-features, --policy-features, parser.conf and --warn=all. Roads: the abi rule, the parser and its config, the cache, other kernels.

That's the administrator's side of features. The kernel publishes its list as a directory, and aa-features-abi prints it as text. Then the --kernel-features option and the --policy-features option replace the two lists, and parser.conf pins the policy's list. Nothing is printed when a rule is left out, unless you ask with --warn=all. From here: the deck on the abi rule, for the line inside a profile and the shipped files. Running the parser, its config file and the cache have their own decks. Upstream and Ubuntu kernels compares the lists of different kernels. And reading a denial covers the rules that made it in.

Details and sources

Read more

Basis of the statements on this page: "guest" means the command was run in a disposable virtual machine with the parser and aa-features-abi built from the AppArmor commit 836052d21 (--config-file=/dev/null -K, kernel features read from the running kernel unless an option says otherwise). The main guest is Debian sid with kernel 7.3.4, whose 49 feature files are the entries of the feature tables of the kernel source the map describes less one (network_v8/sctp). "tree" means the tree's parser was run without a kernel (-Q -K --skip-kernel-load), with the kernel set named. "source" means read and not run. The abi rule, the shipped abi files and the table of which entry switches on which kind of rule are in The abi rule and the abi files and are not repeated here.

The feature directory

/sys/kernel/security/apparmor/features, readable by every user. Top level on the kernel: capability (a file) and the directories caps, dbus, domain, file, io_uring, mount, namespaces, network_v8, network_v9, policy, ptrace, query, rlimit, signal.

EntryValue (guest)What it switches on
file/maskcreate read write exec append mmap_exec link lockfile rules (always compiled)
network_v8, network_v9directoriesnetwork rules
network_v9/af_unixyesfine-grained unix rules
mount/maskmount umount pivot_rootmount, umount and pivot_root rules
mount/move_mountdetachedread from the kernel set only
signal/mask, ptrace/maskthe signal names; read tracesignal and ptrace rules
dbus/maskacquire send receivedbus rules are compiled (the bus daemon enforces them)
namespaces/maskuserns_createuserns rules
io_uring/masksqpoll override_credsio_uring rules
domain/stackyesstacking (& targets)
domain/attach_conditions/xattryesxattrs= on a profile
domain/kill.signalyesflags=(kill.signal=...)
caps/maskthe capability nameswhich capability names are known
policy/versions/v5 to v9, policy/permstable32, policy/permstable32_version, policy/state32, policy/outofband, policy/set_load, policy/diff-encode, policy/compressed_load, policy/extended_policy_headeryes or a numberthe format of the compiled profile
policy/unconfined_restrictions/change_profileyes
query/label/*the query interface
not present: ipc/posix_mqueue, network_v8/af_inet, network, network/af_unix, network_v9_skb, domain/interruptible, domain/disconnected.ipcmqueue rules; ip= and port=; the older network and unix mediation; interface=; two profile flags

aa-features-abi

aa-features-abi [OPTIONS] <SOURCE> [OUTPUT OPTIONS]
  SOURCE:  -x, --extract        the running kernel
           -f F, --file=F       a feature file
  OUTPUT:  --stdout             the default
           -w F, --write=F      a file
  OPTIONS: -d, --debug   -v, --verbose   -h, --help

Guest: -x -w FILE wrote 116 lines. -x with -f: options --extract and --file are mutually exclusive (source). The text form: name {content and } for a file, name { ... } for a directory.

Options that set the feature sets

OptionSetsValueBeats an abi rule
(none)kernel set: the running kernel. Policy set: the file's abi rule, else the built-in default
--kernel-features FILEthe kernel seta feature filenot applicable
--policy-features FILE (older name --compile-features)the policy set of files without an abi rulea file or <kernel>no
--override-policy-abi FILEthe policy set of every filea file or <kernel>yes
-M FILE, --features-file FILEboth: the kernel set, and the policy set as with --policy-featuresa fileno
-m STRING, --match-string STRINGboth, from a stringfeature textno
policy-features=FILE in parser.confas --policy-features, on every runno

Guest, the twelve-rule profile, -Q -K --warn=all:

Profile and optionOutput (prefix left out)
with abi <abi/5.0>,mqueue type=posix rules not enforced
with it, --kernel-features abi/3.0mqueue, userns and io_uring rules not enforced
with it, --override-policy-abi abi/3.0downgrading extended network unix socket rule to generic network rule; mqueue, userns, io_uring not enforced
without an abi ruleFile '...' missing feature abi, falling back to default policy feature abi; network (three lines), extended network unix socket rules not enforced, mqueue, userns, io_uring not enforced
without, --policy-features "<kernel>"mqueue type=posix rules not enforced
without, --policy-features abi/3.0the unix rule downgraded; mqueue, userns, io_uring not enforced

Every run exits with status 0. Without --warn=all none prints anything (tree).

parser.conf

/etc/apparmor/parser.conf: every long option as name=value or name, one per line, read before the command line. --config-file FILE names another file.

System (guest)Active lines
the shipped file of the treenone; two commented policy-features= examples
Debian 13, Debian sidpolicy-features=/usr/share/apparmor-features/features
Ubuntu 24.04, 26.04, 26.10none

Tree: a pin to abi/3.0 removes the "missing feature abi" warning of a profile without an abi rule and leaves mqueue, userns and io_uring rules out; a profile with abi <abi/5.0>, is compiled against abi/5.0 whatever the pin says.

Seeing what was left out

CommandShows
apparmor_parser -Q -K --warn=all FILEone line per kind of rule left out or downgraded, per profile; also every other warning. Without -K (or -T) a profile with a fresh cache entry is not compiled again and prints nothing
--warn=rule-not-enforced, --warn=rule-downgradedonly these two classes
apparmor_parser -Q -D rule-exprs FILEthe compiled rules, one rule: line each
-K --warn=rule-not-enforced --Werror=rule-not-enforcedexit status 1 and Warning converted to Error ...
apparmor_parser --help=warnthe warning classes

Known discrepancies: --Werror=rule-not-enforced without --warn=rule-not-enforced exits with status 1 and prints nothing; inet conditionals are dropped silently when the kernel has no af_inet, so deny rules get wider; attach_disconnected.ipc is dropped without a warning and its bit is written anyway; Two "not enforced" warnings are printed for rules that are compiled; Only the first "Ignoring" warning of a profile is printed.

The same profile on five kernels

The twelve-rule profile with abi <abi/5.0>,, compiled in each guest by the tree's parser with -Q -K --warn=all. Which kernel has which entry, and why, is Upstream and Ubuntu kernels.

Guest kernelFeature filesWarningsrule: linesCache directory
Debian 13, 6.12.11638unix rule downgraded; dbus and mqueue rules not enforced19979b3ac6.0
Ubuntu 24.04, 6.8.0-14751none66b8ec2925.0
Ubuntu 26.04, 7.0.0-4367none67f6da0254.0
Debian sid, 7.3.449mqueue rules not enforced2448da56f3.0
Ubuntu 26.10, 7.3.0-1068none670bd21c56.0

The cache directory

<cache location>/<hash>.<n>: the hash is eight hexadecimal digits computed from the kernel set's text; n is 0 unless two texts collide. apparmor_parser --print-cache-dir prints it. Tree: with --kernel-features naming the text saved from the Debian sid guest, the name is the guest's, 48da56f3.0.

for AppArmor developers for security researchers

In the code

for security researchers

Attack surface

  • Three things outside any profile change which kinds of rule exist in loaded policy, with exit status 0 and no default message: the kernel's feature set (a kernel without an entry), parser.conf (policy-features=), and the options given by whatever loads policy at boot.
  • A deny rule is left out like any other rule of its kind.
  • A kind of rule that was left out produces no audit record of its own class at run time. The access is not always open: Known discrepancy: a POSIX message queue on a kernel without mqueue mediation is refused as a file with a disconnected path.

Roads from here

START HERE

PREAMBLE AND REUSE

RUNNING THE PARSER

LIBAPPARMOR

IN THE KERNEL

  • apparmorfs (no slides yet) — the filesystem the feature files live in

THE DFA ENGINE · libapparmor_re