From: John Johansen <john.johansen@canonical.com>
To: Thorsten Blum <thorsten.blum@linux.dev>,
Paul Moore <paul@paul-moore.com>,
James Morris <jmorris@namei.org>,
"Serge E. Hallyn" <serge@hallyn.com>
Cc: apparmor@lists.ubuntu.com, linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] apparmor: Use sysfs_emit in param_get_{audit,mode}
Date: Tue, 17 Mar 2026 23:29:58 -0700 [thread overview]
Message-ID: <add84d74-27af-45fb-8fe1-c172a2f21cfd@canonical.com> (raw)
In-Reply-To: <20260222214038.287814-1-thorsten.blum@linux.dev>
On 2/22/26 13:40, Thorsten Blum wrote:
> Replace sprintf() with sysfs_emit() in param_get_audit() and
> param_get_mode(). sysfs_emit() is preferred for formatting sysfs output
> because it provides safer bounds checking. Add terminating newlines as
> suggested by checkpatch.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Acked-by: John Johansen <john.johansen@canoncal.com>
I have pulled this into my tree
> ---
> security/apparmor/lsm.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
> index a87cd60ed206..1250192f7b12 100644
> --- a/security/apparmor/lsm.c
> +++ b/security/apparmor/lsm.c
> @@ -17,6 +17,7 @@
> #include <linux/ptrace.h>
> #include <linux/ctype.h>
> #include <linux/sysctl.h>
> +#include <linux/sysfs.h>
> #include <linux/audit.h>
> #include <linux/user_namespace.h>
> #include <linux/netfilter_ipv4.h>
> @@ -2081,7 +2082,7 @@ static int param_get_audit(char *buffer, const struct kernel_param *kp)
> return -EINVAL;
> if (apparmor_initialized && !aa_current_policy_view_capable(NULL))
> return -EPERM;
> - return sprintf(buffer, "%s", audit_mode_names[aa_g_audit]);
> + return sysfs_emit(buffer, "%s\n", audit_mode_names[aa_g_audit]);
> }
>
> static int param_set_audit(const char *val, const struct kernel_param *kp)
> @@ -2109,8 +2110,7 @@ static int param_get_mode(char *buffer, const struct kernel_param *kp)
> return -EINVAL;
> if (apparmor_initialized && !aa_current_policy_view_capable(NULL))
> return -EPERM;
> -
> - return sprintf(buffer, "%s", aa_profile_mode_names[aa_g_profile_mode]);
> + return sysfs_emit(buffer, "%s\n", aa_profile_mode_names[aa_g_profile_mode]);
> }
>
> static int param_set_mode(const char *val, const struct kernel_param *kp)
prev parent reply other threads:[~2026-03-18 6:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-22 21:40 Thorsten Blum
2026-03-18 6:29 ` John Johansen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=add84d74-27af-45fb-8fe1-c172a2f21cfd@canonical.com \
--to=john.johansen@canonical.com \
--cc=apparmor@lists.ubuntu.com \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=serge@hallyn.com \
--cc=thorsten.blum@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®