From patchwork Tue Feb 16 11:49:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 8324361 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 342049FC6A for ; Tue, 16 Feb 2016 11:49:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 73B3520295 for ; Tue, 16 Feb 2016 11:49:45 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 76810202BE for ; Tue, 16 Feb 2016 11:49:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 64B3B6E7AA; Tue, 16 Feb 2016 11:49:42 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id 26F26897FF for ; Tue, 16 Feb 2016 11:49:40 +0000 (UTC) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 451238E236; Tue, 16 Feb 2016 11:49:39 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-27.ams2.redhat.com [10.36.116.27]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1GBnb8N029060; Tue, 16 Feb 2016 06:49:38 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id C25A5818C4; Tue, 16 Feb 2016 12:49:36 +0100 (CET) From: Gerd Hoffmann To: David Airlie Subject: [PATCH] qxl: apply limit to relocs_num in qxl_process_single_command Date: Tue, 16 Feb 2016 12:49:23 +0100 Message-Id: <1455623363-9224-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Cc: gnomes@lxorguk.ukuu.org.uk, "open list:DRM DRIVERS" , stable@vger.kernel.org, open list X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 Limit relocs_num to 65536. That limit is small enougth to avoid integer overflow on 32bit machines when calculating reloc_info size (as reported by Alan Cox), and is big enougth to not block normal usage (kmalloc would ENOMEM on requests larger than that anyway). Cc: stable@vger.kernel.org Cc: gnomes@lxorguk.ukuu.org.uk Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/qxl/qxl_ioctl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/drivers/gpu/drm/qxl/qxl_ioctl.c index 2ae8577..970cb83 100644 --- a/drivers/gpu/drm/qxl/qxl_ioctl.c +++ b/drivers/gpu/drm/qxl/qxl_ioctl.c @@ -168,6 +168,8 @@ static int qxl_process_single_command(struct qxl_device *qdev, cmd->command_size)) return -EFAULT; + if (cmd->relocs_num > 65536) + return -EINVAL; reloc_info = kmalloc(sizeof(struct qxl_reloc_info) * cmd->relocs_num, GFP_KERNEL); if (!reloc_info) return -ENOMEM;