From: sashiko-bot@kernel.org
To: zhangchujun <zhangchujun@cmss.chinamobile.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: leapraid: fix off-by-one in reply frame address validation
Date: Fri, 20 Nov 2026 08:38:25 +0000 [thread overview]
Message-ID: <sashiko-outbox-224751@kernel.org> (raw)
In-Reply-To: <20261120083000.1961-1-zhangchujun@cmss.chinamobile.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] scsi: leapraid: bad reply bounds in
leapraid_request_descript_handler()
--
commit b7ba75a759881f8671081c0b0994098d97d3921e
Author: zhangchujun <zhangchujun@cmss.chinamobile.com>
scsi: leapraid: fix off-by-one in reply frame address validation
This commit changes the upper bound check on the firmware reply frame
DMA address in leapraid_request_descript_handler() from > to >=.
> diff --git a/drivers/scsi/leapraid/leapraid_func.c b/drivers/scsi/leapraid/leapraid_func.c
> index 573bccf1a4cea..c54797e22e744 100644
> --- a/drivers/scsi/leapraid/leapraid_func.c
> +++ b/drivers/scsi/leapraid/leapraid_func.c
> @@ -5667,7 +5667,7 @@ static void leapraid_request_descript_handler(
> break;
> case LEAPRAID_RPY_DESC_FLG_ADDRESS_REPLY:
> rep = le32_to_cpu(rpf->addr_rep.rep_frame_addr);
> - if (rep > (u32)adapter->mem_desc.rep_msg_dma +
> + if (rep >= (u32)adapter->mem_desc.rep_msg_dma +
> adapter->adapter_attr.rep_msg_qd *
> LEAPRAID_REPLY_SIZE ||
> rep < (u32)adapter->mem_desc.rep_msg_dma)
[Severity: Medium]
Can rep still cause an out-of-bounds read and DMA write past
adapter->mem_desc.rep_msg if the firmware returns an address within the
last LEAPRAID_REPLY_SIZE - 1 bytes of the buffer or at an unaligned
offset?
Each reply frame is LEAPRAID_REPLY_SIZE (128) bytes, and
leapraid_init_rep_msg_addr() populates rep_msg_addr[] with addresses at
multiples of LEAPRAID_REPLY_SIZE up to rep_msg_dma + (rep_msg_qd - 1) *
LEAPRAID_REPLY_SIZE. An address in the trailing 127 bytes still passes
this check, causing completion handlers such as
leapraid_driver_cmds_done() to read up to LEAPRAID_REPLY_SIZE bytes past
the end of rep_msg and reposting rep to rep_msg_addr[] for firmware DMA.
Should this also verify that (rep - (u32)adapter->mem_desc.rep_msg_dma)
is a multiple of LEAPRAID_REPLY_SIZE?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120083000.1961-1-zhangchujun@cmss.chinamobile.com?part=1
prev parent reply other threads:[~2026-11-20 8:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 8:30 [PATCH] scsi: leapraid: fix off-by-one in reply frame address validation zhangchujun
2026-11-20 8:38 ` sashiko-bot [this message]
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=sashiko-outbox-224751@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zhangchujun@cmss.chinamobile.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