From nobody Sat Feb 7 17:04:33 2026 Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) (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 2422428690 for ; Mon, 22 Dec 2025 05:47:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766382430; cv=none; b=QllXks5d+Ati38iq+CL+c04ubhhZSOtnzeVyRNrAiEBYrIj550gmdF6xWMe8aE1mJKJ2Zd/TuxnFoRqL9JKEqp/vLZlo4FAdlc+UAC4+c6AourYU6bvPqmHbe/nPRo71JEBxeG1WOq0Ql8ZV346f0ySt53pXRTw/lDl4NXjarHk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766382430; c=relaxed/simple; bh=bZp3B3M4jF0rhysmuvRdz/3MaRGTf3rUPfhGnxSYlu0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZDWqGkpWk+ZN+b548rjHhbpxNiK+RIKPXAWvvS7QDoUeKLAy4mmG5KaFaLeeTDSg1x5JODQ4EwOX6BMypJ+70AJ1CBBp6NXJjWmnBkV8Vd/+WJJcOJBr1F3IvUKniz/azhxV2Ova6jsfnV1Q6/Dr1m5zYKEaiXJxA1RmoXv1MGE= 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=MBMujDzw; arc=none smtp.client-ip=209.85.160.174 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="MBMujDzw" Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-4f34c5f2f98so41498851cf.1 for ; Sun, 21 Dec 2025 21:47:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766382428; x=1766987228; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J5O0+56Coz2B7LcGuChi784ewUGuX6sSWh6JiztntsY=; b=MBMujDzwbzPaNzrevctbAx2JAucG4P78ywerkxrghMrgkE4NPYaNXub+M7C5/5L5FP PcajY3uz6hIVcziXxM/jiTuhZFP2UUpNa1c4TUyFVv/c9K5VcTt9/DwIIZks/DEQViQT JK507S4LCF26e9MSX432PGTyE7LPYw985jF/hcwJPNLM6Wc1zzUYAiOV5HwXC2KZK/Md 5P1ASnNatKAvAPaMDJJOQLd2VHH+byTO0UCp76r2mVvuxmN7IdE8WWfJdw8yscQanLBU L6auJPMl0TLK0aOIZgpldm5QHnY92hp0GpCaVBTe0gvSl061qRu2HdNL4qjUDFbqRPKR I1DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766382428; x=1766987228; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=J5O0+56Coz2B7LcGuChi784ewUGuX6sSWh6JiztntsY=; b=aGIJh4601oNDgV9Iy/d2EwF02Bm8K2EJlmqcurUc86Bh/IHgXYnqrN3/zqWVvfvj70 LWdhCvPCR1UTM7yM850tixrhSmuK1g6mLZKvF3MP+h/iIOBndiSEYY1EK3hLN1ZmDQNy AOU0LMk1TdJ7gmJda+6U0MmkHAksFV+aYEH+lbrQ3WPL1l+kjuz1DbY8TIRmaRcpO8xI 0NpcW6AarBzCNvJpkv+jH5Fv9JXDHPgeQnrnf/bG7HRO6adFVtdrq9+oGhUZCMW/ltBn XPgNpbHZfOoNfNNmn0yuKsKM8ioAF8HEu/y5L8adL0rc3eC4MZ6WoylMlvihrApl8xSB kHxA== X-Forwarded-Encrypted: i=1; AJvYcCX2niY9eLUcoGICt7eExZ+DGj6ju+G0iyGIl8XGiDw/XafVDpLmEglOojG3graROjPH9+/6yuHtmLoKR2E=@vger.kernel.org X-Gm-Message-State: AOJu0YzQTQd02DSktE05xt4nvB+ceBHijgXX6RBwj7VVlfSL1vf6+7ob dK7+mJe22mV4HgZUgwVdSLhin6u41UGDW2OyCWUMVxUWDgczsCR1HL9g X-Gm-Gg: AY/fxX5LUXAWUfHa2I3jeHHXqvrar4p7uhhiOZ1CXVkQShAgfgZsAOcN+J1fq6yhVo0 nDla1xccRaXqzDKUUFlDbs0/WJa/27LVBm1yN0VHe0lOxaufYwAEBMfWyTiIa81H9461mOz43Lw P5CKT+ptDA77P0H2ap+ba+T3NF//dzqAwmY9BSPqJfUmhNHak7V9lvuZUjdmgq+Wy18t6Yc7Nez zJ6siUsRsE0qBfRsVtaSN5tQM5SuKZbbLCtLTnrLu2sZBP+Y8mt0WULv+4CqJd49P/4qH67zzyH DmvRDhdMo73Pwj6pWU3PUeztY+ISMxFMxAhN1Q5UlWSXuJPIhdXAPdUbpOuSKDsjNVWI47rvmBZ 58+mDwGsY/W0sAowapLgGEwJALrklVqMFYfmLhfFhonLQgtjgkKaw6OQwOdkKbKE2NrjJ66T3ou ZIjFOn5eHrtEkFlY+uiU0aAP0puHcC85Wmjv0cdUlcADwmVWNLA790rjSw2Fwn3whiz9MEMXbPd VZbXk+OqooTlJKdEooASc9ed+WNnlsbW9V0kbSIgA== X-Google-Smtp-Source: AGHT+IFuqRyXN12/t7Apv0AtBlIrZWa/o5aPY93pmyxOGgZLK6Cfew8XTFlELI+JhpHCe4WrbDHhLg== X-Received: by 2002:a05:622a:180e:b0:4ee:268f:baa2 with SMTP id d75a77b69052e-4f4abd01701mr162379141cf.27.1766382427983; Sun, 21 Dec 2025 21:47:07 -0800 (PST) Received: from seungjin-HP-ENVY-Desktop-TE02-0xxx.dartmouth.edu ([129.170.197.82]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4f4ac66841bsm67948781cf.30.2025.12.21.21.47.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Dec 2025 21:47:06 -0800 (PST) From: pip-izony To: Mauro Carvalho Chehab Cc: Seungjin Bae , Kyungtae Kim , Sanghoon Choi , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] media: ttusb-dec: fix heap-buffer-overflow in ttusb_dec_process_urb_frame() Date: Mon, 22 Dec 2025 00:46:45 -0500 Message-ID: <20251222054644.938208-2-eeodqql09@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251222002019.882867-2-eeodqql09@gmail.com> References: <20251222002019.882867-2-eeodqql09@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Seungjin Bae The `ttusb_dec_process_urb_frame()` parses the PVA packet from the USB device. However, it doesn't check whether the calculated `packet_payload_length` exceeds the size of the `packet` buffer. The `packet` buffer has a fixed size of `MAX_PVA_LENGTH + 4`. However, `packet_payload_length` is derived from 2 bytes of the input data, allowing a maximum value of 65543 bytes (8 + 0xFFFF). If a malicious USB device sends a packet with crafted data, it triggers a heap buffer overflow. This allows an attacker to overwrite adjacent fields in the `struct ttusb_dec`. Specifically, the `a_pes2ts` field, which contains a callback function pointer, is located after the `packet` buffer. Overwriting this pointer can lead to control flow hijacking. Fix this by adding a bounds check for the parsed length against the buffer size. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Co-developed-by: Sanghoon Choi Signed-off-by: Sanghoon Choi Signed-off-by: Seungjin Bae --- v1 -> v2: Change warning function =20 drivers/media/usb/ttusb-dec/ttusb_dec.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/ttusb-dec/ttusb_dec.c b/drivers/media/usb/tt= usb-dec/ttusb_dec.c index b4575fe89c95..0e983783e787 100644 --- a/drivers/media/usb/ttusb-dec/ttusb_dec.c +++ b/drivers/media/usb/ttusb-dec/ttusb_dec.c @@ -703,10 +703,19 @@ static void ttusb_dec_process_urb_frame(struct ttusb_= dec *dec, u8 *b, =20 if (dec->packet_type =3D=3D TTUSB_DEC_PACKET_PVA && dec->packet_length =3D=3D 8) { - dec->packet_state++; - dec->packet_payload_length =3D 8 + + int len =3D 8 + (dec->packet[6] << 8) + dec->packet[7]; + + if (len > MAX_PVA_LENGTH + 4) { + dev_warn(&dec->udev->dev, + "%s: packet too long - discarding\n" + __func__); + dec->packet_state =3D 0; + } else { + dec->packet_state++; + dec->packet_payload_length =3D len; + } } else if (dec->packet_type =3D=3D TTUSB_DEC_PACKET_SECTION && dec->packet_length =3D=3D 5) { --=20 2.43.0