Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp313540ybd; Fri, 28 Jun 2019 20:35:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxorMcJQEPO+XNa9utK8EdfKfJBOh8kGjTnWx8aAi05H0xNTsF8ZkpXMtuMw3EjZ/Znxxy6 X-Received: by 2002:a17:902:7787:: with SMTP id o7mr14353265pll.120.1561779302963; Fri, 28 Jun 2019 20:35:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561779302; cv=none; d=google.com; s=arc-20160816; b=YGu5Gffe61qgXNjVv1ykAivASqlS7kRPbpdF9RhqI0vwB7EWmgVEbLoSxK50cXc/9H igIMCdX31w+BbOW74uBIJxvDfD8tNwqtA4znljIEceAtMBXz+e1R6yT79LsTyJYXYAmK NKcQAaJR88975+M/TDa7w3nze60b0Wb4JmrcG1O/oIpGe3sEqfgFuxb8mWLUdy+0ZRlE 1s1Et4lMGrIf4KPQ94dfAlbHUQFb6nQ8i/3HEGICiVrVeJ9qRfkG9NnT/y+6/O379zt5 eSYNt9zQO48X7dl9iE8N3/Wy3VtnDGikNYguB2DkYGzi1TfaMGDxmqNiP1nOPwI7zTkd c8Og== 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:authorized-sender; bh=gAGSp3ZeTLapZ58XDXVw+SUowdZ3o7x0dzimYRK3Fms=; b=POYhK1GMof0Hv2TRKQAHCBjx97KPQ+gzr+7IxdSG+aDQWSulMxCUoGmzsA8GxMf15w FRiBjZEw6iSH2wxhIGSCYxRcYOsH8yPpigBG3CkClg8DMckcRstbbgrXlvWU1QD5bbMW DwsuMGad2jCMlqOXJVsgJt676GwI3AOn8qMzpTFaaWBzXA0tHEm1xFoS52W+bRcsg+zD r/VGmZrNJz2MazYoFu/Aqdnc1za17LfbfxCWnSbTe+doWKoWaNxu6P4nq5ve9NZlNwim 1tp6IHBY85p9qcVSdk1xrBQ21vB4khqkN7/pLWyYaYzhp6jnI6OahxqSwcx4uiR1wV0/ ldbg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e3si4075313pfa.248.2019.06.28.20.34.45; Fri, 28 Jun 2019 20:35:02 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726787AbfF2DeY (ORCPT + 99 others); Fri, 28 Jun 2019 23:34:24 -0400 Received: from bin-mail-out-06.binero.net ([195.74.38.229]:2567 "EHLO bin-mail-out-06.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726707AbfF2DeY (ORCPT ); Fri, 28 Jun 2019 23:34:24 -0400 X-Greylist: delayed 363 seconds by postgrey-1.27 at vger.kernel.org; Fri, 28 Jun 2019 23:34:24 EDT X-Halon-ID: e98c0dff-9a1d-11e9-8601-0050569116f7 Authorized-sender: niklas.soderlund@fsdn.se Received: from localhost (unknown [145.14.112.32]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPSA id e98c0dff-9a1d-11e9-8601-0050569116f7; Sat, 29 Jun 2019 05:28:08 +0200 (CEST) Date: Sat, 29 Jun 2019 05:28:17 +0200 From: Niklas =?iso-8859-1?Q?S=F6derlund?= To: Janusz Krzysztofik Cc: Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v7 0/3] media: v4l2-subdev: Verify arguments in v4l2_subdev_call() Message-ID: <20190629032817.GQ32581@bigcity.dyn.berto.se> References: <20190520212747.368-1-jmkrzyszt@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190520212747.368-1-jmkrzyszt@gmail.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, This patch breaks rcar-vin. I'm sorry I did not find out before it was merged as a8fa55078a7784a9 ("media: v4l2-subdev: Verify arguments in v4l2_subdev_call()"). The problem is that rcar-vin calls enum_mbus_code in its bound callback. At this point call_enum_mbus_code() is invoked which then calls check_pad(). At this point sd->entity.graph_obj.mdev is not set so the check if (pad > 0) fails and the binding of the subdevice in rcar-vin fails. I'm not sure how to best solve this, suggestions are appreciated. I see two options, move the call to enum_mbus_code from the bound to the complete callback or make sure the mdev is associated with the subdev before the bound callback is invoked. I don't like the former as I think the complete callback should be removed ;-) On 2019-05-20 23:27:44 +0200, Janusz Krzysztofik wrote: > Correctness of format type (try or active) and pad ID parameters passed > to subdevice operation callbacks is now verified only for IOCTL calls. > However, those callbacks are also used by drivers, e.g., V4L2 host > interfaces. > > Since both subdev_do_ioctl() and drivers are using v4l2_subdev_call() > macro while calling subdevice operations, move those parameter checks > from subdev_do_ioctl() to v4l2_subdev_call(). Also, add check for > non-NULL pointers, including pad config if V4L2_SUBDEV_FORMAT_TRY is > requested. > > Having that done, we can avoid taking care of those checks inside > drivers. > > Janusz Krzysztofik (3): > media: v4l2-subdev: Verify arguments in v4l2_subdev_call() > media: v4l2-subdev: Verify v4l2_subdev_call() pointer arguments > media: v4l2-subdev: Verify v4l2_subdev_call() pad config argument > > drivers/media/v4l2-core/v4l2-subdev.c | 268 +++++++++++++++++--------- > include/media/v4l2-subdev.h | 6 + > 2 files changed, 188 insertions(+), 86 deletions(-) > > Changelog: > v6->v7: > Changes suggested by Sakari - thanks! > - never succeed pad check on media entities with pad_num == 0, > - allow pad 0 on subdevies not registered as media entities. > > v5->v6: > - rename wrappers to call_something() as suggested by Sakari - thanks! > - make check_ functions inline - also on Sakari's suggestion, thanks! > - drop patch 2/4 and remove WARN_ONs from remaining patches to avoid > kernel WARNs on non-kernel bugs - thanks Hans for pointing this out! > > v4->v5: > - a few coding style and code formatting changes, > - require CONFIG_MEDIA_CONTROLLER, not CONFIG_VIDEO_V4L2_SUBDEV_API, > for a valid pad ID check, > - perform pad ID check only if at least one pad is configured so > drivers which don't configure pads are not affected if built with > CONFIG_MEDIA_CONTROLLER defined, > - issue kernel warnings on invalid parameters (new patch - 2/4), > - validate pointers before using them (new patch - 3/4). > > v3->v4: > - fix 'struct' keyword missing from patch 2/2, > - fix checkpatch reported style issue in patch 2/2 > Sorry for that. > > v2->v3: > - add patch 2/2 with pad config check, > - adjust continuation line alignments in patch 1/2 to match those > used in 2/2. > > v1->v2: > - replace the horrible macro with a structure of wrapper functions; > inspired by Hans' and Sakari's comments - thanks! > > -- > 2.21.0 >