Skip to content

Commit

Permalink
scsi: ses: Fix slab-out-of-bounds in ses_intf_remove()
Browse files Browse the repository at this point in the history
commit 578797f upstream.

A fix for:

BUG: KASAN: slab-out-of-bounds in ses_intf_remove+0x23f/0x270 [ses]
Read of size 8 at addr ffff88a10d32e5d8 by task rmmod/12013

When edev->components is zero, accessing edev->component[0] members is
wrong.

Link: https://lore.kernel.org/r/20230202162451.15346-5-thenzl@redhat.com
Cc: stable@vger.kernel.org
Signed-off-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
thenzl authored and gregkh committed Mar 10, 2023
1 parent 414418a commit 82143fa
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/scsi/ses.c
Expand Up @@ -856,7 +856,8 @@ static void ses_intf_remove_enclosure(struct scsi_device *sdev)
kfree(ses_dev->page2);
kfree(ses_dev);

kfree(edev->component[0].scratch);
if (edev->components)
kfree(edev->component[0].scratch);

put_device(&edev->edev);
enclosure_unregister(edev);
Expand Down

0 comments on commit 82143fa

Please sign in to comment.