target-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gax-c <zichenxie0106@gmail.com>
To: james.smart@broadcom.com, ram.vegesna@broadcom.com,
	James.Bottomley@HansenPartnership.com,
	martin.petersen@oracle.com, fthain@linux-m68k.org,
	quic_jjohnson@quicinc.com, dwagner@suse.de, hare@suse.de
Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
	zzjas98@gmail.com, chenyuan0y@gmail.com,
	Zichen Xie <zichenxie0106@gmail.com>
Subject: [PATCH] scsi: elx: efct: Prevent potential integer overflow in efct_efclib_config()
Date: Sat, 19 Oct 2024 16:16:38 -0500	[thread overview]
Message-ID: <20241019211637.5533-1-zichenxie0106@gmail.com> (raw)

From: Zichen Xie <zichenxie0106@gmail.com>

This was found by a static analyzer.
There may be a potential integer overflow issue in
efct_efclib_config(). efc->max_xfer_size is defined
as "efc->max_xfer_size" while sli->sge_supported_length
and sli_get_max_sgl(&efct->hw.sli) are all "u32".
The result of the calculation will be limited to
"u32" without correct casting.
We recommend adding an extra cast to prevent
potential integer overflow.

Fixes: 4df84e846624 ("scsi: elx: efct: Driver initialization routines")
Signed-off-by: Zichen Xie <zichenxie0106@gmail.com>
---
 drivers/scsi/elx/efct/efct_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/elx/efct/efct_driver.c b/drivers/scsi/elx/efct/efct_driver.c
index 55d2301bfd7d..7fe180037c2d 100644
--- a/drivers/scsi/elx/efct/efct_driver.c
+++ b/drivers/scsi/elx/efct/efct_driver.c
@@ -109,7 +109,7 @@ efct_efclib_config(struct efct *efct, struct libefc_function_template *tt)
 	efc->log_level = EFC_LOG_LIB;
 
 	sli = &efct->hw.sli;
-	efc->max_xfer_size = sli->sge_supported_length *
+	efc->max_xfer_size = (u64)sli->sge_supported_length *
 			     sli_get_max_sgl(&efct->hw.sli);
 	efc->sli = sli;
 	efc->fcfi = efct->hw.fcf_indicator;
-- 
2.34.1


             reply	other threads:[~2024-10-19 21:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-19 21:16 Gax-c [this message]
2024-10-21  0:26 ` [PATCH] scsi: elx: efct: Prevent potential integer overflow in efct_efclib_config() Jeff Johnson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241019211637.5533-1-zichenxie0106@gmail.com \
    --to=zichenxie0106@gmail.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=chenyuan0y@gmail.com \
    --cc=dwagner@suse.de \
    --cc=fthain@linux-m68k.org \
    --cc=hare@suse.de \
    --cc=james.smart@broadcom.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=quic_jjohnson@quicinc.com \
    --cc=ram.vegesna@broadcom.com \
    --cc=target-devel@vger.kernel.org \
    --cc=zzjas98@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).