Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6261855imu; Mon, 21 Jan 2019 06:02:56 -0800 (PST) X-Google-Smtp-Source: ALg8bN6qABbcGV6QE3nMpxSqjCYMLkLyURauhTlT4W8A0fI77Nd6dQK4R8gFpzv1rpRDzTNc/OV1 X-Received: by 2002:a17:902:7c85:: with SMTP id y5mr30094531pll.63.1548079376504; Mon, 21 Jan 2019 06:02:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548079376; cv=none; d=google.com; s=arc-20160816; b=SM+8cpZBFNtHxzd4OWKwGQKqP5Bt9Hxw3IzxeDM37AgISNwjMSSMDpUzZJc1MsH61y Ec7Zw+RfWcsiTCSeaEh/u50v8/YSun7mpf/uYV1x5WC9FWkp5bD8qVNJVCIYkyeygTwl u8FfdnOmsuiyu+AHu/VgiWnKO+T1OcEmBN2iIKY1TfO/BDdlMBJ405JQ0AL0Anie/cIx TJjddj2cNRl2afBbbF1QaSWpXq3TP0ISDE1QTxVuePVij5Pa4QMfEGktDetamSbazOPP R79L03eHcVozAvUcJID8mtbyBgvVQ0VZ9k1ysCu6gg5rllNuLDwloeVCSWc5WY0qlRqW wJvg== 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=pzV5lK3Tz3NaoPdEEz8NqA+8tSOD8/69zmQX3p/eFxw=; b=uW/pB6NZg9U/JryfaStrOT1ijiyJRpddt3hQOCICf3znnTYnLQdTGLnnX7J1+4vkVJ BdM/Bsi+6Uyt9gs7vXFCjuaxL4wTjY4PKuM1mXDHVoHy+s6Zjzs55n7DVKTqjUJCZk1P wtuSMVh9RZ+B05CNJV2KDDWi3r3gc+ewqWW3JO1Y5W6tleD6ytxVeLBW1uUAzhMmWKsi C+Ws23KCwZhG41NaE5jf9OR0NMac40uKikPpOZleZbPK37uhwO4mk5YYKmix7foN2u6U SIZ/uXdTfoS6qcJ+1rHBof4QKk+k1iOS7nMssYpFP4Z6kQz5wpshNfKpDCsGiY71alNc GW6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="m/TWJcMS"; 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 a24si13046504pgd.248.2019.01.21.06.02.36; Mon, 21 Jan 2019 06:02:56 -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="m/TWJcMS"; 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 S1732386AbfAUOAY (ORCPT + 99 others); Mon, 21 Jan 2019 09:00:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:46914 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732377AbfAUOAX (ORCPT ); Mon, 21 Jan 2019 09:00:23 -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 734DB2084C; Mon, 21 Jan 2019 14:00:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548079222; bh=Rt2+52BNE72BF/lN+uyv0Y9KcSOM+TndGG/S8jXlS1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m/TWJcMS0I5bMRavnD1s5P5ZoDEu7ZxsNhucuLGPsv7jMbrC0m5t++hm9d3ooeOO0 1m9xCDILEXuXRVr78e+YL0ShJ03MHKLmYcy4COlfulpPH6qbZIw2ebJV5eUsh+07yl AXgUshRnhH4hYt5a3d/bsr+6nTUlahN4giIWS4xM= 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.19 51/99] media: v4l: ioctl: Validate num_planes for debug messages Date: Mon, 21 Jan 2019 14:48:43 +0100 Message-Id: <20190121134915.914937836@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121134913.924726465@linuxfoundation.org> References: <20190121134913.924726465@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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-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);