[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230811-arch-s390-kernel-v1-1-7edbeeab3809@google.com>
Date: Fri, 11 Aug 2023 21:56:15 +0000
From: Justin Stitt <justinstitt@...gle.com>
To: Heiko Carstens <hca@...ux.ibm.com>,
Vasily Gorbik <gor@...ux.ibm.com>,
Alexander Gordeev <agordeev@...ux.ibm.com>,
Christian Borntraeger <borntraeger@...ux.ibm.com>,
Sven Schnelle <svens@...ux.ibm.com>
Cc: linux-s390@...r.kernel.org, linux-kernel@...r.kernel.org,
Kees Cook <keescook@...omium.org>,
linux-hardening@...r.kernel.org,
Justin Stitt <justinstitt@...gle.com>
Subject: [PATCH] s390/ipl: refactor deprecated strncpy
`strncpy` is deprecated for use on NUL-terminated destination strings [1].
Use `strscpy_pad` which has the same behavior as `strncpy` here with the
extra safeguard of guaranteeing NUL-termination of destination strings.
In it's current form, this may result in silent truncation if the src
string has the same size as the destination string.
Link: www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings[1]
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@...r.kernel.org
Signed-off-by: Justin Stitt <justinstitt@...gle.com>
---
arch/s390/kernel/ipl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
index 85a00d97a314..a6dcf6f28197 100644
--- a/arch/s390/kernel/ipl.c
+++ b/arch/s390/kernel/ipl.c
@@ -266,7 +266,7 @@ static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj, \
struct kobj_attribute *attr, \
const char *buf, size_t len) \
{ \
- strncpy(_value, buf, sizeof(_value) - 1); \
+ strscpy_pad(_value, buf, sizeof(_value)); \
strim(_value); \
return len; \
} \
---
base-commit: 52a93d39b17dc7eb98b6aa3edb93943248e03b2f
change-id: 20230811-arch-s390-kernel-968d0545c45a
Best regards,
--
Justin Stitt <justinstitt@...gle.com>
Powered by blists - more mailing lists