mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
ALSA: firewire: isight: bound the sample count to the packet payload
commit29b9667982upstream. isight_packet() takes the frame count from the device iso packet and checks it only against the device claimed iso length. count = be32_to_cpu(payload->sample_count); if (likely(count <= (length - 16) / 4)) isight_samples(isight, payload->samples, count); length is the iso header data_length. It can be up to 0xffff. So the gate allows a count up to about 16379. isight_samples() then copies count frames out of payload->samples into the PCM DMA buffer. payload->samples holds only 2 * MAX_FRAMES_PER_PACKET values. The device multiplexes two samples per frame. A count past MAX_FRAMES_PER_PACKET reads past the payload. A count past the buffer size writes past runtime->dma_area. The smallest PCM buffer is larger than MAX_FRAMES_PER_PACKET. Bounding the count to MAX_FRAMES_PER_PACKET keeps both the read and the write in range. A malicious or faulty Apple iSight on the FireWire bus reaches this during a normal capture. Add the MAX_FRAMES_PER_PACKET bound to the gate. Fixes:3a691b28a0("ALSA: add Apple iSight microphone driver") Suggested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Cc: stable@vger.kernel.org Signed-off-by: Maoyi Xie <maoyixie.tju@gmail.com> Link: https://patch.msgid.link/178205454729.1900991.7807310178296762772@maoyixie.com Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
7531a37720
commit
3ed2fa1ed8
@@ -179,7 +179,8 @@ static void isight_packet(struct fw_iso_context *context, u32 cycle,
|
||||
if (likely(length >= 16 &&
|
||||
payload->signature == cpu_to_be32(0x73676874/*"sght"*/))) {
|
||||
count = be32_to_cpu(payload->sample_count);
|
||||
if (likely(count <= (length - 16) / 4)) {
|
||||
if (likely(count <= (length - 16) / 4 &&
|
||||
count <= MAX_FRAMES_PER_PACKET)) {
|
||||
total = be32_to_cpu(payload->sample_total);
|
||||
if (unlikely(total != isight->total_samples)) {
|
||||
if (!isight->first_packet)
|
||||
|
||||
Reference in New Issue
Block a user