Skip to content

Commit 0b84780

Browse files
keesakpm00
authored andcommitted
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. Link: KSPP#90 [1] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]> Acked-by: Catalin Marinas <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 53dabce commit 0b84780

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mm/kmemleak.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -657,10 +657,10 @@ static struct kmemleak_object *__alloc_object(gfp_t gfp)
657657
/* task information */
658658
if (in_hardirq()) {
659659
object->pid = 0;
660-
strncpy(object->comm, "hardirq", sizeof(object->comm));
660+
strscpy(object->comm, "hardirq");
661661
} else if (in_serving_softirq()) {
662662
object->pid = 0;
663-
strncpy(object->comm, "softirq", sizeof(object->comm));
663+
strscpy(object->comm, "softirq");
664664
} else {
665665
object->pid = current->pid;
666666
/*
@@ -669,7 +669,7 @@ static struct kmemleak_object *__alloc_object(gfp_t gfp)
669669
* dependency issues with current->alloc_lock. In the worst
670670
* case, the command line is not correct.
671671
*/
672-
strncpy(object->comm, current->comm, sizeof(object->comm));
672+
strscpy(object->comm, current->comm);
673673
}
674674

675675
/* kernel backtrace */

0 commit comments

Comments
 (0)