Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp917357pxb; Wed, 6 Apr 2022 04:13:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcVST7FkREOUkuFZwpZ0LcfQ4hkI5TlhTIvWEqI2W0AwoBbRZoIh/dOgbsHHZ+rNS0dZR2 X-Received: by 2002:a17:903:1c2:b0:154:5edf:56d3 with SMTP id e2-20020a17090301c200b001545edf56d3mr8284394plh.10.1649243610129; Wed, 06 Apr 2022 04:13:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649243610; cv=none; d=google.com; s=arc-20160816; b=WwmPAgS8DzKMwpK2e/o2/Xl/JaJuQXiAeaRcKYZCHvEIrgUdMruQylHmdUaPHvO1XS 7GZ1Z6pQWEodhNYtzzMat7fGDiJ57O+TuQslcEqOXDhHGEDaS/sqs7u7DqpN95tq+GXc UCbkJLmhVPODM7ojVSsZzcd5YeZQtXGarBN/LAy+XoeHQVmJwp8YCblRk6RuKU2b3wWc 0JXnW1ILd3QJyzJC7mlmGgAVECth82sKDJApe4Agub7mSaM/umJoK3365IJCTSFrjGyH FtVd49w8HoZkhsf86Swmt90in0elqPMSv/qdPTABfWj4zi7hNByee5zU13mj/leAP2Em Gi8w== 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=Adm59Zc+HhXAWofvx+o60/8JtXmd1yIsOuqHAWYmPts=; b=bk/a/B3giFzINnkPuSZtZr/bIy0XHJs4Wjw4qFE7cpYW7Lwq932Jvicvo1kUH1F0FP 5eaVph4mULXVcThK+EcgBigLH6WzAtc2O3673pqm48lv2v15dTK4NPrU0psgkWKxJsCH CZLkrOh/52aK1Zf0R0qFNb8JBZI2rCbK9sltq8tlsx6ldc8aFZcjrZM8oG4fzBqSfRx/ V/rWfVHflrQr1YEhXegTXwMpZeFSP1kFCQyhPiKCxTKmcsGMuwYya39sAAUbu6QAjk18 izXaGyAn3cPjVM0ikLDriaG2IVRzmIirANHXLjb+E4lUAMt7rDHLtyxW3GeZVhNl5R4b 3Oqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="h/6Jh1SY"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i18-20020a63d452000000b0039b618b2645si2097478pgj.345.2022.04.06.04.13.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 04:13:30 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="h/6Jh1SY"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BC02F5D504E; Wed, 6 Apr 2022 02:38:38 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344303AbiDEPW5 (ORCPT + 99 others); Tue, 5 Apr 2022 11:22:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347134AbiDEJqC (ORCPT ); Tue, 5 Apr 2022 05:46:02 -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 3A7477C17A; Tue, 5 Apr 2022 02:32:29 -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 C7F3261654; Tue, 5 Apr 2022 09:32:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7F05C385A6; Tue, 5 Apr 2022 09:32:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151148; bh=M2jeZD84b1fXWTSwEOBj+dahxynZt8zXMhkQqbDCQfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h/6Jh1SYARLQcuUt6MKbAQtMJfDKbVpmJKJRy9/n1ezrkangDGktyOyZ3hPjbt0rX Fndc8hMamaf1z7Nr+BGQFPwQaLYiRsrXpVksy9FuA7vKE0TE6lu/RJ5hpgjJyf+IYa BTDialA+FjQOViIqeS7ay8LKO7sIjJy4oI/jsFJ8= 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.15 311/913] media: video/hdmi: handle short reads of hdmi info frame. Date: Tue, 5 Apr 2022 09:22:53 +0200 Message-Id: <20220405070349.176245684@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 41f4e749a859..2217004264e4 100644 --- a/drivers/media/i2c/adv7511-v4l2.c +++ b/drivers/media/i2c/adv7511-v4l2.c @@ -544,7 +544,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 122e1fdccd96..d688ffff7a07 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 7f8acbdf0db4..8ab4c63839b4 100644 --- a/drivers/media/i2c/adv7842.c +++ b/drivers/media/i2c/adv7842.c @@ -2593,7 +2593,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