linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/kmemleak: Replace strncpy() with strscpy()
@ 2024-07-10  0:13 Kees Cook
  2024-07-11 18:08 ` Catalin Marinas
  0 siblings, 1 reply; 2+ messages in thread
From: Kees Cook @ 2024-07-10  0:13 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Kees Cook, Andrew Morton, linux-mm, linux-kernel, linux-hardening

Replace the depreciated[1] strncpy() calls with strscpy(). Uses of
object->comm do not depend on the padding side-effect.

Link: https://github.com/KSPP/linux/issues/90 [1]
Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
---
 mm/kmemleak.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index d5b6fba44fc9..764b08100570 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -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 */
-- 
2.34.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm/kmemleak: Replace strncpy() with strscpy()
  2024-07-10  0:13 [PATCH] mm/kmemleak: Replace strncpy() with strscpy() Kees Cook
@ 2024-07-11 18:08 ` Catalin Marinas
  0 siblings, 0 replies; 2+ messages in thread
From: Catalin Marinas @ 2024-07-11 18:08 UTC (permalink / raw)
  To: Kees Cook; +Cc: Andrew Morton, linux-mm, linux-kernel, linux-hardening

On Tue, Jul 09, 2024 at 05:13:08PM -0700, Kees Cook wrote:
> Replace the depreciated[1] strncpy() calls with strscpy(). Uses of
> object->comm do not depend on the padding side-effect.
> 
> Link: https://github.com/KSPP/linux/issues/90 [1]
> Signed-off-by: Kees Cook <kees@kernel.org>

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

(usually Andrew picks the kmemleak patches up)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-11 18:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-10  0:13 [PATCH] mm/kmemleak: Replace strncpy() with strscpy() Kees Cook
2024-07-11 18:08 ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox