From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1DB03D994 for ; Sun, 21 Jun 2026 15:09:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782054554; cv=none; b=vGXj0S3Oi8hK39Ybtx2u1eJ08EmTVcQTD74swJ0DxkqIIFeQh+LQHSnQ8U3VdomrlrWVnZr0HgYbUC9bwB3m9b0cER50p3khotqoPXMQwlPB0rCG/XQOFEVBWhdcZtmrmaE6wgg1Kg28weXHaEyy8JkPflI5NbNC1USCaa7TmXM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782054554; c=relaxed/simple; bh=bGe6auSy2bAcoq3YNv8c9FdmMy0rUqHqUQJP0+7B/4I=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=gWgWiORX1bSbaChqY7Totm3gvAWFLx7g4044xonGzQxQ5kg7Vui/6Lr+tkrqsvK3nAGvNh5n9wl+ju5x4ZUcGHh2r9RU/yzRiLGAWlNM4UIjCV4yHCgZuU7vO3c6hB/aJhjGh0AMD7zHJ4D/JLcl8luLrdzlybzgSbgPLWeYdSA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iymBW88s; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iymBW88s" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-8453f568e84so3307771b3a.0 for ; Sun, 21 Jun 2026 08:09:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782054551; x=1782659351; darn=vger.kernel.org; h=mime-version:content-transfer-encoding:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=31UQCBSl6VHtaj4HbZ4B9yytESDTf5UVo9IslisOCfo=; b=iymBW88s6DFkORO2NjBKYBMyjdgoeAhgh/RIkmiBNJqEfpW/0J5lkS9uEMjJIIHU3S S1XmS2IRuUap9pHKxe2yD/Iv/4MzUQ6pBBua2V1DPpV9iaX8cogQKFxXIfpcVFn1isYN mjVYpAWalscVvkZEx51eE4vIwpS4zbKu6/ozsoJmzP/rEtgvC2c0GkQhqJl6Cy4aMN4S +UbZVx/dcWQ/3Oic026e9O/7byKGdOBURartKX1OcTI+C2NncQv+BhGXG1E703vxBXft IxR4tYO9Q64MAUYw0E8hoKd36y1DRkNWpLystu5dNx7DoG6aduClg3crH72FWU22fjjN AP+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782054551; x=1782659351; h=mime-version:content-transfer-encoding:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=31UQCBSl6VHtaj4HbZ4B9yytESDTf5UVo9IslisOCfo=; b=M2/gIgJPNK6YHg6SnV+sSxdEy3WSP9Zd7sjnX/jwZEqbLtYFiKyLAisXGyopbqM3z5 Icf9xhoIazFqZ771Y+aSLAyU1//bZD/sqEONoe4SzzKDa9KAveSO//vlJpKnbFcSyFuA X47KQ/RqcwSnnJyNwaIimNe28vyOyzYQZfsxQHKDQJgNBdIAPQlbMmHSNXPc20mx1iBO /TazdTKgL9W0Gcj04ITxRgxNTs6lu4170Fr9Yg15naMwAiJ8blicA7dE37tU00A3Ur+P jlGRf1I/yDNbNIaxgrKArgh8Y7TA1EOCgecThZDb2f2kGtTL5JYdmXCXlcbx/r1PDWXD 1YGA== X-Forwarded-Encrypted: i=1; AFNElJ+q/PQMc68s5brkKMHa/g8jJh1VgzBrKiNYuegqN2u88RdDyPhgnrIUQagfETHrj/plYaz1lVTW8g5pDKc=@vger.kernel.org X-Gm-Message-State: AOJu0YwqlhfC5gy/3nWHyBwcvZInkYNrAqt9xtwqlc0/nnJE5zMUWTVt lfa8O7UR9AcUCN2aTwMi8ywMMQCb7/LDmNgncdbEjX1farRONYSDHh87/zUtnA== X-Gm-Gg: AfdE7cnmF3P3fLoc/6ZEXv8MwcxeWoszh5RLfQuo+u26KXm729GmNmDeUbaoBxc0AXh 6MOf/PSVU2DFB3jx4SOUU1Iwg85gvTQY5y9QjRbTeE4mZZXX/lluSiZDuc2rKtVCPnfM4Xlo9zU +xej//5UqiIn0q6xCY5t3rATuhFRRz+1nRI3LaN4yR7T7JOoqqHUjedlNMny8buv0mxc1FwhpHu IRyYx4sfvc+n8hb66E9C/6mQ2Yu9Ynx57SczUcYYwWPuttrKSRN05xozf1C+eeaRkLM4wqwlRMe o0aCiESnKe9fcigdo4Ieh0X6bKyLSghZOwEtEeUSYlEYwGNdAySlH5/L3FEF+USmwINpWTRKhZx rCgNp+2IcbJ+/NmmcACuAR07kDVVH5TboRtt9Q4uMXDwXpIrq4RFcG6Q6f6lmiXky9w4ECcfH4G 8wZrzIV8WdyNQUddD5IXmqakZZfWtQXe9JOe5YoA== X-Received: by 2002:a05:6a00:2294:b0:835:45bf:9660 with SMTP id d2e1a72fcca58-845561b605emr11255355b3a.42.1782054550938; Sun, 21 Jun 2026 08:09:10 -0700 (PDT) Received: from csl-conti-dell7858.ntu.edu.sg ([155.69.195.57]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84564e74727sm4840334b3a.39.2026.06.21.08.09.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jun 2026 08:09:10 -0700 (PDT) From: Maoyi Xie To: Clemens Ladisch , Takashi Sakamoto Cc: Jaroslav Kysela , Takashi Iwai , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] ALSA: firewire: isight: bound the sample count to the packet payload Date: Sun, 21 Jun 2026 23:09:07 +0800 Message-ID: <178205454729.1900991.7807310178296762772@maoyixie.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 3a691b28a0ca ("ALSA: add Apple iSight microphone driver") Suggested-by: Takashi Sakamoto Cc: stable@vger.kernel.org Signed-off-by: Maoyi Xie --- sound/firewire/isight.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c index 2b7f071d593b..33c9dd48b3b0 100644 --- a/sound/firewire/isight.c +++ b/sound/firewire/isight.c @@ -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) -- 2.34.1