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: Replace memcpy + NUL termination with kmemdup_nul in do_setattr

Use kmemdup_nul() to copy 'value' instead of using memcpy() followed by
a manual NUL termination. No functional changes.

Reviewed-by: Serge Hallyn <serge@hallyn.com>
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
46401cc9 8813837a

+1 -4
+1 -4
security/apparmor/lsm.c
··· 856 856 857 857 /* AppArmor requires that the buffer must be null terminated atm */ 858 858 if (args[size - 1] != '\0') { 859 - /* null terminate */ 860 - largs = args = kmalloc(size + 1, GFP_KERNEL); 859 + largs = args = kmemdup_nul(value, size, GFP_KERNEL); 861 860 if (!args) 862 861 return -ENOMEM; 863 - memcpy(args, value, size); 864 - args[size] = '\0'; 865 862 } 866 863 867 864 error = -EINVAL;