Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3464095rwa; Tue, 23 Aug 2022 05:19:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR5exzpbwkxAtHh8v8Zl9zlIJ7ahlmv/S8M2m7CVw0R++W35bDOrMn8NazNyZCl+ANpokmd5 X-Received: by 2002:a63:8943:0:b0:429:ff66:34b2 with SMTP id v64-20020a638943000000b00429ff6634b2mr20042723pgd.3.1661257140345; Tue, 23 Aug 2022 05:19:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661257140; cv=none; d=google.com; s=arc-20160816; b=vwviI6fDuQdkLqNrNnknYTSiPS8wdfng2yNN8paOXQcRpL4AGCo1s/CcQv5Ab6f0bM WTC5MbH3CvfkYqXCfHpGp+AqGM60Ec1rrryc462eqBCDkdy3n1fD4uakSYgOueypfyAP AocDs+MGYnAXE7rR0gkRwS9gec0EheHTsf6HWlUigLV+YELG70Ugu676k96btOXIZLlu vSsGdZPCm4acYPbMET/FUqPBQ8uO/09y/u5GPsnhpRoeJeIqo77IC6WegUFm9xODP8HM f7QfgKubsYtzROj/8VGB0/hXaBYMJh1n4qralJKBFPJvwJ9GzKr5A1bVrIUqlP6Tvgul J/OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cozBecx2yODMSLvlV1Todyw+U3+5bB3Wn/jEy2CisVw=; b=X7jzwRJXT4IQvYY866y/JmNSGdinPgM8wxIf9MiEBksolJWKCmyM+Cg9F85ifFEd+B TvCVkU8geN67XQyZW/MtjvuGncwQlQeu/jiAicXMp/WbRUssBuv/1dXkR0IDroXPY5gR 3vI/xBRtydGtdNSiLX6kf8QEXfBNFoTScPdXNaD/N0voL/bsnFZT7GimaLMtjvGZEx5a i3vGgAh5B+J/zVNfJCpL8+3uFWSfGZT2pE0EVoLTW6jzGqmfC2uN2bhN49S7iHoTbHtt BZgYUuMdoeBTlrdvB0dV7DiCs0jhkMcEM9yaR3YK+TqZ4RyhoBmMf0FDuZ+pzgD53gV1 ptYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x5iZYdaB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a170902f2cb00b00172d70c26a8si8405247plc.154.2022.08.23.05.18.49; Tue, 23 Aug 2022 05:19:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x5iZYdaB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355997AbiHWKlP (ORCPT + 99 others); Tue, 23 Aug 2022 06:41:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354706AbiHWK0L (ORCPT ); Tue, 23 Aug 2022 06:26:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1443074CE9; Tue, 23 Aug 2022 02:05:36 -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 BFFE1B81C66; Tue, 23 Aug 2022 09:05:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CAF2C433C1; Tue, 23 Aug 2022 09:05:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245533; bh=EQPwvuYJOs0V7yD6Lmh7EPf+O5KCLFrmcfzQApKHzAQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x5iZYdaB7ELYS//QvLisalM0F9qKTdqun50VTu7RoAd5i17FmfZ5o5sLBgN4NPloQ aZ5wQooidcvC3+TYGLVaeoYiV6NPhmoQNMAIrQsohxSRxrRDPK//BkH5kjW3dLLTmH jR47aKItPDYcrHQ0y9kgyJQW04jAYx4tEvsMD+y4= 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 4.19 077/287] media: hdpvr: fix error value returns in hdpvr_read Date: Tue, 23 Aug 2022 10:24:06 +0200 Message-Id: <20220823080102.838414734@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/hdpvr/hdpvr-video.c index ce46f8721470..1fb2cdd9c4b2 100644 --- a/drivers/media/usb/hdpvr/hdpvr-video.c +++ b/drivers/media/usb/hdpvr/hdpvr-video.c @@ -413,7 +413,7 @@ static ssize_t hdpvr_read(struct file *file, char __user *buffer, size_t count, struct hdpvr_device *dev = video_drvdata(file); struct hdpvr_buffer *buf = NULL; struct urb *urb; - unsigned int ret = 0; + int ret = 0; int rem, cnt; if (*pos) -- 2.35.1