Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13385411ybl; Sun, 29 Dec 2019 10:36:57 -0800 (PST) X-Google-Smtp-Source: APXvYqyqz2pkP4yyklUlVKxyGfPrMvysPwO2nnyHzN8ZB4ndwhz7vKCCShkCTGkbmqATh/+//OZi X-Received: by 2002:a9d:3b09:: with SMTP id z9mr70501623otb.195.1577644617019; Sun, 29 Dec 2019 10:36:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577644617; cv=none; d=google.com; s=arc-20160816; b=SKKDCVvJ89FZ83Qwy1OVRpHYThBq4zf9x/Z2m/r/FREsE/7vqZnEv/jbVFlyI+2nRP LjnreUoBNXCVFe6XllCtWWf4K0SzIQF2eyuGyVpeXl+caK59JlSJkO8EIJ2BFtzpitHh S/7f942EB7gbp4WKMASKpKtPaQfzo0+ZT/vYgYeZFqHg+klRhHXypTEdK0b2gOr355GO lIIdUEOXmSzLZ3YcGcPDZHWH9kEYgv2zxul4u6BWgmWELGlif1ad4xIEL08/alFpsGRR r1cTGRX8sDnA6gkqZS5vThh/pLEz0EWBz5DCFcACT6JzX0A3AmpGNL4Ff+X4MbJoUFXS c+BA== 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=nQjwVjlodxp2+LpnuNdQ4eAsSIgh5vxHGSPOHLLPIYY=; b=ombFUq77QaJAVQsTzlAceui7bJ4gOGYEl6oPwIHp32x7x/1D+eqZuqqGPac0JEQPoz FOfWUvyzGZgWWCu6436xMOlRJ0WnnzHTSu5D4bEBWnUTTceBcWS6rYqbbMciPn5LYxy3 pthXvRW0LyY61xcM6j78xwjg1BhAZLvKq1qP3/L4Rv52ZAfCv/GV9bxI1v5GX+mTehNK AcMbSRru+RPFwRml011Pua5TkX3QxmXg9OVKcCwZ/nXTk7C+BNMJq2K4oBN5+id/Nw2v lA/xKCMKq8aqnb6XahgFTcxUz9G355P/HMk7jbUBNhW+D2ZxvotQ2vZ4eEkwWSg6p4sn G4Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=C0ZQnQgh; 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 p5si22070486oto.116.2019.12.29.10.36.46; Sun, 29 Dec 2019 10:36:57 -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=C0ZQnQgh; 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 S1727496AbfL2RXN (ORCPT + 99 others); Sun, 29 Dec 2019 12:23:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:40476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727054AbfL2RXK (ORCPT ); Sun, 29 Dec 2019 12:23:10 -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 F1290208E4; Sun, 29 Dec 2019 17:23:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640190; bh=b8X487XQmcO66tp1rKOuiR6cuKxqQUfhPhSDjv/68sk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C0ZQnQghEeEToLLc7onTgHsNTsj3KohYs/HizKn0Rw3zPgeZ16SSVnj/fSW2K/kCd 1EswF7L9l08DLQR0zQLPiK88SuTdNqYJNuTKEGatCrg2VFjUM5bKqvHfe6SaFZ2/pe tkeyEK+/qza3wWO9n/Rpy2lnh+bNrAdPW7yZ+TUs= 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 4.14 056/161] media: ti-vpe: vpe: fix a v4l2-compliance failure about invalid sizeimage Date: Sun, 29 Dec 2019 18:18:24 +0100 Message-Id: <20191229162415.920214526@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162355.500086350@linuxfoundation.org> References: <20191229162355.500086350@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 7e611501c291..f29074c84915 100644 --- a/drivers/media/platform/ti-vpe/vpdma.h +++ b/drivers/media/platform/ti-vpe/vpdma.h @@ -60,6 +60,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 7af66fe95a54..2e8970c7e22d 100644 --- a/drivers/media/platform/ti-vpe/vpe.c +++ b/drivers/media/platform/ti-vpe/vpe.c @@ -1702,6 +1702,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