Message ID | 1452757045-34051-1-git-send-email-tiffany.lin@mediatek.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers |
Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.84) (envelope-from <linux-media-owner@vger.kernel.org>) id 1aJcTS-0005cc-Qh; Thu, 14 Jan 2016 07:37:38 +0000 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.76/mailfrontend-5) with esmtp id 1aJcTP-0005M1-92; Thu, 14 Jan 2016 08:37:38 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750980AbcANHhd (ORCPT <rfc822;mkrufky@linuxtv.org> + 1 other); Thu, 14 Jan 2016 02:37:33 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:49200 "EHLO mailgw02.hq.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750760AbcANHhd (ORCPT <rfc822;linux-media@vger.kernel.org>); Thu, 14 Jan 2016 02:37:33 -0500 Received: from mtkhts09.mediatek.inc [(172.21.101.70)] by mailgw02.hq.mediatek.com (envelope-from <tiffany.lin@mediatek.com>) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1071540166; Thu, 14 Jan 2016 15:37:29 +0800 Received: from mtkslt302.mediatek.inc (10.21.14.115) by mtkhts09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.266.1; Thu, 14 Jan 2016 15:37:28 +0800 From: Tiffany Lin <tiffany.lin@mediatek.com> To: Mauro Carvalho Chehab <mchehab@osg.samsung.com>, Hans Verkuil <hverkuil@xs4all.nl> CC: Eddie Huang <eddie.huang@mediatek.com>, Yingjoe Chen <yingjoe.chen@mediatek.com>, <linux-media@vger.kernel.org>, <linux-mediatek@lists.infradead.org>, Tiffany Lin <tiffany.lin@mediatek.com> Subject: [PATCH] media: v4l2-compat-ioctl32: fix missing length copy in put_v4l2_buffer32 Date: Thu, 14 Jan 2016 15:37:25 +0800 Message-ID: <1452757045-34051-1-git-send-email-tiffany.lin@mediatek.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: <linux-media.vger.kernel.org> X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2016.1.14.73016 X-PMX-Spam: Gauge=IIIIIIIII, Probability=9%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, MSGID_ADDED_BY_MTA 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_1000_1099 0, BODY_SIZE_2000_LESS 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, NO_URI_HTTPS 0, SINGLE_URI_IN_BODY 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __CT 0, __CT_TEXT_PLAIN 0, __DATE_TZ_HK 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __SINGLE_URI_TEXT 0, __TO_MALFORMED_2 0, __URI_IN_BODY 0, __URI_NO_WWW 0, __URI_NS ' |
Commit Message
Tiffany Lin
Jan. 14, 2016, 7:37 a.m. UTC
In v4l2-compliance utility, test QUERYBUF required correct length
value to go through each planar to check planar's length in multi-planar
Signed-off-by: Tiffany Lin <tiffany.lin@mediatek.com>
---
drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 3 +++
1 file changed, 3 insertions(+)
Comments
Hi Tiffany, Good catch! But looking through the compat code I noticed that in the single-planar DMABUF case the length field is also never copied. I think it would be much simpler if the length field is just always copied instead of in each multiplanar or singleplanar mmap/userptr/dmabuf case. It will simplify the code and prevent such mistakes in the future. Can you make a v2 that makes that change? Thanks! Hans On 01/14/2016 08:37 AM, Tiffany Lin wrote: > In v4l2-compliance utility, test QUERYBUF required correct length > value to go through each planar to check planar's length in multi-planar > > Signed-off-by: Tiffany Lin <tiffany.lin@mediatek.com> > --- > drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c > index 327e83a..5ba932a 100644 > --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c > +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c > @@ -521,6 +521,9 @@ static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user > if (num_planes == 0) > return 0; > > + if (put_user(kp->length, &up->length)) > + return -EFAULT; > + > uplane = (__force struct v4l2_plane __user *)kp->m.planes; > if (get_user(p, &up->m.planes)) > return -EFAULT; > -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Hans, On Thu, 2016-01-14 at 08:53 +0100, Hans Verkuil wrote: > Hi Tiffany, > > Good catch! But looking through the compat code I noticed that in the > single-planar DMABUF case the length field is also never copied. I think > it would be much simpler if the length field is just always copied instead > of in each multiplanar or singleplanar mmap/userptr/dmabuf case. It will > simplify the code and prevent such mistakes in the future. > > Can you make a v2 that makes that change? > Sure, I had sent v2. best regards, Tiffany > Thanks! > > Hans > > On 01/14/2016 08:37 AM, Tiffany Lin wrote: > > In v4l2-compliance utility, test QUERYBUF required correct length > > value to go through each planar to check planar's length in multi-planar > > > > Signed-off-by: Tiffany Lin <tiffany.lin@mediatek.com> > > --- > > drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c > > index 327e83a..5ba932a 100644 > > --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c > > +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c > > @@ -521,6 +521,9 @@ static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user > > if (num_planes == 0) > > return 0; > > > > + if (put_user(kp->length, &up->length)) > > + return -EFAULT; > > + > > uplane = (__force struct v4l2_plane __user *)kp->m.planes; > > if (get_user(p, &up->m.planes)) > > return -EFAULT; > > > -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c index 327e83a..5ba932a 100644 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c @@ -521,6 +521,9 @@ static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user if (num_planes == 0) return 0; + if (put_user(kp->length, &up->length)) + return -EFAULT; + uplane = (__force struct v4l2_plane __user *)kp->m.planes; if (get_user(p, &up->m.planes)) return -EFAULT;