Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6249838imu; Mon, 21 Jan 2019 05:50:39 -0800 (PST) X-Google-Smtp-Source: ALg8bN4Z8G6M/InKamuFBLjqTiZOxOD25iM42f+A82chXaRjlFPHnLAc4u6jgt+ixR3F1DJ8FHNN X-Received: by 2002:a17:902:8a95:: with SMTP id p21mr30867046plo.183.1548078639935; Mon, 21 Jan 2019 05:50:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548078639; cv=none; d=google.com; s=arc-20160816; b=VUlrRuuMfGEyDXb9F2uJHHrxvjbZxrKo6OFhjRG0m63FBtE4jGJSbnDYdtzYxkMo32 prwFsMfUMArQ1TWUiMw9ekDaJkLUB8AGC9mNsE00y1RR/sv+9533S6cBcSIaVrJiiy+S HXfZ6YRXOeDHAh0xbXPhImSiwnrXnZliiaEvXMVysyDc82qT6q4Litp1mtvB36hzkPP3 GomHtOPwjrviylZCxTwsL0Xwkl9wfuEwN3t9cqzY6VMPtb9jOeWCLhDyr0m/YZHa2mc4 SKUFzAHY5U2269Zs0sEgchL5gVpziS1FRsSBioSRdZk74q8oIQX03uBIVvdHWK55gxon UPqw== 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=pi2kqTXtlM0B5zZLFPr/xuLz/PT0UZCjKf7zGKagQUI=; b=vl03TijCt9tbNAtNJdo27TDOAzZdd4z6I9I0nSCg7BXpg4Prg8hjg/xAAKNn10keGI QMXr5t1RBmWGPM4UPEH0FUku5Rwovd6FwdNr6xRa4KAzqbF6njD23fQzm8Q0KZZYn+N/ SrrFPXJC4lj3Pb0DN3l0bXIl5CiBD90YFXwUsSJwCwsSrWvX0HGkQ9nIOyonPLIHlGV2 aV19yuBfJdVTC79Bd89ilaFKtT7VpjS8QD8Lp3voNLQYJpdjApTiWDkj1jQanueDsT5a xYC0TUYxgBHdvxaY4EaUA3GuEtl77BHyrwpShgYY5fYq4i7//j7oRo1ylm3KoVVgHhdl fGDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=S5a0ZdWx; 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 f22si13096234pgm.81.2019.01.21.05.50.23; Mon, 21 Jan 2019 05:50:39 -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=S5a0ZdWx; 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 S1729959AbfAUNs2 (ORCPT + 99 others); Mon, 21 Jan 2019 08:48:28 -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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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);