Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4950230yba; Tue, 30 Apr 2019 06:59:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqxU2xdFmhKOxeTRCQA2RdptfPAxx4Hki4buDjGcpBKcHUzWf8rd991W8RDrPpf7xHb5TJE2 X-Received: by 2002:a65:60c7:: with SMTP id r7mr61023669pgv.191.1556632769631; Tue, 30 Apr 2019 06:59:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556632769; cv=none; d=google.com; s=arc-20160816; b=AhVlnjEhY5S5k3M6QC2rk9BeGSAyvtgs+LClofcg2lghQeDqzqAPu2wD8LAsoBCDUD RO5+PjODIPYOiKKhiLbx1kC50Q17nrRlg6l1K/ao2bBZaEIDBysTx/zUnBfp0QCKsoxJ DDLKd7wQIN8oBqLXzs7LonrXOu749ej2MDaXaZNbp6FmPJUaVno78Mk1c64g0Fw0TBd5 8lKMQMkw/Fd462WScZ3akOca2CexjySgRpDCFftJ3+HJ9o0PjzqXkqNgDBJf4Dsw5QmJ jHVoXIEflDQ26qAXcW25bwE3BCQwmsA/KixtoAsUQt1e1XP+BKHq+7jxdV2a139Sh03J RhPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=AaV3gYxorKYrW96vLmzDyn0deBVwVKaMEtynWZiCEv4=; b=h0RXWq5mmdmCK7yxCkXRbE96l8TZFALrF5NKq3qcHa6S7lNywwbmqoz0H1GKN6UDS+ bQDkMzcRh/q/By54sgkiOY+WO7/EAHZlacwAzj/ibq7Xidd+M/BqWNDmRU1Ew45DNq5J HS4RGtzWYY2LV1xzS3hqqYycEE5SzOdJjxuGjT/RMYoAkxZVyFRBWjriqOBL4Ai1bxSF 0bFa6ZqKaLBVduKsit2Zh5JZihGPwBpvw3rHz7FxV2AMh7BnoleRppfgdhce5Pko+R/e LfcKdXlk+006IIqabZO+6qpGgDMaClPTPgXUFWscjQg7+DSMaYwPzFCJTLdE/82pI2rV pnkw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=iki.fi Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10si11378900pff.199.2019.04.30.06.59.13; Tue, 30 Apr 2019 06:59:29 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=iki.fi Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727330AbfD3N6U (ORCPT + 99 others); Tue, 30 Apr 2019 09:58:20 -0400 Received: from retiisi.org.uk ([95.216.213.190]:43680 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726105AbfD3N6U (ORCPT ); Tue, 30 Apr 2019 09:58:20 -0400 Received: from valkosipuli.localdomain (valkosipuli.retiisi.org.uk [IPv6:2a01:4f9:c010:4572::80:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by hillosipuli.retiisi.org.uk (Postfix) with ESMTPS id 3787D634C7B; Tue, 30 Apr 2019 16:58:10 +0300 (EEST) Received: from sailus by valkosipuli.localdomain with local (Exim 4.89) (envelope-from ) id 1hLTGr-0000hd-Rk; Tue, 30 Apr 2019 16:58:09 +0300 Date: Tue, 30 Apr 2019 16:58:09 +0300 From: Sakari Ailus To: Janusz Krzysztofik Cc: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH 03/14] media: ov6650: Fix unverified arguments used in .set_fmt() Message-ID: <20190430135809.5mgf4govbqj3cxph@valkosipuli.retiisi.org.uk> References: <20190408214242.9603-1-jmkrzyszt@gmail.com> <20190408214242.9603-4-jmkrzyszt@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190408214242.9603-4-jmkrzyszt@gmail.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Janusz, On Mon, Apr 08, 2019 at 11:42:31PM +0200, Janusz Krzysztofik wrote: > Commit 717fd5b4907ad ("[media] v4l2: replace try_mbus_fmt by set_fmt") > converted a former ov6650_try_fmt() video operation callback to an > ov6650_set_fmt() pad operation callback. However, the function does not > verify correctness of user provided format->which flag and pad config > pointer arguments. Fix it. > > Fixes: 717fd5b4907ad ("[media] v4l2: replace try_mbus_fmt by set_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 007f0ca24913..3062c9a6c57b 100644 > --- a/drivers/media/i2c/ov6650.c > +++ b/drivers/media/i2c/ov6650.c > @@ -679,6 +679,17 @@ static int ov6650_set_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; > + } For this to return an error, there would need to be a problem on the caller's side. In other words, this isn't supposed to happen. Instead of adding such checks to all drivers, I think they instead should be added to the caller's side. The checks already exist for uAPI, but not for other drivers. The same applies to patches until 7th (including). > + > if (is_unscaled_ok(mf->width, mf->height, &priv->rect)) > v4l_bound_align_image(&mf->width, 2, W_CIF, 1, > &mf->height, 2, H_CIF, 1, 0); -- Kind regards, Sakari Ailus