DF-1442 / fix.diff
diff --git a/sys/dev/disk/ahci/ahci_cam.c b/sys/dev/disk/ahci/ahci_cam.c --- a/sys/dev/disk/ahci/ahci_cam.c +++ b/sys/dev/disk/ahci/ahci_cam.c @@ -1129,9 +1129,14 @@ /* * Use the vendor specific area to set the TRIM status - * for scsi_da + * for scsi_da. The short Domain Validation inquiry buffer + * (e.g. SID_ADDITIONAL_LENGTH+5 bytes) does not extend past + * vendor_specific1, so make sure we have room before writing + * to avoid corrupting the adjacent slab object. */ - if (at->at_identify.support_dsm) { + if (at->at_identify.support_dsm && + rdata_len >= offsetof(struct scsi_inquiry_data, + vendor_specific1) + 2) { rdata->inquiry_data.vendor_specific1[0] = at->at_identify.support_dsm &ATA_SUPPORT_DSM_TRIM; rdata->inquiry_data.vendor_specific1[1] = |