Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13473594ybl; Sun, 29 Dec 2019 12:45:51 -0800 (PST) X-Google-Smtp-Source: APXvYqyWiqm6rsqQEO3We4IFJXjFf7j3uLu+porowTV085r/dhR7fsXgx6rgSvi9jsLTZFPowHPj X-Received: by 2002:a9d:70d9:: with SMTP id w25mr65776930otj.231.1577652351516; Sun, 29 Dec 2019 12:45:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577652351; cv=none; d=google.com; s=arc-20160816; b=pgohla3OMQMymRF5SCsmEvjU5b5j7qUXeXDjXtrT0P9p+nzkkyvwL4EDL2q9F8aeZk phAELzqhGUziRq1nlGmjL77zdPtvbsMfNRn7XzJ2T4cphiM3os/+yL4cQ7wYr0msV5xh oU8+myyE0yWikKWDQxQoNCn9RVpBnMpDivexmX4kgRhxW+mbjAq2KXufCUnhuND4Cv8h TSKqidET+JqWe5IrXLxyAGwgmWaLPA2IfadL9WbvK7bnOS1eRmUGj/tirtYbEErgkEH7 ciJdSuAkX9bSy2dvQXmF9LrKZf6yfRKButfwHi17SwrarucslN+tkUXpqQblXOSJKAze zoiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=94OJjLfnTX+zgOw/d+HnUnJ05hak++dpf2hVN9Y5gQY=; b=GK0f/Tr3PgSoVvpTObOctmHsQDfRS0FNnYI6oT32HSYLaKPJ5Ifq6VHsVZjQsq2mFp 63ueb6kI+mSbAPiazADTQmfKPndJCs5di6GYIHbfZKKvmo0LiN80KTDRkE3xlxipcjPC SbVR5IruAR3oGFXEg8LVRIlDIosxHJDEDguG8FRMJxAiw0Kl8oZbLZsLRy1ADY7Nwify SfvwXpHuPDkks2p9T1n7w/+3crCVwFWmfaqbGDcWwUi+CK0jIXDVGJwpubOivaAk3KdK TX8SeuPKWFbRQSTBM57HmfVBwO6LJrq6585w0tHWbGfKZmiyLdM2ZWlBx04JsUqcxsB4 N+5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lmTBaSmq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si18846458otz.198.2019.12.29.12.45.41; Sun, 29 Dec 2019 12:45:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lmTBaSmq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731181AbfL2RrA (ORCPT + 99 others); Sun, 29 Dec 2019 12:47:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:56848 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730899AbfL2Rqs (ORCPT ); Sun, 29 Dec 2019 12:46:48 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8280D206A4; Sun, 29 Dec 2019 17:46:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577641608; bh=4HuciwyFX8Ae4TZ0WTYJrGWObwnCBGqD5+qppSi9StI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lmTBaSmq+DBpFVOue18p5YJoPP7gSsYJuht9rpHL+iZu8CaDzeOLmW8SOA2JAecr+ Xt1hI91VuJ9wg5ESMZ7hoRAq8Xg7dY7Jbu4YFhJvn7X7pRlSw7+2A9m23Z+EbW1Qot k3x2gVBIQYiuN8vVsMyfwXOYJw8vKChNxKbctem8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Benoit Parrot , Tomi Valkeinen , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.4 135/434] media: ti-vpe: vpe: fix a v4l2-compliance failure about invalid sizeimage Date: Sun, 29 Dec 2019 18:23:08 +0100 Message-Id: <20191229172710.680773149@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229172702.393141737@linuxfoundation.org> References: <20191229172702.393141737@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Benoit Parrot [ Upstream commit 0bac73adea4df8d34048b38f6ff24dc3e73e90b6 ] v4l2-compliance fails with this message: fail: v4l2-test-formats.cpp(463): !pfmt.sizeimage fail: v4l2-test-formats.cpp(736): \ Video Capture Multiplanar is valid, \ but TRY_FMT failed to return a format test VIDIOC_TRY_FMT: FAIL This failure is causd by the driver failing to handle out range 'bytesperline' values from user space applications. VPDMA hardware is limited to 64k line stride (16 bytes aligned, so 65520 bytes). So make sure the provided or calculated 'bytesperline' is smaller than the maximum value. Signed-off-by: Benoit Parrot Reviewed-by: Tomi Valkeinen Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/ti-vpe/vpdma.h | 1 + drivers/media/platform/ti-vpe/vpe.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/drivers/media/platform/ti-vpe/vpdma.h b/drivers/media/platform/ti-vpe/vpdma.h index 28bc94129348..9bacfd603250 100644 --- a/drivers/media/platform/ti-vpe/vpdma.h +++ b/drivers/media/platform/ti-vpe/vpdma.h @@ -57,6 +57,7 @@ struct vpdma_data_format { * line stride of source and dest * buffers should be 16 byte aligned */ +#define VPDMA_MAX_STRIDE 65520 /* Max line stride 16 byte aligned */ #define VPDMA_DTD_DESC_SIZE 32 /* 8 words */ #define VPDMA_CFD_CTD_DESC_SIZE 16 /* 4 words */ diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c index 512660b4ee63..8b14ba4a3d9e 100644 --- a/drivers/media/platform/ti-vpe/vpe.c +++ b/drivers/media/platform/ti-vpe/vpe.c @@ -1668,6 +1668,10 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f, if (stride > plane_fmt->bytesperline) plane_fmt->bytesperline = stride; + plane_fmt->bytesperline = clamp_t(u32, plane_fmt->bytesperline, + stride, + VPDMA_MAX_STRIDE); + plane_fmt->bytesperline = ALIGN(plane_fmt->bytesperline, VPDMA_STRIDE_ALIGN); -- 2.20.1