Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp18883838rwd; Wed, 28 Jun 2023 01:54:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ79vSoAFkwOCSFdPumuLIkT52fE4P7HBArWEOUHzv9em3GmzeDQh07nX0zXR+aaIvYcwJ9o X-Received: by 2002:a17:907:7884:b0:98e:23d3:bf47 with SMTP id ku4-20020a170907788400b0098e23d3bf47mr9111021ejc.36.1687942498577; Wed, 28 Jun 2023 01:54:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687942498; cv=none; d=google.com; s=arc-20160816; b=wr20+gAdSa8/T6Bs75mzXAnfd/jzX9n5eK2iulL4/q7OtYxJdtqQ/JS6JcuA0fyoTZ QcamUI5VhFsrq3Mi3Iap16Rhf/QQRC7C5g7vle2+EVMTE/voQoCtEiYQdG9RJGjv36// kmQi9+OfH1U+Wg0K0aiNErbUF7f1cK6ccx3hLPT5amQaT31eEesIDM454Cu7mu246jru xomW5cf7KXyuPfuvs7uZk9brGWbVHJvYYaK+R6vXE34iWXTBPZ810V+g1L1a7G3AtT3U 48qjcLvk//WH3VWYnFCE+55Q1DEe92Z2wWfPNCYe0jURlmnQf/cHLw+g0FUNRaOc6/xr vyIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=PDrjMND7bGroH5j0rrcnleC0OQhYiDIbwQdzo2Jgn1U=; fh=PEnDtYiI8Z2LpklDQbwGxu8vt5c7x2djgbAttlD77qY=; b=pHFpmnkQ9lLcJvZHBElyFW5lxKiOfCpym3S7CxRZ+nslr2ovBZxiMIjPraThgTdJNd bMrZ8/tRqSXMO2MTlgZI+Hn+NQnpq+vsXg65tnG144tVcVQ/JLIoqeb0YFhWTOaGRN6e 6QuINniCvtz5OrnmGiY1sEzTr3g/6aCKjeSZ6DpKhRmXIlm+WjG+pYAPsJESDWjqWMCl XL6lWHDcsG56Rzl2Ibr02JZXarbj4AO0tUFUL7HoKNeiyM/DtjMreYhkEhQdH2ERbf2N RDqygLeCC6lKxLwOAWRyMyFD+UEnlWnMlJM1rmYhA5hcU082lM5p9sfMMMChJOGmYsc2 9NtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b="RtXRKS/W"; 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=foss.st.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ks1-20020a170906f84100b0098638efc275si5403514ejb.688.2023.06.28.01.54.34; Wed, 28 Jun 2023 01:54:58 -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=@foss.st.com header.s=selector1 header.b="RtXRKS/W"; 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=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232408AbjF1ILD (ORCPT + 99 others); Wed, 28 Jun 2023 04:11:03 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:55064 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232112AbjF1IG4 (ORCPT ); Wed, 28 Jun 2023 04:06:56 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35S5lVX9018612; Wed, 28 Jun 2023 08:34:00 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : content-transfer-encoding : in-reply-to; s=selector1; bh=PDrjMND7bGroH5j0rrcnleC0OQhYiDIbwQdzo2Jgn1U=; b=RtXRKS/WRZx7QSJzfVpCjRCj9ZtuaKSv3IXMctDL/yPKDmEgeo5VLF01mapnfg3LVOlU XtKbfby2bnY9inO/CZ0KbBRWxwmwVwtZeufo5NiNXTaPZUTeRHxOI9lwngy0TRBPVixB 2Sn8KEsghfIKT9KJ8PrqwEMVeIp7k3LPRSCc89jmy8Nm2W0f4SJ1djae7tqZS8ny3YV5 8AMu2qCIFVEqoYidHx70QY7trwnVn4YgezH3lLvN6X+8Y2hUw2uCh9eESZ2KY0ImE2WE i4aocEfzGaL7pPAXOwe2CYsUz+8kRv6z8iQxfGYjnWI3/IglynWMp0w0Z/RLYRZt5h+5 qg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3rgf1ara2p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 08:34:00 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 18C8810005B; Wed, 28 Jun 2023 08:33:59 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 0CDDF20B869; Wed, 28 Jun 2023 08:33:59 +0200 (CEST) Received: from gnbcxd0016.gnb.st.com (10.129.178.213) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 28 Jun 2023 08:33:58 +0200 Date: Wed, 28 Jun 2023 08:33:53 +0200 From: Alain Volmat To: sun yq CC: , , , , , , , <499671216@qq.com> Subject: Re: [PATCH] OOB read and write in mdp_prepare_buffer Message-ID: <20230628063353.GA3625616@gnbcxd0016.gnb.st.com> Mail-Followup-To: sun yq , mchehab@kernel.org, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, 499671216@qq.com References: <20230627082731.1769620-1-yqsun1997@gmail.com> <20230627140640.GA3605278@gnbcxd0016.gnb.st.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Disclaimer: ce message est personnel / this message is private X-Originating-IP: [10.129.178.213] X-ClientProxiedBy: SHFCAS1NODE2.st.com (10.75.129.73) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_03,2023-06-27_01,2023-05-22_02 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Wed, Jun 28, 2023 at 07:28:54AM +0800, sun yq wrote: > Hi, > Because there are many functions using the plane, increasing the max > number of the plane is to maximize the solution to all possible oob > places. I don't think it is the right approach then. If the HW is only handling 3 planes, there should be no reason to have to allocate for 8 planes. I suspect that this 8 value is coming from the maximum allowed plane number in V4L2 right ? INHO driver should simply be fixed to ensure that num_plane won't go higher than the real number of plane allocated in the structures. It should be possible to get the num_plane value from the format selected. Alain > > On Tue, Jun 27, 2023 at 10:06 PM Alain Volmat wrote: > > > > Hi, > > > > On Tue, Jun 27, 2023 at 04:27:31PM +0800, yqsun1997@gmail.com wrote: > > > From: yqsun1997 > > > > > > Because format in struct img_image_buffer max index is IMG_MAX_PLANES ==3, > > > The num_planes max index is 8.so will be OOB like in mdp_prepare_buffer. > > > > Similarly as your other patch, could you describe why you need to > > increase the IMG_MAX_PLANES while I suspect your driver only needs to > > deal with 3 planes. While the maximum num_planes value that can be > > given by the user is 8, this has to be first compared to the configured > > format prior to reaching this function. > > > > > > > > static void mdp_prepare_buffer(struct img_image_buffer *b, > > > struct mdp_frame *frame, struct vb2_buffer *vb) > > > { > > > struct v4l2_pix_format_mplane *pix_mp = &frame->format.fmt.pix_mp; > > > unsigned int i; > > > > > > b->format.colorformat = frame->mdp_fmt->mdp_color; > > > b->format.ycbcr_prof = frame->ycbcr_prof; > > > for (i = 0; i < pix_mp->num_planes; ++i) { > > > u32 stride = mdp_fmt_get_stride(frame->mdp_fmt, > > > pix_mp->plane_fmt[i].bytesperline, i); > > > > > > b->format.plane_fmt[i].stride = stride; //oob > > > ...... > > > > > > Signed-off-by: yqsun1997 > > > --- > > > drivers/media/platform/mediatek/mdp3/mtk-mdp3-type.h | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-type.h b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-type.h > > > index ae0396806..e2e991a34 100644 > > > --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-type.h > > > +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-type.h > > > @@ -11,7 +11,7 @@ > > > > > > #define IMG_MAX_HW_INPUTS 3 > > > #define IMG_MAX_HW_OUTPUTS 4 > > > -#define IMG_MAX_PLANES 3 > > > +#define IMG_MAX_PLANES 8 > > > #define IMG_MAX_COMPONENTS 20 > > > > > > struct img_crop { > > > -- > > > 2.39.2 > > > > > > > Regards, > > Alain