Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3404885rwa; Tue, 23 Aug 2022 04:20:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR5XwZqIF4ByxRLuFe0amCTcNk7qXe3TjtO//q/ixJDr5T7HtbtyfzrRUqcvywkpkN/UOO39 X-Received: by 2002:a63:8449:0:b0:42a:fc54:a437 with SMTP id k70-20020a638449000000b0042afc54a437mr969296pgd.496.1661253641807; Tue, 23 Aug 2022 04:20:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253641; cv=none; d=google.com; s=arc-20160816; b=BU2QbKNyarOJCJ1s2oon3SuNNHhy1eI79BFehT/QzcHYZ9fyKrEy3f4JnGuy4Qf49J fVGhLkgiqHQXGlTwb+KSeG6rq6aQWJpL9JzFdXTN8KBm6lTAaa9fFsnMxE3b77gvKnGQ W5jooezc9xDdt3zzL9rBuJks7UCsCQHFJ2RT6LbYcIJX9pHH/ips7wg0e3tXiSBDjxbB 968V/k0sn4xprThtJn+aKEuTqJLt4UIjuVdB7gx9QERSM1THBx9uG4L9us89egx1FQUD vdyPE03HRA2rYBQwQmztc6mhMXSYPtzRXvhs2lZ6v7LizNhE7N3z9lX9N/2lHV9LrlSj Fwfg== 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=O6trwy9nXM4r7Eq54qFD0z6Fb3oxXZXdui/4EDnHWEo=; b=uj0ZvvFe0UZdRAcYTv/qutUMh2oQXOoYPbTnQOk0nfcmUxnzUWxcrHDFR0cSKHojpo tWo/ZGOqSsn1Z2KLttbgZjSQyg7OKH+BrZYVAVtPgDGPQkyq7IbevGJd+CeUUx6h378J wGIl5yDLg8K6LgJqgTcqncHxuXFrKN4aFJ8rm6q3zfCCaIKyYHh2Okpq44pxVODYH06O bkLnm17zXFsPBIn3BkfFWQpIgylw7X42JG3n6xXSUGy0JjqEQfgkEJqY3FwoL3b+my7S nLNGEaHnv7lXTn/GVkr8jAwStiCu6+JT5c31/thlLFl5/8N2EKrKbFZo/v6WAI5tshTv +ipA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XQmJUufW; 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 z13-20020a17090a1fcd00b001f7b6192be1si12362194pjz.25.2022.08.23.04.20.30; Tue, 23 Aug 2022 04:20:41 -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=XQmJUufW; 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 S1351505AbiHWJjo (ORCPT + 99 others); Tue, 23 Aug 2022 05:39:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351689AbiHWJim (ORCPT ); Tue, 23 Aug 2022 05:38:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB43225EB1; Tue, 23 Aug 2022 01:41:06 -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 dfw.source.kernel.org (Postfix) with ESMTPS id D11D16153C; Tue, 23 Aug 2022 08:39:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B084AC433D6; Tue, 23 Aug 2022 08:39:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243999; bh=3nNFgxHraRJWA0ShV22x8RUpKDKlePeNDiV/IlDMamg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XQmJUufWNUijtmn5P/GDwEbN+d+WfmB9xU8INGKmbJ4rffpVfEXLB85N8Wa2cHWSM liD/nOlxM1VIZD1QKqQYnLiJ30FPXVS6D9T75s7/2EPmiLsJZPTbGXBkwgDc3F0Dkz jyaRVG12Ign2O+Kf7djQ0ifEklCM+gU+28q3BY+s= 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.14 066/229] media: hdpvr: fix error value returns in hdpvr_read Date: Tue, 23 Aug 2022 10:23:47 +0200 Message-Id: <20220823080056.079825043@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080053.202747790@linuxfoundation.org> References: <20220823080053.202747790@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 1cecb37e16d2..59bd44736fae 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