From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29C72223DEF; Mon, 23 Jun 2025 22:02:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750716164; cv=none; b=oHXra+udCpqfYGKs6/DtH1h3MGzIiBBb2MSfWxo2Zgp9haZBr7WTd7hl1aiLPBr+kJsnwt760/mACiMTICmtmU0MsEq8J4HN2jyDYxwBq3GpJP0FUUjHEb5tl67KHQ1hosCh8iQNdeXLuSl0aR83sje2UQBkRTpmGZ4Z6zYd8EI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750716164; c=relaxed/simple; bh=r3FGzPaOGeyN4tEz0VFKjCkGKXIbtyZi207vcVDo6yQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uI/W6USz4IxBlLRC/2im8eo2nJeooZPCqiR5Sn3IrSzLxGJV+HNi8/YR1cs4i+RYF9kMOxgXW+ocmODhMSwYgwkaNVTy+hqPIZt2tYwoPLGwm3betzF3MSzgjm0sIGcr+EC27JyAPAM84JXSEvR7uVdnVg+XuTUor8S4pFAGm8c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=fEoTzebZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="fEoTzebZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B64C6C4CEEA; Mon, 23 Jun 2025 22:02:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750716164; bh=r3FGzPaOGeyN4tEz0VFKjCkGKXIbtyZi207vcVDo6yQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fEoTzebZfphhoG2rjEUoMFEnTZnbchw6VCh0bs/C5f2aKA6nfOLilqMiH/iZQRN1v MdcXCktkJh8yhx2SaRp7g1gWWr6pdvaYeAuLAyvxuRX9BMs2gMl+2HeMD8wagI2R2z uRAIpOIL2f7Xt2v1F8nBE9TMkA9QQCFU1FPSwdjk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Daniel Wagner , Justin Tee , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.15 332/411] scsi: lpfc: Use memcpy() for BIOS version Date: Mon, 23 Jun 2025 15:07:56 +0200 Message-ID: <20250623130642.009018202@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250623130632.993849527@linuxfoundation.org> References: <20250623130632.993849527@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Daniel Wagner [ Upstream commit ae82eaf4aeea060bb736c3e20c0568b67c701d7d ] The strlcat() with FORTIFY support is triggering a panic because it thinks the target buffer will overflow although the correct target buffer size is passed in. Anyway, instead of memset() with 0 followed by a strlcat(), just use memcpy() and ensure that the resulting buffer is NULL terminated. BIOSVersion is only used for the lpfc_printf_log() which expects a properly terminated string. Signed-off-by: Daniel Wagner Link: https://lore.kernel.org/r/20250409-fix-lpfc-bios-str-v1-1-05dac9e51e13@kernel.org Reviewed-by: Justin Tee Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/lpfc/lpfc_sli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 68b015bb6d157..fb139e1e35ca3 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -5926,9 +5926,9 @@ lpfc_sli4_get_ctl_attr(struct lpfc_hba *phba) phba->sli4_hba.flash_id = bf_get(lpfc_cntl_attr_flash_id, cntl_attr); phba->sli4_hba.asic_rev = bf_get(lpfc_cntl_attr_asic_rev, cntl_attr); - memset(phba->BIOSVersion, 0, sizeof(phba->BIOSVersion)); - strlcat(phba->BIOSVersion, (char *)cntl_attr->bios_ver_str, + memcpy(phba->BIOSVersion, cntl_attr->bios_ver_str, sizeof(phba->BIOSVersion)); + phba->BIOSVersion[sizeof(phba->BIOSVersion) - 1] = '\0'; lpfc_printf_log(phba, KERN_INFO, LOG_SLI, "3086 lnk_type:%d, lnk_numb:%d, bios_ver:%s, " -- 2.39.5