Received: by 10.223.185.116 with SMTP id b49csp591213wrg; Fri, 16 Feb 2018 04:06:38 -0800 (PST) X-Google-Smtp-Source: AH8x2246OM0tIWq86dgPFQI93WLvfq3AdIUS8bKNOl/szhLhZ44iJvksDS4xZWMPHTbG+43GiAJc X-Received: by 2002:a17:902:8a89:: with SMTP id p9-v6mr5632791plo.397.1518782798620; Fri, 16 Feb 2018 04:06:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518782798; cv=none; d=google.com; s=arc-20160816; b=FvOse++A65GA6zWwktHecjYyY8lUuEaGgXuwHWjdNWJYzvBAIvqKj87HUEdVGD8tEC MJ6a8BUjwOia/bG4VT7Xi6m/OtG0VA8/QxKpk24nvMFFBPu24NEaTIfN4SBsdG6lu4Vq KvBMDGlJ9LxPupdw0JaTx18483zwK+N2gNucAsZdXzl99TwAFk7VzcG2BcVz1ZobeEKp eSJvL9H6cuTwwlOYc7O5ENrFBx8oKC8/N0l9/5oik23zSntM0vf8HVCAeN3Uj+oVo7oz MvrR7jtU034mdbXTWIzCsMVvba93iv3lZgMvm8BmSkbrdFl67Tamq9Iv8ATzsNpVEY9Z HCfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=4emsvIZ2LVSqtDh3vB0TU0VLqoub3VroqaGioososHU=; b=sKzckfmyGpRXjchyPxeaY8TCH5mch4N23Por04Rc22m8THhIOyqdkqKaRf83DHZ5Xt 4/ZlhawHMfWPdK8/CAG+pPw3iChI1GcNbWCXXf05eDJgPuOvLJwu3q745bFAg0N7Mutl g6I6hyA5UVJPTKHVWce86XlbmZLF9QEt1gCDOP06TFU+uhCFYhHDTnkmqlHUS6uUtof4 ZRpxLoD3kZluCY2guhOpCVNkL1TE2DQRbedPMf6Eh+zi1KuoIpe8X3XZwAI62QQUZDFw cO41bBCYiyGHWItDJkNaj3qE0jXvZHWc+JsoMsIm5B3hVCI/iDsnYVw3chfdTTUexNdw v9UQ== 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 t1-v6si4699890plr.558.2018.02.16.04.06.23; Fri, 16 Feb 2018 04:06:38 -0800 (PST) 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 S1166207AbeBOSQv (ORCPT + 99 others); Thu, 15 Feb 2018 13:16:51 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:53460 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163601AbeBOP10 (ORCPT ); Thu, 15 Feb 2018 10:27:26 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 6CB6FBD1; Thu, 15 Feb 2018 15:27:25 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Hans Verkuil , Sakari Ailus , Mauro Carvalho Chehab Subject: [PATCH 4.9 45/88] media: v4l2-compat-ioctl32.c: copy clip list in put_v4l2_window32 Date: Thu, 15 Feb 2018 16:17:12 +0100 Message-Id: <20180215151228.913241826@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151222.437136975@linuxfoundation.org> References: <20180215151222.437136975@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hans Verkuil commit a751be5b142ef6bcbbb96d9899516f4d9c8d0ef4 upstream. put_v4l2_window32() didn't copy back the clip list to userspace. Drivers can update the clip rectangles, so this should be done. Signed-off-by: Hans Verkuil Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 59 +++++++++++++++++--------- 1 file changed, 40 insertions(+), 19 deletions(-) --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c @@ -50,6 +50,11 @@ struct v4l2_window32 { static int get_v4l2_window32(struct v4l2_window *kp, struct v4l2_window32 __user *up) { + struct v4l2_clip32 __user *uclips; + struct v4l2_clip __user *kclips; + compat_caddr_t p; + u32 n; + if (!access_ok(VERIFY_READ, up, sizeof(*up)) || copy_from_user(&kp->w, &up->w, sizeof(up->w)) || get_user(kp->field, &up->field) || @@ -59,38 +64,54 @@ static int get_v4l2_window32(struct v4l2 return -EFAULT; if (kp->clipcount > 2048) return -EINVAL; - if (kp->clipcount) { - struct v4l2_clip32 __user *uclips; - struct v4l2_clip __user *kclips; - int n = kp->clipcount; - compat_caddr_t p; + if (!kp->clipcount) { + kp->clips = NULL; + return 0; + } - if (get_user(p, &up->clips)) + n = kp->clipcount; + if (get_user(p, &up->clips)) + return -EFAULT; + uclips = compat_ptr(p); + kclips = compat_alloc_user_space(n * sizeof(*kclips)); + kp->clips = kclips; + while (n--) { + if (copy_in_user(&kclips->c, &uclips->c, sizeof(uclips->c))) return -EFAULT; - uclips = compat_ptr(p); - kclips = compat_alloc_user_space(n * sizeof(*kclips)); - kp->clips = kclips; - while (--n >= 0) { - if (copy_in_user(&kclips->c, &uclips->c, sizeof(uclips->c))) - return -EFAULT; - if (put_user(n ? kclips + 1 : NULL, &kclips->next)) - return -EFAULT; - uclips += 1; - kclips += 1; - } - } else - kp->clips = NULL; + if (put_user(n ? kclips + 1 : NULL, &kclips->next)) + return -EFAULT; + uclips++; + kclips++; + } return 0; } static int put_v4l2_window32(struct v4l2_window *kp, struct v4l2_window32 __user *up) { + struct v4l2_clip __user *kclips = kp->clips; + struct v4l2_clip32 __user *uclips; + u32 n = kp->clipcount; + compat_caddr_t p; + if (copy_to_user(&up->w, &kp->w, sizeof(kp->w)) || put_user(kp->field, &up->field) || put_user(kp->chromakey, &up->chromakey) || put_user(kp->clipcount, &up->clipcount) || put_user(kp->global_alpha, &up->global_alpha)) return -EFAULT; + + if (!kp->clipcount) + return 0; + + if (get_user(p, &up->clips)) + return -EFAULT; + uclips = compat_ptr(p); + while (n--) { + if (copy_in_user(&uclips->c, &kclips->c, sizeof(uclips->c))) + return -EFAULT; + uclips++; + kclips++; + } return 0; }