OOB read and write in mtk multiple places
Subsystems (3)
PATCH 1/1 OOB read and write in mtk multiple places
From: yqsun1997 <[email protected]>
The num_planes max index is 8,
but bytesperline and bytesperline in struct mtk_q_data,
The max index is MTK_VCODEC_MAX_PLANES == 3,
so will cause OOB read and write in multiple places.like vidioc_venc_g_fmt same as commit 8fbcf730
--- drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h +1 -1
@@ -22,7 +22,7 @@#define MTK_VCODEC_DEC_NAME "mtk-vcodec-dec"#define MTK_VCODEC_ENC_NAME "mtk-vcodec-enc" -#define MTK_VCODEC_MAX_PLANES 3 +#define MTK_VCODEC_MAX_PLANES 8#define MTK_V4L2_BENCHMARK 0#define WAIT_INTR_TIMEOUT_MS 1000#define IS_VDEC_LAT_ARCH (hw_arch) ((hw_arch) >= MTK_VDEC_LAT_SINGLE_CORE)
Signature · 1 line
2.39.2
Hi,
I had a look at some places where this macro MTK_VCODEC_MAX_PLANES is being used, such as q_data->bytesperline etc.
This patch seems to be increasing the table size from 3 to 8 but, if my understanding is correct doesn't solve the issue that (taking the example you give in vidioc_venc_g_fmt) the table bytesperline is accessed taking into account a num_planes values which is unchecked if appropriate for this driver.
What are the 8 planes you are referring to ?
While increasing the table to 8 might also be necessary, it seems to me that the real OOB access issue should be solved by checking the num of planes value.
Regards,
Alain
Quoted 29 lines · On Tue, Jun 27, 2023 at 04:10:02PM +0800, [email protected] wrote:
From: yqsun1997 <[email protected]>
The
num_planesmax index is 8,
but bytesperline and bytesperline in structmtk_q_data,
The max index isMTK_VCODEC_MAX_PLANES== 3,
so will cause OOB read and write in multiple places.likevidioc_venc_g_fmtsame as commit8fbcf730Signed-off-by yqsun1997 <[email protected]>--- drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h +1
-1@@ -22,7 +22,7 @@#define MTK_VCODEC_DEC_NAME "mtk-vcodec-dec"#define MTK_VCODEC_ENC_NAME "mtk-vcodec-enc" -#define MTK_VCODEC_MAX_PLANES 3 +#define MTK_VCODEC_MAX_PLANES 8#define MTK_V4L2_BENCHMARK 0#define WAIT_INTR_TIMEOUT_MS 1000#define IS_VDEC_LAT_ARCH (hw_arch) ((hw_arch) >= MTK_VDEC_LAT_SINGLE_CORE)Signature · 1 line
2.39.2
When using V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, the number of planes is controlled by the user. Only checking the oob at the function may miss other functions, so it is appropriate to change the size of the macro. You can refer to other functions, such as mtk_dip_vb2_video_queue_setup, the max plane size of this module is 8
Quoted 50 lines · Alain Volmat
Hi,
I had a look at some places where this macro
MTK_VCODEC_MAX_PLANESis being used, such asq_data->bytesperlineetc.
This patch seems to be increasing the table size from 3 to 8 but, if my understanding is correct doesn't solve the issue that (taking the example you give invidioc_venc_g_fmt) the table bytesperline is accessed taking into account anum_planesvalues which is unchecked if appropriate for this driver.What are the 8 planes you are referring to ?
While increasing the table to 8 might also be necessary, it seems to me that the real OOB access issue should be solved by checking the num of planes value.
Regards,
AlainQuoted 29 lines · On Tue, Jun 27, 2023 at 04:10:02PM +0800, [email protected] wrote:
From: yqsun1997 <[email protected]>
The
num_planesmax index is 8,
but bytesperline and bytesperline in structmtk_q_data,
The max index isMTK_VCODEC_MAX_PLANES== 3,
so will cause OOB read and write in multiple places.likevidioc_venc_g_fmtsame as commit8fbcf730Signed-off-by yqsun1997 <[email protected]>--- drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h +1
-2@@ -22,7 +22,7 @@#define MTK_VCODEC_DEC_NAME "mtk-vcodec-dec"#define MTK_VCODEC_ENC_NAME "mtk-vcodec-enc" -#define MTK_VCODEC_MAX_PLANES 3 +#define MTK_VCODEC_MAX_PLANES 8#define MTK_V4L2_BENCHMARK 0#define WAIT_INTR_TIMEOUT_MS 1000#define IS_VDEC_LAT_ARCH (hw_arch) ((hw_arch) >= MTK_VDEC_LAT_SINGLE_CORE) --2.39.2
Hi,
Quoted 4 lines · sun yq
When using
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, the number of planes is controlled by the user. Only checking the oob at the function may miss other functions, so it is appropriate to change the size of the macro. You can refer to other functions, such as
o> mtk_dip_vb2_video_queue_setup, the max plane size of this module is 8
To my understanding, the vcodec driver only has formats requiring up to 3 planes. Could you explain why you need to change this macro to 8 ? Could you please describe the issue you had which led to this change ?
Quoted 53 lines · Alain Volmat
Quoted 50 lines
Hi,
I had a look at some places where this macro
MTK_VCODEC_MAX_PLANESis being used, such asq_data->bytesperlineetc.
This patch seems to be increasing the table size from 3 to 8 but, if my understanding is correct doesn't solve the issue that (taking the example you give invidioc_venc_g_fmt) the table bytesperline is accessed taking into account anum_planesvalues which is unchecked if appropriate for this driver.What are the 8 planes you are referring to ?
While increasing the table to 8 might also be necessary, it seems to me that the real OOB access issue should be solved by checking the num of planes value.
Regards,
AlainQuoted 29 lines · On Tue, Jun 27, 2023 at 04:10:02PM +0800, [email protected] wrote:
From: yqsun1997 <[email protected]>
The
num_planesmax index is 8,
but bytesperline and bytesperline in structmtk_q_data,
The max index isMTK_VCODEC_MAX_PLANES== 3,
so will cause OOB read and write in multiple places.likevidioc_venc_g_fmtsame as commit8fbcf730Signed-off-by yqsun1997 <[email protected]>--- drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h +1
-2@@ -22,7 +22,7 @@#define MTK_VCODEC_DEC_NAME "mtk-vcodec-dec"#define MTK_VCODEC_ENC_NAME "mtk-vcodec-enc" -#define MTK_VCODEC_MAX_PLANES 3 +#define MTK_VCODEC_MAX_PLANES 8#define MTK_V4L2_BENCHMARK 0#define WAIT_INTR_TIMEOUT_MS 1000#define IS_VDEC_LAT_ARCH (hw_arch) ((hw_arch) >= MTK_VDEC_LAT_SINGLE_CORE) --2.39.2