From nobody Tue Dec 16 12:16:58 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E037DC32792 for ; Fri, 19 Aug 2022 16:11:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351800AbiHSQKj (ORCPT ); Fri, 19 Aug 2022 12:10:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351206AbiHSQHu (ORCPT ); Fri, 19 Aug 2022 12:07:50 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA67C1ADBA; Fri, 19 Aug 2022 08:56:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6EADDB8280D; Fri, 19 Aug 2022 15:56:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C044FC433D6; Fri, 19 Aug 2022 15:56:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660924581; bh=a31WYOj3u0YxhhWWPGE8uaQmFHl6yu7OQLekdTH58ts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=twpV1CETAnptV2FXnMksPW2irnZRCMJjbxboiQxnP2qkT5IIdi9r8DuGwcKSxOmbq TmbzrCA+qj8HZwRvzEAv9FSOcEhWCPNjh5f5dPrcr9Yxv6KtNciKC+JWGZFgYLi3J4 jOAkthVIxBIk+RMJkDxC2qTgziaL8+GmcxE28zw8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Niels Dossche , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.10 186/545] media: hdpvr: fix error value returns in hdpvr_read Date: Fri, 19 Aug 2022 17:39:16 +0200 Message-Id: <20220819153837.686619755@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Niels Dossche [ Upstream commit 359c27c6ddbde404f44a9c0d3ec88ccd1e2042f2 ] Error return values are supposed to be negative in hdpvr_read. Most error returns are currently handled via an unsigned integer "ret". When setting a negative error value to "ret", the value actually becomes a large positive value, because "ret" is unsigned. Later on, the "ret" value is returned. But as ssize_t is a 64-bit signed number, the error return value stays a large positive integer instead of a negative integer. This can cause an error value to be interpreted as the read size, which can cause a buffer overread for applications relying on the returned size. Fixes: 9aba42efe85b ("V4L/DVB (11096): V4L2 Driver for the Hauppauge HD PVR= usb capture device") Signed-off-by: Niels Dossche Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/usb/hdpvr/hdpvr-video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpv= r/hdpvr-video.c index 60e57e0f1927..fd7d2a9d0449 100644 --- a/drivers/media/usb/hdpvr/hdpvr-video.c +++ b/drivers/media/usb/hdpvr/hdpvr-video.c @@ -409,7 +409,7 @@ static ssize_t hdpvr_read(struct file *file, char __use= r *buffer, size_t count, struct hdpvr_device *dev =3D video_drvdata(file); struct hdpvr_buffer *buf =3D NULL; struct urb *urb; - unsigned int ret =3D 0; + int ret =3D 0; int rem, cnt; =20 if (*pos) --=20 2.35.1