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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B2C0C77B6F for ; Tue, 11 Apr 2023 13:24:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229822AbjDKNYT (ORCPT ); Tue, 11 Apr 2023 09:24:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229667AbjDKNYS (ORCPT ); Tue, 11 Apr 2023 09:24:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E113449D8 for ; Tue, 11 Apr 2023 06:24:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7F21461DEE for ; Tue, 11 Apr 2023 13:24:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92A5CC433EF; Tue, 11 Apr 2023 13:24:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1681219456; bh=Vsrx+R/M3AmdzKNWyMot0W9sLksj1wjCBRfvDVhtfo8=; h=Subject:To:Cc:From:Date:From; b=GG7uqnm7VMkgszR2538i5JYONYZ4284/h0x+6S0LHNkLKcjCe/LIP1i+5mE9loTpU Un4YXUQuqpb2BtDGTgVnIUspn7lBwhlw+ccwj8DnnzRSVHlHw5qgjlgy8fPnefHZaF b4v8vIgFA1clAEIBP50+5HbGdFJ8qWXPNMNf4wSw= Subject: FAILED: patch "[PATCH] drm/i915: fix race condition UAF in" failed to apply to 4.14-stable tree To: lm0963hack@gmail.com, andi.shyti@linux.intel.com, jani.nikula@intel.com, stable@vger.kernel.org, tvrtko.ursulin@intel.com, umesh.nerlige.ramappa@intel.com Cc: From: Date: Tue, 11 Apr 2023 15:24:06 +0200 Message-ID: <2023041105-shakily-screen-fbb6@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 4.14-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 . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-4.14.y git checkout FETCH_HEAD git cherry-pick -x dc30c011469165d57af9adac5baff7d767d20e5c # git commit -s git send-email --to '' --in-reply-to '2023041105-shakily-screen-fbb6@gregkh' --subject-prefix 'PATCH 4.14.y' HEAD^.. Possible dependencies: dc30c0114691 ("drm/i915: fix race condition UAF in i915_perf_add_config_ioctl") 2fec539112e8 ("i915/perf: Replace DRM_DEBUG with driver specific drm_dbg call") 046d1660daee ("drm/i915/gem: Return an error ptr from context_lookup") a4839cb1137b ("drm/i915: Stop manually RCU banging in reset_stats_ioctl (v2)") 651e7d48577a ("drm/i915: replace IS_GEN and friends with GRAPHICS_VER") ec2b1485a065 ("drm/i915/dmc: s/HAS_CSR/HAS_DMC") c24760cf42c3 ("drm/i915/dmc: s/intel_csr/intel_dmc") 93e7e61eb448 ("drm/i915/display: rename display version macros") 4df9c1ae7a4b ("drm/i915: rename display.version to display.ver") 6c51f288b41f ("drm/i915: Don't use {skl, cnl}_hpd_pin() for bxt/glk") 0fe6637d9852 ("drm/i915: Restore lost glk ccs w/a") 87b8c3bc8d27 ("drm/i915: Restore lost glk FBC 16bpp w/a") 2446e1d6433b ("drm/i915/display: Eliminate IS_GEN9_{BC,LP}") 9c0fed84d575 ("Merge tag 'drm-intel-next-2021-04-01' of git://anongit.freedesktop.org/drm/drm-intel into drm-next") thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From dc30c011469165d57af9adac5baff7d767d20e5c Mon Sep 17 00:00:00 2001 From: Min Li Date: Tue, 28 Mar 2023 17:36:27 +0800 Subject: [PATCH] drm/i915: fix race condition UAF in i915_perf_add_config_ioctl Userspace can guess the id value and try to race oa_config object creation with config remove, resulting in a use-after-free if we dereference the object after unlocking the metrics_lock. For that reason, unlocking the metrics_lock must be done after we are done dereferencing the object. Signed-off-by: Min Li Fixes: f89823c21224 ("drm/i915/perf: Implement I915_PERF_ADD/REMOVE_CONFIG interface") Cc: # v4.14+ Reviewed-by: Andi Shyti Reviewed-by: Umesh Nerlige Ramappa Signed-off-by: Tvrtko Ursulin Link: https://patchwork.freedesktop.org/patch/msgid/20230328093627.5067-1-lm0963hack@gmail.com [tursulin: Manually added stable tag.] (cherry picked from commit 49f6f6483b652108bcb73accd0204a464b922395) Signed-off-by: Jani Nikula diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index 283a4a3c6862..004074936300 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -4638,13 +4638,13 @@ int i915_perf_add_config_ioctl(struct drm_device *dev, void *data, err = oa_config->id; goto sysfs_err; } - - mutex_unlock(&perf->metrics_lock); + id = oa_config->id; drm_dbg(&perf->i915->drm, "Added config %s id=%i\n", oa_config->uuid, oa_config->id); + mutex_unlock(&perf->metrics_lock); - return oa_config->id; + return id; sysfs_err: mutex_unlock(&perf->metrics_lock);