Skip to content

RDKEMW-18141:Update isApparmorProfileLoaded() to avoid audit logs in kernel version - #464

Open
Sonajeya31 wants to merge 1 commit into
rdkcentral:release/v3.14from
Sonajeya31:hotfix/RDKEMW-18141
Open

RDKEMW-18141:Update isApparmorProfileLoaded() to avoid audit logs in kernel version#464
Sonajeya31 wants to merge 1 commit into
rdkcentral:release/v3.14from
Sonajeya31:hotfix/RDKEMW-18141

Conversation

@Sonajeya31

Copy link
Copy Markdown
Contributor

Description

The container configuration allows AppArmor profiles to be specified, which will be applied to processes running in the container. The logic checks if the profile is loaded into the kernel, then assigns the profile if it is found.

The current mechanism for testing if an AppArmor profile is loaded depends on the kernel module permprofile logic. Unfortunately, after kernel version 4.13, this logic is changed in such a way that results in logs being created whenever a profile is passed in via permprofile, which results in a number of logs created unnecessarily.

These logs are marked with info="profile not found" with DobbyDaemon as the process and profile name:
2025-10-23T10:24:24.077Z audit[3773]: AVC apparmor="DENIED" operation="change_profile" info="label not found" error=-2 profile="DobbyDaemon" name="dobby_default" pid=3773 comm="DobbyDaemon"

This change removes the use of permprofile in favor of walking sysfs directories to determine if a profile is loaded. The logic prior to permprofile was to walk the apparmorfs profiles file and string search for the entry, however this operation slowed down container startup when the profiles list was large. The change here should occur in ~6-7ms compared to 40-50ms (per testing on-device by @goruklu) with the string search when 100 profiles are loaded.

Note that due to the nature of apparmorfs pseudofiles, these files can't be mmap()'d or used in other optimized loads, so those options were not viable.

The change assumes the following directory structure in apparmorfs, which was confirmed to exist in kernels 4.9 - 6.14 (and current):

root@Docsis-Gateway:~# ls /sys/kernel/security/apparmor/policy/profiles/ PolicyA.sp.1 PolicyB.141 PolicyC.45 PolicyD.138 PolicyE.101

It is important that the profile name be examined to ensure that it is followed with both a . and numeric value, to avoid conflicts with other profile naming schemes (mainly ending in .sp), hence the added conditions there.

This resolves part of https://ccp.sys.comcast.net/browse/DELIA-68521

Test Procedure
Verify DobbyDaemon is confined (cat /proc//attr/current), profile name should be DobbyDaemon
Verify dobby_default profile is NOT loaded (cat /sys/kernel/security/apparmor/profiles | grep dobby_default)
Attempt to start a container and measure startup time
Alternatively, the code can be put into a standalone stub and measure execution time using the same instructions above with >100 profiles loaded. The script below can be used to automatically create placeholder profiles:
`DIR="/tmp/test_profiles"
mkdir "$DIR"

for i in $(seq 1 100); do
file="$DIR/test_profile_$i"
printf 'profile test_profile%s flags=(complain) {\n\n}\n' "$i" > "$file"
done `

Removing dobby_default from the kernel ensures full iteration of the list occurs instead of stopping when a result is found, which should provide a more accurate measure of performance.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other (doesn't fit into the above categories - e.g. documentation updates)

Requires Bitbake Recipe changes?

  • The base Bitbake recipe (meta-rdk-ext/recipes-containers/dobby/dobby.bb) must be modified to support the changes in this PR (beyond updating SRC_REV)

Copilot AI review requested due to automatic review settings July 21, 2026 09:29
@github-actions

Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

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 Dobby’s AppArmor profile presence check to avoid triggering kernel audit logs introduced by the post-4.13 permprofile behavior, by switching to a sysfs directory walk under apparmorfs.

Changes:

  • Replace permprofile-based existence probing with a scan of /sys/kernel/security/apparmor/policy/profiles/.
  • Add stricter matching for profile names (<name>.<digit…>) to avoid collisions with similarly-prefixed profiles.
  • Add logging for “loaded” vs “not found” outcomes using the new mechanism.

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

Comment thread bundle/lib/source/DobbyConfig.cpp
Comment thread bundle/lib/source/DobbyConfig.cpp
Comment thread bundle/lib/source/DobbyConfig.cpp
@goruklu

goruklu commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@bsineath can you please sign the CLA ? this is a cherry-pick of the apparmor profile loading fix to an older branch.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants