From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E6DCC43381 for ; Mon, 18 Feb 2019 11:45:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4CC632177E for ; Mon, 18 Feb 2019 11:45:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550490353; bh=nJ6qqCeNFYQ7hLOSbZzzKi8wB5OYO6kK+VAUcs7AypI=; h=Subject:To:Cc:From:Date:List-ID:From; b=1h4fUKKchjoMudzLUZamhBvLEDNmPCvpDR9o+hca6yjRsJ0UQPxYE0u3f16I0mylz ok/cYfgmP1DHqCabRZbhwKqDCAgLUYWZIHS219scM6l9Gd8VQ6C4+OGJ5vE50yG6xA pMMj/C/9aNErqiAea8+1ngqzL1UjKvDYDfZcHJWY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728954AbfBRLpw (ORCPT ); Mon, 18 Feb 2019 06:45:52 -0500 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:54847 "EHLO out2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728915AbfBRLpw (ORCPT ); Mon, 18 Feb 2019 06:45:52 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 694F0221AD; Mon, 18 Feb 2019 06:45:51 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 18 Feb 2019 06:45:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=mgf9z0 tcHYotpWeagq1CAbm7IQSQm+OvKQQr+auvpXI=; b=yVLy5I5nAWtVpjABUYdALN 7oPLn+Ncr0vq4qMLXli/Ym/XloZmRtCfOoUvU9YpV+jsKxeF5akHu9bVYSyLFXvY apAG9G24jiaiOx7jeqGgKjC5/1jo8zuXVkQRRVjqqkr5h0Y6gG68Db8Gyf7BRqCv FN7w/WY8WUXlO5Ypgk21SGa2JmenlrBStvjbpL62GYPqrUh1ZiEaODkowdAqesCy /IhRvqP5Y50TCZrmVSKS8gfzeV6qK/pjOJtfAHLmLl8P8GgTSmODDIO3wKhxjJ3N gA3L68YDOw8FETqEZAiTPP21xgvy31oZos8Ld1UxPJOeSeLS6WTEeASaMVWpSTaQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrtdduucdltddurdegtdelrddttddmucetuf doteggodetrfdotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfquhhtnecuuegr ihhlohhuthemuceftddtnecunecujfgurhepuffvhfffkfggtgfgsehtkeertddttdflne cuhfhrohhmpeeoghhrvghgkhhhsehlihhnuhigfhhouhhnuggrthhiohhnrdhorhhgqeen ucffohhmrghinhepfhhrvggvuggvshhkthhophdrohhrghenucfkphepkeefrdekiedrke elrddutdejnecurfgrrhgrmhepmhgrihhlfhhrohhmpehgrhgvgheskhhrohgrhhdrtgho mhenucevlhhushhtvghrufhiiigvpeeg X-ME-Proxy: Received: from localhost (5356596b.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) by mail.messagingengine.com (Postfix) with ESMTPA id 942CCE41AC; Mon, 18 Feb 2019 06:45:50 -0500 (EST) Subject: FAILED: patch "[PATCH] drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC" failed to apply to 4.4-stable tree To: joonas.lahtinen@linux.intel.com, adamza@microsoft.com, akash.goel@intel.com, chris@chris-wilson.co.uk, jani.nikula@intel.com, stable@vger.kernel.org, torvalds@linux-foundation.org, tvrtko.ursulin@intel.com, tvrtko.ursulin@linux.intel.com Cc: From: Date: Mon, 18 Feb 2019 12:45:49 +0100 Message-ID: <155049034970202@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 4.4-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 2e7bd10e05afb866b5fb13eda25095c35d7a27cc Mon Sep 17 00:00:00 2001 From: Joonas Lahtinen Date: Thu, 7 Feb 2019 10:54:53 +0200 Subject: [PATCH] drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set Make sure the underlying VMA in the process address space is the same as it was during vm_mmap to avoid applying WC to wrong VMA. A more long-term solution would be to have vm_mmap_locked variant in linux/mmap.h for when caller wants to hold mmap_sem for an extended duration. v2: - Refactor the compare function Fixes: 1816f9236303 ("drm/i915: Support creation of unbound wc user mappings for objects") Reported-by: Adam Zabrocki Suggested-by: Linus Torvalds Signed-off-by: Joonas Lahtinen Cc: # v4.0+ Cc: Akash Goel Cc: Chris Wilson Cc: Tvrtko Ursulin Cc: Adam Zabrocki Reviewed-by: Chris Wilson Reviewed-by: Tvrtko Ursulin #v1 Link: https://patchwork.freedesktop.org/patch/msgid/20190207085454.10598-1-joonas.lahtinen@linux.intel.com (cherry picked from commit 5c4604e757ba9b193b09768d75a7d2105a5b883f) Signed-off-by: Jani Nikula diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 216f52b744a6..c882ea94172c 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -1824,6 +1824,16 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data, return 0; } +static inline bool +__vma_matches(struct vm_area_struct *vma, struct file *filp, + unsigned long addr, unsigned long size) +{ + if (vma->vm_file != filp) + return false; + + return vma->vm_start == addr && (vma->vm_end - vma->vm_start) == size; +} + /** * i915_gem_mmap_ioctl - Maps the contents of an object, returning the address * it is mapped to. @@ -1882,7 +1892,7 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data, return -EINTR; } vma = find_vma(mm, addr); - if (vma) + if (vma && __vma_matches(vma, obj->base.filp, addr, args->size)) vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags)); else