Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

apparmor: Use sysfs_emit in param_get_{audit,mode}

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>
Signed-off-by: John Johansen <john.johansen@canonical.com>

authored by

Thorsten Blum and committed by
John Johansen
497ad4be e6a522c5

+3 -3
+3 -3
security/apparmor/lsm.c
··· 17 17 #include <linux/ptrace.h> 18 18 #include <linux/ctype.h> 19 19 #include <linux/sysctl.h> 20 + #include <linux/sysfs.h> 20 21 #include <linux/audit.h> 21 22 #include <linux/user_namespace.h> 22 23 #include <linux/netfilter_ipv4.h> ··· 2065 2064 return -EINVAL; 2066 2065 if (apparmor_initialized && !aa_current_policy_view_capable(NULL)) 2067 2066 return -EPERM; 2068 - return sprintf(buffer, "%s", audit_mode_names[aa_g_audit]); 2067 + return sysfs_emit(buffer, "%s\n", audit_mode_names[aa_g_audit]); 2069 2068 } 2070 2069 2071 2070 static int param_set_audit(const char *val, const struct kernel_param *kp) ··· 2093 2092 return -EINVAL; 2094 2093 if (apparmor_initialized && !aa_current_policy_view_capable(NULL)) 2095 2094 return -EPERM; 2096 - 2097 - return sprintf(buffer, "%s", aa_profile_mode_names[aa_g_profile_mode]); 2095 + return sysfs_emit(buffer, "%s\n", aa_profile_mode_names[aa_g_profile_mode]); 2098 2096 } 2099 2097 2100 2098 static int param_set_mode(const char *val, const struct kernel_param *kp)