Linux Security Modules development
 help / color / mirror / Atom feed
* [RFC PATCH] apparmor: honor the configured debug message default
@ 2026-12-04  2:07 Pengpeng Hou
  2026-12-04  2:21 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-12-04  2:07 UTC (permalink / raw)
  To: John Johansen, Georgia Garcia, Paul Moore, James Morris,
	Serge E. Hallyn
  Cc: apparmor, linux-security-module, Pengpeng Hou, Lukas Bulwahn

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@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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RFC PATCH] apparmor: honor the configured debug message default
  2026-12-04  2:07 [RFC PATCH] apparmor: honor the configured debug message default Pengpeng Hou
@ 2026-12-04  2:21 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-04  2:21 UTC (permalink / raw)
  Cc: linux-security-module

> 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@163.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/179635003085.74470.10701182849877618986@163.com?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-04  2:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04  2:07 [RFC PATCH] apparmor: honor the configured debug message default Pengpeng Hou
2026-12-04  2:21 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox