Skip to content

Commit 3b92d34

Browse files
azeemshaikh38kees
authored andcommitted
scsi: ibmvscsi: Replace all non-returning strlcpy with strscpy
strlcpy() reads the entire source buffer first. This read may exceed the destination size limit. This is both inefficient and can lead to linear read overflows if a source string is not NUL-terminated [1]. In an effort to remove strlcpy() completely [2], replace strlcpy() here with strscpy(). No return values were used, so direct replacement is safe. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy [2] KSPP#89 Signed-off-by: Azeem Shaikh <azeemshaikh38@gmail.com> Acked-by: Tyrel Datwyler <tyreld@linux.ibm.com> Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20230517143409.1520298-1-azeemshaikh38@gmail.com
1 parent 883f8fe commit 3b92d34

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/scsi/ibmvscsi/ibmvscsi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ static void gather_partition_info(void)
250250

251251
ppartition_name = of_get_property(of_root, "ibm,partition-name", NULL);
252252
if (ppartition_name)
253-
strlcpy(partition_name, ppartition_name,
253+
strscpy(partition_name, ppartition_name,
254254
sizeof(partition_name));
255255
p_number_ptr = of_get_property(of_root, "ibm,partition-no", NULL);
256256
if (p_number_ptr)
@@ -1282,12 +1282,12 @@ static void send_mad_capabilities(struct ibmvscsi_host_data *hostdata)
12821282
if (hostdata->client_migrated)
12831283
hostdata->caps.flags |= cpu_to_be32(CLIENT_MIGRATED);
12841284

1285-
strlcpy(hostdata->caps.name, dev_name(&hostdata->host->shost_gendev),
1285+
strscpy(hostdata->caps.name, dev_name(&hostdata->host->shost_gendev),
12861286
sizeof(hostdata->caps.name));
12871287

12881288
location = of_get_property(of_node, "ibm,loc-code", NULL);
12891289
location = location ? location : dev_name(hostdata->dev);
1290-
strlcpy(hostdata->caps.loc, location, sizeof(hostdata->caps.loc));
1290+
strscpy(hostdata->caps.loc, location, sizeof(hostdata->caps.loc));
12911291

12921292
req->common.type = cpu_to_be32(VIOSRP_CAPABILITIES_TYPE);
12931293
req->buffer = cpu_to_be64(hostdata->caps_addr);

0 commit comments

Comments
 (0)