Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3080231rwb; Mon, 15 Aug 2022 17:38:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR7R/1NN3rj6TmzbjSc50r2pLOFykfvDGbfxm5K/Yx24zz5QwfgAU7mSANcmoiaGcy/mridy X-Received: by 2002:a17:907:a046:b0:730:9c7a:eab3 with SMTP id gz6-20020a170907a04600b007309c7aeab3mr12334825ejc.285.1660610289425; Mon, 15 Aug 2022 17:38:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660610289; cv=none; d=google.com; s=arc-20160816; b=uTqCwoj5KIYSasGEcOT4fHvMM4gaUEStkDHITtlSkAPKwyDYA9FZbzpZzYM4MtIuky 3fbpKdbGxCBnQppPOEcs55ETVMF45eZCDaByIwJBDCCWioJmp4KtWFu3ZzaWCx+hFW4q Qslw1I7mqubCGnDSHXt7k9lWaQ6cb4uvKKnpJZAF+8bDSC5ZZeZdpHdnmgfHvWmi9uLv 3CVWsSoUBXJB72JnZy7mkBvQRJxwgJ0RhUGpuAAPHn9aF4zWUkzjVzmp3pr2XdVmpxmj +vpDONO78CfP+JFDVdWanQeuwMMC59KWIMx/+J6GHG/mi9Om5Y/V9Xh7WwhHG5H6ojek mOnw== 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=fnWSnKIcHRELcCUmpW6uZJMoO40FgvmWAGpVZ3QdR9fiFsBll7WUWgj+hYEvRsGon/ crIC8H99PEljoDJ2xIgXExYel1vEASL3xs9D4wG5P18hk1TX/gV4cvqloKTo2HEbuzR0 /7kEwfnb8bvV5HWufCthouRjBYNjv8rGfYMea6q2jsGdIMe3u11N175A3tB//GHNmRYF l2So80deMflNuiXUT2AWNVM06zS5iZcdR/I3+eBFJfE0L6O1xfEn6uv3C+YjF6KcbjEg Zcp99991GKUPY0IAfe5OIZN+XCkYS6MevMsBLd2zGwpZmOBncZ+DYh3aZN3J6LL/SZ4Z 7Nog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sopqvlTK; 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 gt6-20020a1709072d8600b007309efc29a4si12723568ejc.691.2022.08.15.17.37.43; Mon, 15 Aug 2022 17:38:09 -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=sopqvlTK; 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 S1344413AbiHOXn3 (ORCPT + 99 others); Mon, 15 Aug 2022 19:43:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354091AbiHOXlK (ORCPT ); Mon, 15 Aug 2022 19:41:10 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49859103C5A; Mon, 15 Aug 2022 13:10:35 -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 75E24CE12E7; Mon, 15 Aug 2022 20:10:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B79EC433D6; Mon, 15 Aug 2022 20:10:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660594231; bh=a31WYOj3u0YxhhWWPGE8uaQmFHl6yu7OQLekdTH58ts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sopqvlTKODPpyJkTHgXP/fl7IGbcrb6q+p5rZTM9t4mqaQs8PI6CG6MD1YeuJk9V7 lUOmi9MXRzEVMt69g+ra3pEgrr0PepBItuY5bxejPh/lwc72PcxhU386dIiE/rKkaX cGd5CECUIQjcCP+qb9o98PMdOpq5rlgdxzRJBoHA= 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.19 0398/1157] media: hdpvr: fix error value returns in hdpvr_read Date: Mon, 15 Aug 2022 19:55:54 +0200 Message-Id: <20220815180455.590092009@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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