* [PATCH] scsi: qla2xxx: Fix off by one in qla_edif_app_getstats()
@ 2024-04-02 9:56 Dan Carpenter
2024-04-02 15:42 ` Himanshu Madhani
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2024-04-02 9:56 UTC (permalink / raw)
To: Quinn Tran
Cc: Nilesh Javali, GR-QLogic-Storage-Upstream, James E.J. Bottomley,
Martin K. Petersen, Himanshu Madhani, Larry Wisneski,
Duane Grigsby, linux-scsi, linux-kernel, kernel-janitors
The app_reply->elem[] array is allocated earlier in this function and it
has app_req.num_ports elements. Thus this > comparison needs to be >=
to prevent memory corruption.
Fixes: 7878f22a2e03 ("scsi: qla2xxx: edif: Add getfcinfo and statistic bsgs")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/scsi/qla2xxx/qla_edif.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/qla2xxx/qla_edif.c b/drivers/scsi/qla2xxx/qla_edif.c
index 26e6b3e3af43..dcde55c8ee5d 100644
--- a/drivers/scsi/qla2xxx/qla_edif.c
+++ b/drivers/scsi/qla2xxx/qla_edif.c
@@ -1100,7 +1100,7 @@ qla_edif_app_getstats(scsi_qla_host_t *vha, struct bsg_job *bsg_job)
list_for_each_entry_safe(fcport, tf, &vha->vp_fcports, list) {
if (fcport->edif.enable) {
- if (pcnt > app_req.num_ports)
+ if (pcnt >= app_req.num_ports)
break;
app_reply->elem[pcnt].rekey_count =
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] scsi: qla2xxx: Fix off by one in qla_edif_app_getstats()
2024-04-02 9:56 [PATCH] scsi: qla2xxx: Fix off by one in qla_edif_app_getstats() Dan Carpenter
@ 2024-04-02 15:42 ` Himanshu Madhani
2024-04-02 15:51 ` Himanshu Madhani
2024-04-06 1:58 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Himanshu Madhani @ 2024-04-02 15:42 UTC (permalink / raw)
To: Dan Carpenter
Cc: Quinn Tran, Nilesh Javali, GR-QLogic-Storage-Upstream,
James E.J. Bottomley, Martin Petersen, Larry Wisneski,
Duane Grigsby, linux-scsi, linux-kernel, kernel-janitors
> On Apr 2, 2024, at 02:56, Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> The app_reply->elem[] array is allocated earlier in this function and it
> has app_req.num_ports elements. Thus this > comparison needs to be >=
> to prevent memory corruption.
>
> Fixes: 7878f22a2e03 ("scsi: qla2xxx: edif: Add getfcinfo and statistic bsgs")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> drivers/scsi/qla2xxx/qla_edif.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/qla2xxx/qla_edif.c b/drivers/scsi/qla2xxx/qla_edif.c
> index 26e6b3e3af43..dcde55c8ee5d 100644
> --- a/drivers/scsi/qla2xxx/qla_edif.c
> +++ b/drivers/scsi/qla2xxx/qla_edif.c
> @@ -1100,7 +1100,7 @@ qla_edif_app_getstats(scsi_qla_host_t *vha, struct bsg_job *bsg_job)
>
> list_for_each_entry_safe(fcport, tf, &vha->vp_fcports, list) {
> if (fcport->edif.enable) {
> - if (pcnt > app_req.num_ports)
> + if (pcnt >= app_req.num_ports)
> break;
>
> app_reply->elem[pcnt].rekey_count =
> --
> 2.43.0
>
Looks Good.
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com <mailto:himanshu.madhani@oracle.com>>
--
Himanshu Madhani Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] scsi: qla2xxx: Fix off by one in qla_edif_app_getstats()
2024-04-02 9:56 [PATCH] scsi: qla2xxx: Fix off by one in qla_edif_app_getstats() Dan Carpenter
2024-04-02 15:42 ` Himanshu Madhani
@ 2024-04-02 15:51 ` Himanshu Madhani
2024-04-06 1:58 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Himanshu Madhani @ 2024-04-02 15:51 UTC (permalink / raw)
To: Dan Carpenter, Quinn Tran
Cc: Nilesh Javali, GR-QLogic-Storage-Upstream, James E.J. Bottomley,
Martin K. Petersen, Larry Wisneski, Duane Grigsby, linux-scsi,
linux-kernel, kernel-janitors
On 4/2/24 02:56, Dan Carpenter wrote:
> The app_reply->elem[] array is allocated earlier in this function and it
> has app_req.num_ports elements. Thus this > comparison needs to be >=
> to prevent memory corruption.
>
> Fixes: 7878f22a2e03 ("scsi: qla2xxx: edif: Add getfcinfo and statistic bsgs")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> drivers/scsi/qla2xxx/qla_edif.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/qla2xxx/qla_edif.c b/drivers/scsi/qla2xxx/qla_edif.c
> index 26e6b3e3af43..dcde55c8ee5d 100644
> --- a/drivers/scsi/qla2xxx/qla_edif.c
> +++ b/drivers/scsi/qla2xxx/qla_edif.c
> @@ -1100,7 +1100,7 @@ qla_edif_app_getstats(scsi_qla_host_t *vha, struct bsg_job *bsg_job)
>
> list_for_each_entry_safe(fcport, tf, &vha->vp_fcports, list) {
> if (fcport->edif.enable) {
> - if (pcnt > app_req.num_ports)
> + if (pcnt >= app_req.num_ports)
> break;
>
> app_reply->elem[pcnt].rekey_count =
Looks good.
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
--
Himanshu Madhani Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] scsi: qla2xxx: Fix off by one in qla_edif_app_getstats()
2024-04-02 9:56 [PATCH] scsi: qla2xxx: Fix off by one in qla_edif_app_getstats() Dan Carpenter
2024-04-02 15:42 ` Himanshu Madhani
2024-04-02 15:51 ` Himanshu Madhani
@ 2024-04-06 1:58 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2024-04-06 1:58 UTC (permalink / raw)
To: Quinn Tran, Dan Carpenter
Cc: Martin K . Petersen, Nilesh Javali, GR-QLogic-Storage-Upstream,
James E.J. Bottomley, Himanshu Madhani, Larry Wisneski,
Duane Grigsby, linux-scsi, linux-kernel, kernel-janitors
On Tue, 02 Apr 2024 12:56:54 +0300, Dan Carpenter wrote:
> The app_reply->elem[] array is allocated earlier in this function and it
> has app_req.num_ports elements. Thus this > comparison needs to be >=
> to prevent memory corruption.
>
>
Applied to 6.9/scsi-fixes, thanks!
[1/1] scsi: qla2xxx: Fix off by one in qla_edif_app_getstats()
https://git.kernel.org/mkp/scsi/c/4406e4176f47
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-06 1:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-02 9:56 [PATCH] scsi: qla2xxx: Fix off by one in qla_edif_app_getstats() Dan Carpenter
2024-04-02 15:42 ` Himanshu Madhani
2024-04-02 15:51 ` Himanshu Madhani
2024-04-06 1:58 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®