[RFC PATCH] apparmor: honor the configured debug message default
Pengpeng Hou
hppiscas at 163.com
Fri Dec 4 02:07:10 UTC 2026
SECURITY_APPARMOR_DEBUG_MESSAGES promises to set the default of
apparmor.debug. The debug mask is instead zero-initialized regardless of
that option until a parameter is written.
The conversion from a boolean to a mask dropped the initializer that
used to follow this option.
Initialize the mask to the value the existing parameter parser uses for
Y when the option is enabled, and to DEBUG_NONE otherwise. Explicit
parameter values still override this initial value.
The issue was found by our static-analysis tool and manually reviewed.
Fixes: 71e6cff3e0dd ("apparmor: Improve debug print infrastructure")
Signed-off-by: Pengpeng Hou <hppiscas at 163.com>
---
Would you prefer to restore the documented boot-time default or remove
the ineffective option? Earlier proposals take the latter approach. This
version keeps the option; users who enable it get debug messages without
having to write the parameter after boot.
https://lore.kernel.org/r/20250514071400.465055-1-lukas.bulwahn@redhat.com
https://lore.kernel.org/r/20260905123450.5620-4-breno3011alves@gmail.com
The patch was prepared with Gemini and revised with Codex assistance
(Assisted-by: gpt 5).
Built lsm.o on x86-64 with GCC 11.4 and W=1. With
SECURITY_APPARMOR_DEBUG_MESSAGES=y, nm placed aa_g_debug in
zero-initialized storage before the fix and initialized data afterwards.
With the option off it stayed in zero-initialized storage. No boot or
runtime logging test was performed.
security/apparmor/lsm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
index eaebc3c60c5af8e7a86434cebbfe6ed9da968dc1..396f3947f35ee4fa9a08bacedc7df0e982c02250 100644
--- a/security/apparmor/lsm.c
+++ b/security/apparmor/lsm.c
@@ -1966,7 +1966,8 @@ module_param_named(rawdata_compression_level, aa_g_rawdata_compression_level,
aacompressionlevel, 0400);
/* Debug mode */
-int aa_g_debug;
+int aa_g_debug = IS_ENABLED(CONFIG_SECURITY_APPARMOR_DEBUG_MESSAGES) ?
+ DEBUG_ALL : DEBUG_NONE;
module_param_call(debug, param_set_debug, param_get_debug,
&aa_g_debug, 0600);
base-commit: d06ce6f1eb5eeffd4ebcfde345dc34a98131d106
More information about the Linux-security-module-archive
mailing list