Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3077762rwb; Mon, 15 Aug 2022 17:34:30 -0700 (PDT) X-Google-Smtp-Source: AA6agR6isfl9Psf1Q+/n/IGTCeTEt6Wviy/fEN5FC2+WAj2zx56oeR2D5NjH0VE0TPA8lYSJWGed X-Received: by 2002:a17:906:ee8e:b0:730:3646:d178 with SMTP id wt14-20020a170906ee8e00b007303646d178mr11957484ejb.426.1660610070477; Mon, 15 Aug 2022 17:34:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660610070; cv=none; d=google.com; s=arc-20160816; b=egYNeWkvw93TzBYevEVcAGcFIiVCtqkA0fLvD6nuwuT9zXxhRN353dvaaeGyPbpeFf D2W2aWmtTcc69CtFFRmpl/N+us6dNcaJ8wKsqm39OixphP9b3UcNQOKPppJnBgr0U4hw jiOmme5TjoeGa196R8PwPNAIGDsDmwcN1h9mqcTskOO2KTbnoiTySJVkgGs1kHxh/lC1 j/L7loutRf7RmCkuxzLoaodZTaN/rfl6BIGQX7y5cYA0pMrTnlQD2e6GvEzclebs+qf2 L0I19eHsmfJkwadKp7KnqTWtz4mVqm/8CD1T5W1ubXCT6iyJ2Qe1wkWXbs7eibfcZfCs Xy9g== 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=/UGfLmuzn3eu/JIeKalpiSB4NycEUl5O2HrzzksGPY0=; b=e6q/zGAzrbA9LJ0LxJzP0EnhysJtV34FlEo0mJwRNLIJHEVYQ5nw9xWbbZ6F6reUCA Wpsak2Kv+EoGtYq09OtQvwTSSG/AdXebiLvy+1laU6rLgMzQTN+XxpvuEyk6snP/Almt WD64jO0J7zPXqxxjpYef6mMnqWIz1uckKCdxZo3evimkZlI0Pp1egJDGPzXOKlPxxWp+ AJIEnBvYTv2DWznUHv9Zp/rlgV/QBtuG2JJrQ6O8yI7eL9dTZyE8mLCXa5f2ULfRflZl Xg3vhfA/krluEeMQuLAjMJRCiNd9+pemMVBln2N5QzuL5jgUQSmSClHyXjO0ehG1OaZK BIxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ECOBIbqY; 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 wz14-20020a170906fe4e00b007385dfb42c7si3083886ejb.565.2022.08.15.17.34.03; Mon, 15 Aug 2022 17:34:30 -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=ECOBIbqY; 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 S245546AbiHOVDN (ORCPT + 99 others); Mon, 15 Aug 2022 17:03:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346905AbiHOVBR (ORCPT ); Mon, 15 Aug 2022 17:01:17 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DFD1C7BAE; Mon, 15 Aug 2022 12:13:22 -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 sin.source.kernel.org (Postfix) with ESMTPS id 218E4CE12C8; Mon, 15 Aug 2022 19:13:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20C27C433C1; Mon, 15 Aug 2022 19:13:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660590799; bh=a31WYOj3u0YxhhWWPGE8uaQmFHl6yu7OQLekdTH58ts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ECOBIbqYy0GGof4UTsr4Kx2++7qIXuoVJqDKXtxzg8OFHh9wLVFE6jkF1RbQCJVPW GV1kUEue5u073QxfVOVwd7OYVR/SJO2Mc2JSxz2QHgXDMSTIXDSJQRo27hJLQpDvVH hn4FScFLU0l1fw0d2gUaCpnUsJT3McU2u38g2r5A= 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.18 0375/1095] media: hdpvr: fix error value returns in hdpvr_read Date: Mon, 15 Aug 2022 19:56:14 +0200 Message-Id: <20220815180445.221584739@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 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 __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