* [[PATCH v2]] transform strncpy into strscpy
@ 2025-04-02 19:40 Baris Can Goral
0 siblings, 0 replies; 2+ messages in thread
From: Baris Can Goral @ 2025-04-02 19:40 UTC (permalink / raw)
To: martin.petersen
Cc: linux-scsi, target-devel, linux-kernel, skhan,
linux-kernel-mentees, Baris Can Goral
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index c40217f44b1b..5c0b74e76be2 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -143,7 +143,7 @@ static ssize_t target_core_item_dbroot_store(struct config_item *item,
}
filp_close(fp, NULL);
- strncpy(db_root, db_root_stage, read_bytes);
+ strscpy(db_root, db_root_stage, read_bytes);
pr_debug("Target_Core_ConfigFS: db_root set to %s\n", db_root);
r = read_bytes;
@@ -3664,7 +3664,7 @@ static void target_init_dbroot(void)
}
filp_close(fp, NULL);
- strncpy(db_root, db_root_stage, DB_ROOT_LEN);
+ strscpy(db_root, db_root_stage, DB_ROOT_LEN);
pr_debug("Target_Core_ConfigFS: db_root set to %s\n", db_root);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH] change strncpy to strscpy strncpy is now depricated. It may not NUL-terminate the destination string, resulting in potential memory content exposures, unbounded reads, or crashes. Link: https://github.com/KSPP/linux/issues/90
@ 2025-04-02 17:25 goralbaris
2025-04-02 20:11 ` [[PATCH v2]] transform strncpy into strscpy Baris Can Goral
0 siblings, 1 reply; 2+ messages in thread
From: goralbaris @ 2025-04-02 17:25 UTC (permalink / raw)
To: martin.petersen
Cc: linux-scsi, target-devel, linux-kernel, skhan,
linux-kernel-mentees, goralbaris
Signed-off-by: goralbaris <goralbaris@gmail.com>
---
drivers/target/target_core_configfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index c40217f44b1b..5c0b74e76be2 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -143,7 +143,7 @@ static ssize_t target_core_item_dbroot_store(struct config_item *item,
}
filp_close(fp, NULL);
- strncpy(db_root, db_root_stage, read_bytes);
+ strscpy(db_root, db_root_stage, read_bytes);
pr_debug("Target_Core_ConfigFS: db_root set to %s\n", db_root);
r = read_bytes;
@@ -3664,7 +3664,7 @@ static void target_init_dbroot(void)
}
filp_close(fp, NULL);
- strncpy(db_root, db_root_stage, DB_ROOT_LEN);
+ strscpy(db_root, db_root_stage, DB_ROOT_LEN);
pr_debug("Target_Core_ConfigFS: db_root set to %s\n", db_root);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* [[PATCH v2]] transform strncpy into strscpy
2025-04-02 17:25 [PATCH] change strncpy to strscpy strncpy is now depricated. It may not NUL-terminate the destination string, resulting in potential memory content exposures, unbounded reads, or crashes. Link: https://github.com/KSPP/linux/issues/90 goralbaris
@ 2025-04-02 20:11 ` Baris Can Goral
0 siblings, 0 replies; 2+ messages in thread
From: Baris Can Goral @ 2025-04-02 20:11 UTC (permalink / raw)
To: martin.petersen
Cc: linux-scsi, target-devel, linux-kernel, skhan,
linux-kernel-mentees, Baris Can Goral
Description:
The strncpy() function is actively dangerous to use since it may not NULL-terminate the destination string,
resulting in potential memory content exposures, unbounded reads, or crashes.
Link: [1] https://github.com/KSPP/linux/issues/90
Changes from v2:
-Description added
-User Name corrected
Signed-off-by: Baris Can Goral <goralbaris@gmail.com>
---
drivers/target/target_core_configfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index c40217f44b1b..5c0b74e76be2 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -143,7 +143,7 @@ static ssize_t target_core_item_dbroot_store(struct config_item *item,
}
filp_close(fp, NULL);
- strncpy(db_root, db_root_stage, read_bytes);
+ strscpy(db_root, db_root_stage, read_bytes);
pr_debug("Target_Core_ConfigFS: db_root set to %s\n", db_root);
r = read_bytes;
@@ -3664,7 +3664,7 @@ static void target_init_dbroot(void)
}
filp_close(fp, NULL);
- strncpy(db_root, db_root_stage, DB_ROOT_LEN);
+ strscpy(db_root, db_root_stage, DB_ROOT_LEN);
pr_debug("Target_Core_ConfigFS: db_root set to %s\n", db_root);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-02 20:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-02 19:40 [[PATCH v2]] transform strncpy into strscpy Baris Can Goral
-- strict thread matches above, loose matches on Subject: below --
2025-04-02 17:25 [PATCH] change strncpy to strscpy strncpy is now depricated. It may not NUL-terminate the destination string, resulting in potential memory content exposures, unbounded reads, or crashes. Link: https://github.com/KSPP/linux/issues/90 goralbaris
2025-04-02 20:11 ` [[PATCH v2]] transform strncpy into strscpy Baris Can Goral
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox