Message ID | 20221212015706.2609544-4-shinichiro.kawasaki@wdc.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | scsi: mpi3mr: fix issues found by KASAN | expand |
On 12/12/22 10:57, Shin'ichiro Kawasaki wrote: > The commit c1af985d27da ("scsi: mpi3mr: Add Event acknowledgment logic") > introduced an array mrioc->evtack_cmds. But initialization of the array > elements was missed. They are just zero cleared. The function > mpi3mr_complete_evt_ack refers host_tag field of the elements. Due to > zero value of the host_tag field, the functions calls clear_bit for > mrico->evtack_cmds_bitmap with wrong bit index. This results in memory > access to invalid address and "BUG: KASAN: use-after-free". This BUG was > observed at eHBA-9600 firmware update to version 8.3.1.0. To fix it, add > the missing initialization of mrioc->evtack_cmds. > > Fixes: c1af985d27da ("scsi: mpi3mr: Add Event acknowledgment logic") > Cc: stable@vger.kernel.org > Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com> Looks OK to me. Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> > --- > drivers/scsi/mpi3mr/mpi3mr_os.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c > index 3306de7170f6..6eaeba41072c 100644 > --- a/drivers/scsi/mpi3mr/mpi3mr_os.c > +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c > @@ -4952,6 +4952,10 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id) > mpi3mr_init_drv_cmd(&mrioc->dev_rmhs_cmds[i], > MPI3MR_HOSTTAG_DEVRMCMD_MIN + i); > > + for (i = 0; i < MPI3MR_NUM_EVTACKCMD; i++) > + mpi3mr_init_drv_cmd(&mrioc->evtack_cmds[i], > + MPI3MR_HOSTTAG_EVTACKCMD_MIN + i); > + > if (pdev->revision) > mrioc->enable_segqueue = true; >
diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 3306de7170f6..6eaeba41072c 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -4952,6 +4952,10 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id) mpi3mr_init_drv_cmd(&mrioc->dev_rmhs_cmds[i], MPI3MR_HOSTTAG_DEVRMCMD_MIN + i); + for (i = 0; i < MPI3MR_NUM_EVTACKCMD; i++) + mpi3mr_init_drv_cmd(&mrioc->evtack_cmds[i], + MPI3MR_HOSTTAG_EVTACKCMD_MIN + i); + if (pdev->revision) mrioc->enable_segqueue = true;
The commit c1af985d27da ("scsi: mpi3mr: Add Event acknowledgment logic") introduced an array mrioc->evtack_cmds. But initialization of the array elements was missed. They are just zero cleared. The function mpi3mr_complete_evt_ack refers host_tag field of the elements. Due to zero value of the host_tag field, the functions calls clear_bit for mrico->evtack_cmds_bitmap with wrong bit index. This results in memory access to invalid address and "BUG: KASAN: use-after-free". This BUG was observed at eHBA-9600 firmware update to version 8.3.1.0. To fix it, add the missing initialization of mrioc->evtack_cmds. Fixes: c1af985d27da ("scsi: mpi3mr: Add Event acknowledgment logic") Cc: stable@vger.kernel.org Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com> --- drivers/scsi/mpi3mr/mpi3mr_os.c | 4 ++++ 1 file changed, 4 insertions(+)