Received: by 10.223.185.116 with SMTP id b49csp168429wrg; Thu, 15 Feb 2018 19:06:35 -0800 (PST) X-Google-Smtp-Source: AH8x227CtyjIOl0PAsUHAiYlATLIzrDdDOrP9SAYdnbMHySri8MzUUwiIBOrwZQDQTY2Spu8eoWx X-Received: by 2002:a17:902:8d81:: with SMTP id v1-v6mr4444467plo.430.1518750395486; Thu, 15 Feb 2018 19:06:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518750395; cv=none; d=google.com; s=arc-20160816; b=BL/ZjLkxt5pxirNTjWcck/y+3CtYiFsVZBTCzT9njxE/0aFUEAXCK5Lv1ELzxARGqk 0G2fcaHApSg6f8vcqZILOUK5GVarf02E7B8JP1JZbExT3kBS3YHiErdYpOmfBAG8mt+M 07mENVJAbd6DspoQ9HhygukLVUyg6o1w7XKRcGhc4JYczudnwGSCTXy25Bs1IRHB7+g9 +oJxx2kFdGVTko+Fw5q1XfcjvSx4YgkJ5A4PneAzV+MVTvluX9tQTy0CCC/owvxcNtgs jI8YVwsZpXYVimoYD8fiQKd1vkeopEmIHADTvf1D0uzCGflgQspVq95MvHcxbLA3/Oyd wCvw== 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=zLwEo7PbKsypSOfg/nP0W1eTlfqUhN787ZsnDWiW/7o=; b=dgGGp8ik1rE4Ld/CXMDZvRv3Og6F55BGp8T6CZ1YHgCAyc6HuTnYDzcyuQ9Zl99GTZ lwIeau+G7rNVXw0zgstMToLrdmLpozwLNzpsDOFJn20m7+D+fbujcGelLp+r03zbVLHA z3/enB2hzvxyncl+z3xGmEh+kSjvMPSXNeenGewVtOqPG/eaUaJ1NxxV4cXf1rdlcmtw ZAO8TYIlkOaRNaFAy9iofV2ZkjIwuTmZLyC5tG2EZkINdP990vvIqppPUp7mBRn4DGGJ 9o4zb79aJV6TMNTfXAOdAjzSVkG9KOWQFBmf8FXqcOXnz8C1szFOvIMOhYwzG3Ia2Rky a4Pg== 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 z76si3437672pgz.781.2018.02.15.19.06.20; Thu, 15 Feb 2018 19:06:35 -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 S1165449AbeBOPoS (ORCPT + 99 others); Thu, 15 Feb 2018 10:44:18 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:34312 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1165417AbeBOPoO (ORCPT ); Thu, 15 Feb 2018 10:44:14 -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 CFC551199; Thu, 15 Feb 2018 15:44:13 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans Verkuil , Sakari Ailus , Mauro Carvalho Chehab Subject: [PATCH 4.15 122/202] media: v4l2-compat-ioctl32.c: copy clip list in put_v4l2_window32 Date: Thu, 15 Feb 2018 16:17:02 +0100 Message-Id: <20180215151719.653707996@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@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.15-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; }