[v5,01/12] media: platform: mtk-mdp3: fix potential frame size overflow in mdp_try_fmt_mplane()
Message ID | 20230113064104.22402-2-moudy.ho@mediatek.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp122422wrt; Thu, 12 Jan 2023 22:59:20 -0800 (PST) X-Google-Smtp-Source: AMrXdXvKo9BRABAMEg15HEb4kcUb8jxFh+3xNyfFTv1U9RDb62+iAhc3GXhzYwfcmafue1O3xI4b X-Received: by 2002:a17:907:9a89:b0:7c0:e5dd:6e5f with SMTP id km9-20020a1709079a8900b007c0e5dd6e5fmr2458746ejc.4.1673593160626; Thu, 12 Jan 2023 22:59:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673593160; cv=none; d=google.com; s=arc-20160816; b=hf6NFBZcw/O2XJgHxk3DTcamqhHbZcRzwwXIyx8CxV9NgLEMhxSk2lapm7dJ674mLP 2L4r4ewMQFOaf9BFj9A8c/8Ryt2tr4+PTTUBpARxp+XFx2Vh4qMWNhTLNxBg0DxNfsjj faLmKlsPW9JEOeqiK9wf3ss0ehxIHbI0MeX2YSXWVVNA3r3lpjj/17FaE8eWLMZnvT6H RwIfU3TPp9qGHC4aXm7UWwOM2f/hGwJnmNA8wDrUUYeoXR9XSRNKI4zm2MQnUfIHe4rX wEJJzBpHm9PrNKgPyRsVuNLanTxoF7JY8tOgcZVs7p9+majYSrnnfVkSRNONERzhksqR r0ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=8k9F/t2cGOgm7cgze3tgM/N3f5OW0K5CP5YZeJ76/Ok=; b=PY0ljpZ/N/LGq89gUjZr/iovpkLdxARWaSNrHD1Td3+L8P9vr8/HpnqlkWpDVfzL0P xMD/vL094qrK7jyokgIeeSRTkkYYvZEQQQubOvpmLtMhrV7easxYV6yZoS862PkWx9D5 Agt1kyONQnAUWJWM/QX1dBUgWAX6/JoJau8eUPYZat83qAl1hXu72G2wdKnMyj4JB2oX ZwdJ3rKlIYo1dwNMwv4IECVx8XBzB34DKXltAgaASBO+r+PPKgE+6hEbtDyr1km3FSnq OQx/ImBfjTIN8j+uOuBhs0OGWfXIHSlnfCwMFCE3JkEcBBTH1o5/AH7kP8kuqmXCXCHw J5Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=lXUBGSd5; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs12-20020a170906dc8c00b0085ca2799671si9300019ejc.136.2023.01.12.22.58.57; Thu, 12 Jan 2023 22:59:20 -0800 (PST) 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=@mediatek.com header.s=dk header.b=lXUBGSd5; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241062AbjAMG5r (ORCPT <rfc822;zhuangel570@gmail.com> + 99 others); Fri, 13 Jan 2023 01:57:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240722AbjAMGzv (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 13 Jan 2023 01:55:51 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F5F471887; Thu, 12 Jan 2023 22:41:11 -0800 (PST) X-UUID: 42477e90930d11eda06fc9ecc4dadd91-20230113 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=8k9F/t2cGOgm7cgze3tgM/N3f5OW0K5CP5YZeJ76/Ok=; b=lXUBGSd55VTQxheE2ayM/JyvbAG+XUFis+WdwAZxCGq3SxpB/l3WEsF+Zc7hFrioKArm6OoCopv8a2xM26Uk7oHyWQb0oTd0x2fnVBI4v9H0NCiLi+0DMnN/pcWrMNbI585vHGT49vPWhlgruPL3QHRWFLKN6qRLuUTPtxjAqDM=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.17,REQID:35a1f78c-84d3-4cec-9f6b-1bfa1dc6d2ed,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:543e81c,CLOUDID:611d278c-8530-4eff-9f77-222cf6e2895b,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0 X-CID-BVR: 0,NGT X-UUID: 42477e90930d11eda06fc9ecc4dadd91-20230113 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from <moudy.ho@mediatek.com>) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1888787520; Fri, 13 Jan 2023 14:41:07 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Fri, 13 Jan 2023 14:41:06 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Fri, 13 Jan 2023 14:41:06 +0800 From: Moudy Ho <moudy.ho@mediatek.com> To: Mauro Carvalho Chehab <mchehab@kernel.org>, Matthias Brugger <matthias.bgg@gmail.com>, Hans Verkuil <hverkuil-cisco@xs4all.nl> CC: Chun-Kuang Hu <chunkuang.hu@kernel.org>, <linux-media@vger.kernel.org>, <linux-mediatek@lists.infradead.org>, <linux-kernel@vger.kernel.org>, <Project_Global_Chrome_Upstream_Group@mediatek.com>, Moudy Ho <moudy.ho@mediatek.com> Subject: [PATCH v5 01/12] media: platform: mtk-mdp3: fix potential frame size overflow in mdp_try_fmt_mplane() Date: Fri, 13 Jan 2023 14:40:53 +0800 Message-ID: <20230113064104.22402-2-moudy.ho@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230113064104.22402-1-moudy.ho@mediatek.com> References: <20230113064104.22402-1-moudy.ho@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754889621968864668?= X-GMAIL-MSGID: =?utf-8?q?1754889621968864668?= |
Series |
Add support for multiple chips
|
|
Commit Message
Moudy Ho (何宗原)
Jan. 13, 2023, 6:40 a.m. UTC
Fix overflow risk when setting certain formats whose frame size exceeds
a RGB24 with 7723x7723 resolution.
For example, a 7723x7724 RGB24 frame:
1. bpl (byte per line) = 7723 * 3.
2. Overflow occurs when bpl * 7724 * depth.
Fixes: 61890ccaefaf ("media: platform: mtk-mdp3: add MediaTek MDP3 driver")
Signed-off-by: Moudy Ho <moudy.ho@mediatek.com>
---
drivers/media/platform/mediatek/mdp3/mtk-mdp3-regs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-regs.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-regs.c index 4e84a37ecdfc..c63bd5e479e0 100644 --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-regs.c +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-regs.c @@ -432,9 +432,9 @@ const struct mdp_format *mdp_try_fmt_mplane(struct v4l2_format *f, bpl = clamp(bpl, min_bpl, max_bpl); pix_mp->plane_fmt[i].bytesperline = bpl; - min_si = (bpl * pix_mp->height * fmt->depth[i]) / + min_si = ((u64)bpl * pix_mp->height * fmt->depth[i]) / fmt->row_depth[i]; - max_si = (bpl * s.max_height * fmt->depth[i]) / + max_si = ((u64)bpl * s.max_height * fmt->depth[i]) / fmt->row_depth[i]; si = clamp(si, min_si, max_si);