Skip to content

Commit 8453e79

Browse files
azeemshaikh38kees
authored andcommitted
soc: fsl: qe: 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> Reviewed-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20230523021425.2406309-1-azeemshaikh38@gmail.com Signed-off-by: Kees Cook <keescook@chromium.org>
1 parent ce66167 commit 8453e79

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • drivers/soc/fsl/qe

drivers/soc/fsl/qe/qe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ int qe_upload_firmware(const struct qe_firmware *firmware)
524524
* saved microcode information and put in the new.
525525
*/
526526
memset(&qe_firmware_info, 0, sizeof(qe_firmware_info));
527-
strlcpy(qe_firmware_info.id, firmware->id, sizeof(qe_firmware_info.id));
527+
strscpy(qe_firmware_info.id, firmware->id, sizeof(qe_firmware_info.id));
528528
qe_firmware_info.extended_modes = be64_to_cpu(firmware->extended_modes);
529529
memcpy(qe_firmware_info.vtraps, firmware->vtraps,
530530
sizeof(firmware->vtraps));
@@ -599,7 +599,7 @@ struct qe_firmware_info *qe_get_firmware_info(void)
599599
/* Copy the data into qe_firmware_info*/
600600
sprop = of_get_property(fw, "id", NULL);
601601
if (sprop)
602-
strlcpy(qe_firmware_info.id, sprop,
602+
strscpy(qe_firmware_info.id, sprop,
603603
sizeof(qe_firmware_info.id));
604604

605605
of_property_read_u64(fw, "extended-modes",

0 commit comments

Comments
 (0)