Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp701255pxb; Tue, 5 Apr 2022 19:23:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyM8XJ2B15GiHoU5UdUdKZyupAyYnLRl+ZM6KI+qjbpmOer5UNS3FnoEMqUiOYuWm5E8q32 X-Received: by 2002:a17:90b:1d02:b0:1c7:1802:c00e with SMTP id on2-20020a17090b1d0200b001c71802c00emr7378046pjb.99.1649211819595; Tue, 05 Apr 2022 19:23:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649211819; cv=none; d=google.com; s=arc-20160816; b=hK7UA9c5/+L5atVw/0EEoJ47glOocsvFHl4X/REP51iDxLXy/6miH0TPw9v9X6ZYzY gQdF375dGwsSdTB5fsYw9MT20t1wWOPKnQ8SL1aP9ixCi9OlmXDhXJ4g1S/vKst5gPGH lX5bUs+59CTJnFRIuq1pfmRfVQohcGO7Hz10ucektxu090MGeOG5EpEgIfzxL7MulTgv 2Sjl+9JieH7eXNgwJ0tFBv7ehuc3UqMgAa/JHmgAZgMSmT3DzGJqVz0Jq1D35LnJiJnC G9roOfZ8dLkeaIBxyjVJDfhiTsstoiA1nhT23Ub1UOnwAIkcbMwHJDEIwJ5+tqApQaPg yFeA== 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=LJ31sQrF+Wv0srLjr744LMEy6wWw2RR7Swrmit1sb4Q=; b=cwihv3oVQKQQVzyW8ZVxkOnnEjb2toiEO5KEC1VyRrf/z/nlbL12M0aiFCpgM6U7ru jujVr+Gp493ZnzDabYPFWMxXR14AInnmAFmN4unI4PYQcjbN5pV03oUENeJJZMexV3HO PeWlc0r1KAwbzGtxjCmZlnS0G5iRkyzOPpxAQv0aOTlmt/W4RveosRTTjNt71z5+VW9e mqd1xIwZNEpqllkJ3yW59Rsyeml0zGEckrAny0aFztxqh6TuQKAjUl4f965nfqVHqzOD MOaHe1aH9BvXW9G9Dzp1NdKSGXt0jqQVDs8Remvj39YpsCQ87I2r8h7ngrAo6Z8+Vltl q67w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RG2+ob9S; 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 b4-20020a056a00114400b004fa3a8dff78si15321247pfm.47.2022.04.05.19.23.23; Tue, 05 Apr 2022 19:23:39 -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=RG2+ob9S; 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 S235449AbiDEIhv (ORCPT + 99 others); Tue, 5 Apr 2022 04:37:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235483AbiDEH7r (ORCPT ); Tue, 5 Apr 2022 03:59:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A0BA5EBF7; Tue, 5 Apr 2022 00:54:40 -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 9A0AA615CD; Tue, 5 Apr 2022 07:54:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9659C340EE; Tue, 5 Apr 2022 07:54:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649145279; bh=CaPjrMepGUncNKEa4UU9hfroCy8AfZBlohBfmt7mJRc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RG2+ob9Ss4wn53+iaaEpZ5t+vaivVsL6hqvUfRmETHmvK1Q+MceoNq+CA0HwlerVx FvSP8T5yprh1D4WAVpuMVgFOvdGSjLDIjL0vL/jc83n8AsBmYy5mZ6HJxoQUeD0oO5 Vx23JoxP4GkdSptBp3pxFpMcT7XJw5W5dsBErZIs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tom Rix , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.17 0350/1126] media: video/hdmi: handle short reads of hdmi info frame. Date: Tue, 5 Apr 2022 09:18:17 +0200 Message-Id: <20220405070417.902302808@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@linuxfoundation.org> User-Agent: quilt/0.66 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: Tom Rix [ Upstream commit 4a92fc6e55da5b87cecb572275deaff6ac9dd27e ] Calling hdmi_infoframe_unpack() with static sizeof(buffer) skips all the size checking done later in hdmi_infoframe_unpack(). A better value is the amount of data read into buffer. Fixes: 480b8b3e42c3 ("video/hdmi: Pass buffer size to infoframe unpack functions") Signed-off-by: Tom Rix Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/i2c/adv7511-v4l2.c | 2 +- drivers/media/i2c/adv7604.c | 2 +- drivers/media/i2c/adv7842.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/adv7511-v4l2.c b/drivers/media/i2c/adv7511-v4l2.c index 8e13cae40ec5..db7f41a80770 100644 --- a/drivers/media/i2c/adv7511-v4l2.c +++ b/drivers/media/i2c/adv7511-v4l2.c @@ -522,7 +522,7 @@ static void log_infoframe(struct v4l2_subdev *sd, const struct adv7511_cfg_read_ buffer[3] = 0; buffer[3] = hdmi_infoframe_checksum(buffer, len + 4); - if (hdmi_infoframe_unpack(&frame, buffer, sizeof(buffer)) < 0) { + if (hdmi_infoframe_unpack(&frame, buffer, len + 4) < 0) { v4l2_err(sd, "%s: unpack of %s infoframe failed\n", __func__, cri->desc); return; } diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c index a2fa408d2d9f..bb0c8fc6d383 100644 --- a/drivers/media/i2c/adv7604.c +++ b/drivers/media/i2c/adv7604.c @@ -2484,7 +2484,7 @@ static int adv76xx_read_infoframe(struct v4l2_subdev *sd, int index, buffer[i + 3] = infoframe_read(sd, adv76xx_cri[index].payload_addr + i); - if (hdmi_infoframe_unpack(frame, buffer, sizeof(buffer)) < 0) { + if (hdmi_infoframe_unpack(frame, buffer, len + 3) < 0) { v4l2_err(sd, "%s: unpack of %s infoframe failed\n", __func__, adv76xx_cri[index].desc); return -ENOENT; diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c index 9d6eed0f8281..22caa070273b 100644 --- a/drivers/media/i2c/adv7842.c +++ b/drivers/media/i2c/adv7842.c @@ -2583,7 +2583,7 @@ static void log_infoframe(struct v4l2_subdev *sd, const struct adv7842_cfg_read_ for (i = 0; i < len; i++) buffer[i + 3] = infoframe_read(sd, cri->payload_addr + i); - if (hdmi_infoframe_unpack(&frame, buffer, sizeof(buffer)) < 0) { + if (hdmi_infoframe_unpack(&frame, buffer, len + 3) < 0) { v4l2_err(sd, "%s: unpack of %s infoframe failed\n", __func__, cri->desc); return; } -- 2.34.1