Skip to content

Commit

Permalink
module: Replace deprecated strncpy() with strscpy()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Thorsten Blum authored and Petr Pavlu committed Mar 10, 2025
1 parent 3690f4a commit 6380bf8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/module/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6380bf8

Please sign in to comment.