]> www.infradead.org Git - users/hch/misc.git/commitdiff
module: Replace deprecated strncpy() with strscpy()
authorThorsten Blum <thorsten.blum@linux.dev>
Fri, 7 Mar 2025 11:35:47 +0000 (12:35 +0100)
committerPetr Pavlu <petr.pavlu@suse.com>
Mon, 10 Mar 2025 10:56:03 +0000 (11:56 +0100)
strncpy() is deprecated for NUL-terminated destination buffers; use
strscpy() instead. The destination buffer ownername is only used with
"%s" format strings and must therefore be NUL-terminated, but not NUL-
padded.

No functional changes intended.

Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://lore.kernel.org/r/20250307113546.112237-2-thorsten.blum@linux.dev
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
kernel/module/main.c

index 81ecb9d3a93530a59f71bbbd987d0eef1245de9a..e1ed5d82f45feb8dabfa4bbdbbc90e8d9c15368d 100644 (file)
@@ -1179,7 +1179,7 @@ static const struct kernel_symbol *resolve_symbol(struct module *mod,
 
 getname:
        /* We must make copy under the lock if we failed to get ref. */
-       strncpy(ownername, module_name(fsa.owner), MODULE_NAME_LEN);
+       strscpy(ownername, module_name(fsa.owner), MODULE_NAME_LEN);
 unlock:
        mutex_unlock(&module_mutex);
        return fsa.sym;