Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7540219ybi; Mon, 8 Jul 2019 23:59:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwl4Oga6aEgRJEJzor0pXtZYguOlTiqDmQu9tR7/Qia/ni+OdwCWQsFf7MFFbBwyfYoubme X-Received: by 2002:a17:90a:d998:: with SMTP id d24mr30603120pjv.89.1562655585845; Mon, 08 Jul 2019 23:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562655585; cv=none; d=google.com; s=arc-20160816; b=ok835W9pSfIWlpp7c/Q+gpCHBXuOz26wVp2oMH8xFlmVs81IjJbr0L9hrIGeIDXDkM H2a5pCNS+/wx7xTGIB31jzb4un+SsuPIXRbX/KPAr27un+DtwoF3fOKbqNShQu4dQXN0 7JJFXu+GPAO3j5pxZliYQbAbd/gjor7NnHJdkC/RzQpvjC63+GD9UxLhNEDSdiS/+D7/ w1/egsXrkuz5pyHk2l7ALqXWWNutqPCl5WYSH8aFiPiypVeHhu3yH7qZ+DJXeD0N4DMW iUo/T9ffC2RsIbpSkCgJ21pJhAyic23LNFYENuDY5zE9hpXzeYHY69rj6NS2AGLW+0l/ 3yqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=E3G1rTHrjCP2mm5ed3AgXgMF8NLC4MvUlOmmUi9lRvM=; b=CSuH4Tq51xJzf7tjD4AaAEisws7dWwvN8yCk0RmXkUI2SLua/gxcykqbFFT7ossxjR 7edRBVSP7U2MxNENQ2yIx+NsgJDC11VGwEFVf2WFexQwOzpgmUY56G88XFPK9LbVkecG +vmyPojfemaQ+DdupkeEMu9cwlKMsCkWObNi9DX4BiKGdewR+cYtGzu99AEbz/a8RGew ZHnKlYyX/47dGWEieH6ZjoJrLHaoNa2Yx29zUH1pBS3XqIgmecwj8lsdHi7qU2yMe4zO 5V81BmuyleYdrqlc/sl7YaXzgYY9Q1dMUtzm50ZyBzFRyX/JaExt/80L32zyUiBmTH+L vy6Q== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 78si20618988pga.411.2019.07.08.23.59.30; Mon, 08 Jul 2019 23:59:45 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726010AbfGIG6R (ORCPT + 99 others); Tue, 9 Jul 2019 02:58:17 -0400 Received: from mga07.intel.com ([134.134.136.100]:49998 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725818AbfGIG6Q (ORCPT ); Tue, 9 Jul 2019 02:58:16 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jul 2019 23:58:15 -0700 X-IronPort-AV: E=Sophos;i="5.63,469,1557212400"; d="scan'208";a="159369367" Received: from jkrzyszt-desk.igk.intel.com ([172.22.244.18]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jul 2019 23:58:13 -0700 From: Janusz Krzysztofik To: Chris Wilson , =?UTF-8?q?Micha=C5=82=20Winiarski?= Cc: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , =?UTF-8?q?Micha=C5=82=20Wajdeczko?= , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH] drm/i915: Fix reporting of size of created GEM object Date: Tue, 9 Jul 2019 08:58:00 +0200 Message-Id: <20190709065800.2354-1-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit e163484afa8d ("drm/i915: Update size upon return from GEM_CREATE") (re)introduced reporting of actual size of created GEM objects, possibly rounded up on object alignment. Unfortunately, its implementation resulted in a possible use-after-free bug. The bug has been fixed by commit 929eec99f5fd ("drm/i915: Avoid use-after-free in reporting create.size") at the cost of possibly incorrect value being reported as actual object size. Safely restore correct reporting by capturing actual size of created GEM object before a reference to the object is put. Fixes: 929eec99f5fd ("drm/i915: Avoid use-after-free in reporting create.size") Signed-off-by: Janusz Krzysztofik --- drivers/gpu/drm/i915/i915_gem.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 7ade42b8ec99..16bae5870d6f 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -171,6 +171,7 @@ i915_gem_create(struct drm_file *file, obj = i915_gem_object_create_shmem(dev_priv, size); if (IS_ERR(obj)) return PTR_ERR(obj); + size = obj->base.size; ret = drm_gem_handle_create(file, &obj->base, &handle); /* drop reference from allocate - handle holds it now */ -- 2.21.0