From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55A28C2F3BE for ; Mon, 21 Jan 2019 13:48:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 179EF20879 for ; Mon, 21 Jan 2019 13:48:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548078513; bh=e2Q79qmfSoPszl37lDfrbfGqxYpAW776ofdsQIIZbzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=CeaYVF7y101IDstML0zr91WUoxZQVAju0Fy4aJX7mst9CW0bvA3VtHiR6vyPNPqwe PJtHIQoxv4U3ryy17q/o8rD+qmmRy5Bt6KudqkiNTpAUGU6sZHVmdle8+ByoU7FCVA L4x7kv4tIYB480gTGb6tWsnHN6PRms0ScQ4IeOIQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729950AbfAUNs0 (ORCPT ); Mon, 21 Jan 2019 08:48:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:58354 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729948AbfAUNs0 (ORCPT ); Mon, 21 Jan 2019 08:48:26 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 C75F12063F; Mon, 21 Jan 2019 13:48:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548078505; bh=e2Q79qmfSoPszl37lDfrbfGqxYpAW776ofdsQIIZbzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S5a0ZdWxJcY+KyyRXi52bq5rsvv22B+uipFFtaohFB93c5U2gBq/LO2cx5xzte+WA Ltq3fxgt6O1ATeC519RbjS/RyAMbLFDnxsNZOzVDk7NOi9qcGKsnJI04xcyrVa7ogG JJWNakV7LZAvwjA3cZ3i7VelMHYYcvcRByAlTC88= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sakari Ailus , Thierry Reding , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 4.20 056/111] media: v4l: ioctl: Validate num_planes for debug messages Date: Mon, 21 Jan 2019 14:42:50 +0100 Message-Id: <20190121122502.043630494@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121122455.819406896@linuxfoundation.org> References: <20190121122455.819406896@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sakari Ailus commit 7fe9f01c04c2673bd6662c35b664f0f91888b96f upstream. The num_planes field in struct v4l2_pix_format_mplane is used in a loop before validating it. As the use is printing a debug message in this case, just cap the value to the maximum allowed. Signed-off-by: Sakari Ailus Cc: stable@vger.kernel.org Reviewed-by: Thierry Reding Signed-off-by: Hans Verkuil Cc: # for v4.12 and up Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/v4l2-core/v4l2-ioctl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -286,6 +286,7 @@ static void v4l_print_format(const void const struct v4l2_window *win; const struct v4l2_sdr_format *sdr; const struct v4l2_meta_format *meta; + u32 planes; unsigned i; pr_cont("type=%s", prt_names(p->type, v4l2_type_names)); @@ -316,7 +317,8 @@ static void v4l_print_format(const void prt_names(mp->field, v4l2_field_names), mp->colorspace, mp->num_planes, mp->flags, mp->ycbcr_enc, mp->quantization, mp->xfer_func); - for (i = 0; i < mp->num_planes; i++) + planes = min_t(u32, mp->num_planes, VIDEO_MAX_PLANES); + for (i = 0; i < planes; i++) printk(KERN_DEBUG "plane %u: bytesperline=%u sizeimage=%u\n", i, mp->plane_fmt[i].bytesperline, mp->plane_fmt[i].sizeimage);