From patchwork Mon Mar 14 09:04:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "tiffany.lin" X-Patchwork-Id: 8577771 Return-Path: X-Original-To: patchwork-linux-mediatek@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8157FC0553 for ; Mon, 14 Mar 2016 09:05:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8F9CE2044B for ; Mon, 14 Mar 2016 09:05:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8F3A420429 for ; Mon, 14 Mar 2016 09:05:06 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1afOQz-0008VJ-Pf; Mon, 14 Mar 2016 09:05:05 +0000 Received: from [210.61.82.183] (helo=mailgw01.mediatek.com) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1afOQn-0007z6-Lw; Mon, 14 Mar 2016 09:04:54 +0000 Received: from mtkhts07.mediatek.inc [(172.21.101.69)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1561277379; Mon, 14 Mar 2016 17:04:29 +0800 Received: from [172.21.77.4] (172.21.77.4) by mtkhts07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.266.1; Mon, 14 Mar 2016 17:04:28 +0800 Message-ID: <1457946267.16701.6.camel@mtksdaap41> Subject: Re: FW: [PATCH v5 0/8] Add MT8173 Video Encoder Driver and VPU Driver From: tiffany lin To: Hans Verkuil Date: Mon, 14 Mar 2016 17:04:27 +0800 In-Reply-To: <56E66672.9030307@xs4all.nl> References: <1457939579.32502.10.camel@mtksdaap41> <56E66672.9030307@xs4all.nl> X-Mailer: Evolution 3.2.3-0ubuntu6 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160314_020453_961452_11EA2886 X-CRM114-Status: GOOD ( 18.22 ) X-Spam-Score: -1.1 (-) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, daniel.thompson@linaro.org, Mauro Carvalho Chehab , linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, PoChun.Lin@mediatek.com, Rob Herring , Hans Verkuil , linux-arm-kernel@lists.infradead.org, Matthias Brugger , Yingjoe Chen , Eddie Huang , Pawel Osciak , linux-media@vger.kernel.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, 2016-03-14 at 08:21 +0100, Hans Verkuil wrote: > On 03/14/2016 08:12 AM, tiffany lin wrote: > > Hi Hans, > > > > After change to use "v4l-utils.git master branch", "V4l2-compliance > > -d /dev/video1" fail on "fail: v4l2-test-buffers.cpp(555): > > check_0(crbufs.reserved, sizeof(crbufs.reserved))". > > > > Check the source code and found > > > > memset(&crbufs, 0xff, sizeof(crbufs)); -> crbufs to 0xff > > node->g_fmt(crbufs.format, i); > > crbufs.count = 0; > > crbufs.memory = m; > > fail_on_test(doioctl(node, VIDIOC_CREATE_BUFS, &crbufs)); > > fail_on_test(check_0(crbufs.reserved, sizeof(crbufs.reserved))); > > fail_on_test(crbufs.index != q.g_buffers()); > > > > crbufs is initialized to fill with 0xff and after VIDIOC_CREATE_BUFS, > > crbufs.reserved field should be 0x0. But v4l2_m2m_create_bufs and > > vb2_create_bufs do not process reserved filed. > > Do we really need to check reserved filed filled with 0x0? Or we need to > > change vb2_create_bufs to fix this issue? > > The reserved field is zeroed in v4l_create_bufs() in v4l2-ioctl.c, so even before > vb2_create_bufs et al is called. > > The fact that it is no longer zeroed afterwards suggests that someone is messing > with the reserved field. > > You'll have to do a bit more digging, I'm afraid. > Hi Hans, Thanks for your information. I found the root cause is in "put_v4l2_create32". It do not copy reserved field from kernel space to user space. After modification,"test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK" format)) || + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved))) return -EFAULT; return __put_v4l2_format32(&kp->format, &up->format); } best regards, Tiffany > Regards, > > Hans diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c index f38c076..109f687 100644 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c @@ -280,7 +280,8 @@ static int put_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user static int put_v4l2_create32(struct v4l2_create_buffers *kp, struct v4l2_create_buffers32 __user *up) { if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_create_buffers32)) || - copy_to_user(up, kp, offsetof(struct v4l2_create_buffers32, format))) + copy_to_user(up, kp, offsetof(struct v4l2_create_buffers32,