mirror of
https://github.com/torvalds/linux.git
synced 2026-01-25 15:03:52 +08:00
RISC-V: cpu: refactor deprecated strncpy
`strncpy` is deprecated for use on NUL-terminated destination strings [1]. Favor not copying strings onto stack and instead use strings directly. This avoids hard-coding sizes and buffer lengths all together. Link: https://github.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Suggested-by: Kees Cook <keescook@chromium.org> Signed-off-by: Justin Stitt <justinstitt@google.com> Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com> Acked-by: Palmer Dabbelt <palmer@rivosinc.com> Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Link: https://lore.kernel.org/r/20230802-arch-riscv-kernel-v2-1-24266e85bc96@google.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
This commit is contained in:
committed by
Palmer Dabbelt
parent
54670b59cf
commit
12d61a1bc2
@@ -222,21 +222,21 @@ static void print_isa(struct seq_file *f)
|
||||
|
||||
static void print_mmu(struct seq_file *f)
|
||||
{
|
||||
char sv_type[16];
|
||||
const char *sv_type;
|
||||
|
||||
#ifdef CONFIG_MMU
|
||||
#if defined(CONFIG_32BIT)
|
||||
strncpy(sv_type, "sv32", 5);
|
||||
sv_type = "sv32";
|
||||
#elif defined(CONFIG_64BIT)
|
||||
if (pgtable_l5_enabled)
|
||||
strncpy(sv_type, "sv57", 5);
|
||||
sv_type = "sv57";
|
||||
else if (pgtable_l4_enabled)
|
||||
strncpy(sv_type, "sv48", 5);
|
||||
sv_type = "sv48";
|
||||
else
|
||||
strncpy(sv_type, "sv39", 5);
|
||||
sv_type = "sv39";
|
||||
#endif
|
||||
#else
|
||||
strncpy(sv_type, "none", 5);
|
||||
sv_type = "none";
|
||||
#endif /* CONFIG_MMU */
|
||||
seq_printf(f, "mmu\t\t: %s\n", sv_type);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user