[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230831162227.2307863-1-smostafa@google.com>
Date: Thu, 31 Aug 2023 16:22:27 +0000
From: Mostafa Saleh <smostafa@...gle.com>
To: catalin.marinas@....com, will@...nel.org,
linux-kernel@...r.kernel.org, kvmarm@...ts.linux.dev,
linux-arm-kernel@...ts.infradead.org
Cc: maz@...nel.org, oliver.upton@...ux.dev, kristina.martsenko@....com,
broonie@...nel.org, quic_pkondeti@...cinc.com, smostafa@...gle.com,
justinstitt@...gle.com
Subject: [PATCH] Revert "arm64/sysreg: refactor deprecated strncpy"
This reverts commit d232606773a0b09ec7f1ffc25f63abe801d011fd.
Using strscpy is not correct in this context and the commit
assumption is not right "strncpy is deprecated for use on
NUL-terminated destination strings".
strncpy is used here to copy parts of the string(cmdline) separated
by spaces into the buffer and not a NULL terminated string.
This breaks the arm options "kvm-arm.mode=protected, arm64.nobti ..."
Signed-off-by: Mostafa Saleh <smostafa@...gle.com>
---
arch/arm64/kernel/idreg-override.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/kernel/idreg-override.c b/arch/arm64/kernel/idreg-override.c
index aee12c75b738..2fe2491b692c 100644
--- a/arch/arm64/kernel/idreg-override.c
+++ b/arch/arm64/kernel/idreg-override.c
@@ -262,9 +262,9 @@ static __init void __parse_cmdline(const char *cmdline, bool parse_aliases)
if (!len)
return;
- len = strscpy(buf, cmdline, ARRAY_SIZE(buf));
- if (len == -E2BIG)
- len = ARRAY_SIZE(buf) - 1;
+ len = min(len, ARRAY_SIZE(buf) - 1);
+ strncpy(buf, cmdline, len);
+ buf[len] = 0;
if (strcmp(buf, "--") == 0)
return;
--
2.42.0.rc2.253.gd59a3bf2b4-goog
Powered by blists - more mailing lists