Page MenuHomeFreeBSD

scsi_cd: Improve TOC access validation
ClosedPublic

Authored by markj on Nov 2 2021, 1:43 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Jan 23, 5:54 AM
Unknown Object (File)
Dec 7 2024, 2:35 AM
Unknown Object (File)
Dec 6 2024, 5:02 PM
Unknown Object (File)
Nov 12 2024, 5:19 AM
Unknown Object (File)
Nov 11 2024, 11:31 PM
Unknown Object (File)
Nov 6 2024, 8:19 PM
Unknown Object (File)
Nov 2 2024, 4:50 AM
Unknown Object (File)
Oct 31 2024, 12:02 AM
Subscribers

Details

Summary
  1. During CD probing, we read the TOC header to find the number of entries, then read the TOC itself. The header determines the number of entries, which determines the amount of data to read from the device into the softc in the CD_STATE_MEDIA_TOC_FULL state. We hard-code a limit of 99 tracks (plus one for the lead-out) in the softc, but were not validating that the size reported by the media would fit in this hard-coded limit. Kernel memory corruption would occur if not.[1] Add validation to check this.
  1. The CDIOCPLAYTRACKS ioctl uses caller provided track numbers to index into the TOC, but we only validate the starting index. Add validation of the ending index.

Also, raise the hard-coded limit from 100 tracks to 170, per a
suggestion from Ken.

Reported by: C Turt <ecturt@gmail.com> [1]

Test Plan

I verified that I'm able to read the TOC from an audio CD as before. I tried
lowering the hard-coded limit to a small number and verified that we now
clear the CD_FLAG_VALID_TOC flag when probing a CD during boot, whereas
before we'd panic.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable