Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3339425imu; Sun, 11 Nov 2018 12:43:50 -0800 (PST) X-Google-Smtp-Source: AJdET5cMsTHk6NcKwGLaL4wCyAEcPLN5P9GVu4h5DZ5QZADlb2EWfsnP4SXxFjjoza5qV1MS/3O+ X-Received: by 2002:a17:902:7d98:: with SMTP id a24-v6mr17472948plm.271.1541969030513; Sun, 11 Nov 2018 12:43:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541969030; cv=none; d=google.com; s=arc-20160816; b=elHYok+DhDoLQo1uVZCjabSiN0c3zCYd0XnYrnUxsSJDbObzyJ68I0S4rKDa+wxXY5 7+dG2ccmVIrUxecc0f93RjwyrzApUyj06+cymjiD9BUcdG3x896S5XTp0tc3HxYKOeqd ZXCMgE8bgHXk/k9TQbJYs3B5VtA3sNaLoDn/pST/+XR21BYKVYafv8lFTwuv2gdeGKy8 xBDwQQ4X26F0uBFaUv0qy4ErmQ7J1MII5dcBE2TiVKD9lSOOv+jpYc+BlqfSX0x3Rj8q jMG/DRjI1O+fYFvpdmLUduyki0wsv30Jnk8miJHy6pdNxvCfz1HpzKrazfvzIySd/AnO R8bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=sX87CliYClMsoqjXHTGd+DeSw8pphyP+Yu6Gwr+X4mM=; b=n7LVltG6LIPgvJKBkChDqNFuY9BgYDsz7sPkYersz0PQEebEJxJeFKENR39xw1kn63 PympLDyjQ9LwRRZxqpLP80z1ejSl9foP3Fte+ESLfzySf8ulAZ8qa+nbZUztkeiEJ7Z7 AgWSIvPBFm/ieFe0GhJ4+NwHr4xuebm0z4+OsSTBeu6r5sI0yLIFQ/H/2dB7YiX/oR5/ FhUsiP9r86lCDSZ/zVxe+bAiQMl109B5flsS1qHWvqQ/NqC8E2Ksa+aW2soFSGa0ouVG ydk9Nnv2W2RmnKHR4MeNwP6KML4W8Tfq8yviwZYvYxZHz4X+K/4r0DdFNMS//Z/N5nzT 8HKw== 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 a34-v6si16529090pld.249.2018.11.11.12.43.34; Sun, 11 Nov 2018 12:43:50 -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 S1729791AbeKLFsB (ORCPT + 99 others); Mon, 12 Nov 2018 00:48:01 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:49300 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729555AbeKLFsB (ORCPT ); Mon, 12 Nov 2018 00:48:01 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvsO-0000lN-5J; Sun, 11 Nov 2018 19:58:32 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsN-0001NY-St; Sun, 11 Nov 2018 19:58:31 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Mauro Carvalho Chehab" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 019/366] media: v4l2-compat-ioctl32: prevent go past max size In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Mauro Carvalho Chehab commit ea72fbf588ac9c017224dcdaa2019ff52ca56fee upstream. As warned by smatch: drivers/media/v4l2-core/v4l2-compat-ioctl32.c:879 put_v4l2_ext_controls32() warn: check for integer overflow 'count' The access_ok() logic should check for too big arrays too. Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Ben Hutchings --- drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c @@ -848,7 +848,7 @@ static int put_v4l2_ext_controls32(struc get_user(kcontrols, &kp->controls)) return -EFAULT; - if (!count) + if (!count || count > (U32_MAX/sizeof(*ucontrols))) return 0; if (get_user(p, &up->controls)) return -EFAULT;