Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3258207yba; Mon, 8 Apr 2019 14:46:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFpQSySo3HYIbqJ8jO0vL9DxKzR//0pD4ckK40iydqLKaQj1gC65KKKIsTQXSz6xz5bmCR X-Received: by 2002:a62:59cb:: with SMTP id k72mr32797359pfj.111.1554759970993; Mon, 08 Apr 2019 14:46:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554759970; cv=none; d=google.com; s=arc-20160816; b=AUOm8B/PpP2zgIa2b9YS5PudCDSl2bDQ3j+UjwtUduT5hqye2EMNuNl4G6Hp3C7N4Y 5MaRG3SKD1CelrormQV9q544IF7A80saNAuxv1o+TSjMIAb23UeDfQe/v0PCazP4zcTM e5Bcf7ykYfiQWcHna5S0BUx3+V48dnokHVwMlK4AvCX47ToTlbCiySBHI0RtIfMNc/Mh JzHsqbEu1RZhWS6m7wVnyU+jsrIipddRYl9UhzFLg+K9752HN4E2vsVNKTcGfCHo4DSf XklTBy/ToIUu5FBXshQmN0GBObPaHBaYnJvUBpKfXfw1OnIt1ck21xt9RyaBzxr9bAG8 +szw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xnC2Q7NaDaS6u2MiZtA1HALfljD2ysiOfTyMydRHW5s=; b=IZYbV51tKpVgrgUKrF487U1kjt2JmDQNvzEk3XHW8Bi1J+Gv2evFTdwf3dgmBo14Wi HT8XavW+/CnWdgu3fqxNdubsoLIT0UDbyDk2BBIf+hvHkh7d5LuGIMxDpJh8CQ7DsRFt yMcmXTyQjQuhz4OCDnFpCgHRd+754IRSa2MHixKLLTFfuAM/3ln7O+O0gtcXlVt2NJGw 3TMOTqIbe2DSWw0F5qWxWr+pAYcBx4e2j3qwJNyFMJ6abPADafa5oGS8EiIy4BpRhiUL UNgoarrRwwE1j/+/ylFEFvMWh1e0m0/oNL9X5+4rF9Vs+QJSkgje7MlRe4zHGAVfsAAa cIRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jwI1amul; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z127si26052726pfb.254.2019.04.08.14.45.56; Mon, 08 Apr 2019 14:46:10 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=jwI1amul; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726876AbfDHVnR (ORCPT + 99 others); Mon, 8 Apr 2019 17:43:17 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:39047 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726564AbfDHVnN (ORCPT ); Mon, 8 Apr 2019 17:43:13 -0400 Received: by mail-lj1-f194.google.com with SMTP id l7so12625838ljg.6; Mon, 08 Apr 2019 14:43:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xnC2Q7NaDaS6u2MiZtA1HALfljD2ysiOfTyMydRHW5s=; b=jwI1amulwo1LNJ7let0l3PYX2sHWrU0Wk/Aa+C+fZ9at8nr+emkX5+/J+ENdx4uMnW XDzn106OibE71EMGOgwlbOdgM4hz9PnzZUwEJz8IP1VDIHhWIXvuKVrwR7zOyp7nhq9t ilbOIVFzMf7/jYUfSb5kCd7DxGZ+qN+hSBJYjIRHKYaloZobk/Yo9TD9HG7uImliYS9K NJ+HbW7O8aahkrFBRDm1uYAlfdS1NWECBkJPV9nWUog+J069Z+AcsqOBuvfvNxYQizO+ bLD0fgKWnDbQTQN5aWpinFKKZCl2Ak8dEf49cI4p7D0tgxUTbxwEMJAqU+IKIh3EvnXp Cvog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xnC2Q7NaDaS6u2MiZtA1HALfljD2ysiOfTyMydRHW5s=; b=H4+1H8WvPiyvIIhz6G604hJCJMgRrYUQrphcYZApOv5HlSwQX9Ul8i+4vAveSDdCYf O8C1X8rNxZjHlKuKCHtV6VWBFol4TPeEa4G3TKLDFdm2mdLq0gls+rjWXWIhCmRDtIkI 8i2Km0AhB91SKBcMVZ9KR5TD6BsNOD/EfRDwItVKk9TocBp+Q3u2R3LaPp4Zab2fCF82 xg0L2KXddqXbzVirpWSUI/0G/eHKDUVQAahnLhUN7P+JYXWRN+h1S3eK/naOp1Xmj29j 8JEBAtCR4VpnUgOxmT2qLO7Xf4L6qerIEJ/kMYI3iv1mGnaYD076+kAEUWgQkb86YdYB iaMA== X-Gm-Message-State: APjAAAVlbGZuQOvfGt2Ob4dji6RxBdJ8DDFYMlQS/GQ1ihDvXwvOELtT 0NTgrWNYNoKlP118NmFQwPo= X-Received: by 2002:a2e:7c02:: with SMTP id x2mr14248044ljc.176.1554759790982; Mon, 08 Apr 2019 14:43:10 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id j6sm5286048ljc.0.2019.04.08.14.43.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 14:43:10 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH 04/14] media: ov6650: Fix unverified arguments accepted by .get_fmt() Date: Mon, 8 Apr 2019 23:42:32 +0200 Message-Id: <20190408214242.9603-5-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408214242.9603-1-jmkrzyszt@gmail.com> References: <20190408214242.9603-1-jmkrzyszt@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit da298c6d98d5 ("[media] v4l2: replace video op g_mbus_fmt by pad op get_fmt") converted a former ov6650_g_fmt() video operation callback to an ov6650_get_fmt() pad operation callback. However, the function does not verify correctness of user provided format->which flag and pad config pointer arguments. Fix it. Even if the function never dereferences the pad config pointer argument, return -EINVAL if it is NULL on V4L2_SUBDEV_FORMAT_TRY. Fixes: da298c6d98d5 ("[media] v4l2: replace video op g_mbus_fmt by pad op get_fmt") Signed-off-by: Janusz Krzysztofik Cc: stable@vger.kernel.org --- drivers/media/i2c/ov6650.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index 3062c9a6c57b..5c1738c5a847 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -515,6 +515,17 @@ static int ov6650_get_fmt(struct v4l2_subdev *sd, if (format->pad) return -EINVAL; + switch (format->which) { + case V4L2_SUBDEV_FORMAT_ACTIVE: + break; + case V4L2_SUBDEV_FORMAT_TRY: + if (cfg) + break; + /* fall through */ + default: + return -EINVAL; + } + mf->width = priv->rect.width >> priv->half_scale; mf->height = priv->rect.height >> priv->half_scale; mf->code = priv->code; -- 2.21.0