mm/kmemleak: Replace strncpy() with strscpy()
Subsystems (2)
PATCH 1/1 mm/kmemleak: Replace strncpy() with strscpy()
Replace the depreciated[1] strncpy() calls with strscpy(). Uses of object->comm do not depend on the padding side-effect.
Signed-off-by Kees Cook <[email protected]>
---
Cc: Catalin Marinas <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: [email protected]
--- mm/kmemleak.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
mm/kmemleak.c +3 -3
@@ -657,10 +657,10 @@ static struct kmemleak_object *__alloc_object(gfp_t gfp)/* task information */ if (in_hardirq ()) { object->pid =0 ; -strncpy (object->comm,"hardirq" ,sizeof (object->comm)); +strscpy (object->comm,"hardirq" ); }else if (in_serving_softirq ()) { object->pid =0 ; -strncpy (object->comm,"softirq" ,sizeof (object->comm)); +strscpy (object->comm,"softirq" ); }else { object->pid = current->pid;/*
@@ -669,7 +669,7 @@ static struct kmemleak_object *__alloc_object(gfp_t gfp)* dependency issues with current->alloc_lock. In the worst * case, the command line is not correct. */ -strncpy (object->comm, current->comm,sizeof (object->comm)); +strscpy (object->comm, current->comm); }/* kernel backtrace */
Signature · 1 line
2.34.1
Quoted 5 lines · Kees Cook
Replace the depreciated[1]
strncpy()calls withstrscpy(). Uses ofobject->commdo not depend on the padding side-effect.Signed-off-by Kees Cook <[email protected]>
Acked-by Catalin Marinas <[email protected]>
(usually Andrew picks the kmemleak patches up)