Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp234652pxb; Wed, 18 Aug 2021 00:42:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPvFaT08pHwTOmK3KjDw+f/1y9ufUQXLYhb4A+JhAF+2mWsB6//rVILcsqQVUuD0mfY+a1 X-Received: by 2002:a05:6402:202:: with SMTP id t2mr8713228edv.116.1629272563501; Wed, 18 Aug 2021 00:42:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629272563; cv=none; d=google.com; s=arc-20160816; b=gVS1VgHyhYvHIbCVOXVBQFwVihFT93zzSVpu9s+u9eioglmVNB/jXImnMLjZaVI5U/ a1xg0+qHqyNW01rTn6Od42XO2NLnWIumEmn714XqAFbf8/9q6lzcaQMqrO50Ib4fZ1HM ix1MODR06D61NqYKwnrQBN0Z72hc5HxuHkAbSZpFLRLyPL2KQr7JM6lxVIGnE7d6hwqE hOXMJQNOT3zOxe2bdgY0LnOrygHheLmWhVczKqKg0qTIT5jK38EPvCJM+qbb+ZBpa/+h k9qbL44lYptioWkuyO3+/EPbamNSHwda4wbk4k6ILiNrAW732J90ooygI21YZ+7yMrfm GC7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=he3hjgMVhcOXzxQ8ZzPKGe5qy8qOVQuZUYfKXwOfAPg=; b=KA8JH/C1Z/3Px5E1bBDrl1C8If0CW1YF0/QpEmlHe7O07T9x3MHZ8ViZvC2njyjhVh HhDjqTQ1Nfi3gVL+vgIdoR6yse/866Wws4gpAKj1tEp8wDIL0sUibHb1PEVE99REF5qV rYjDEBWEIeC270ed6q8mLS4vZ2oRjUP6ca1DqRqc0xSObquM0nz9W+Ve29VC62T5Nc4D Aoc6ju2H4w2mT8FOSyzgDL3HPm+NzrUUnFrCBRC94FiONXtZRaPPi60B8/oKtJdnGd2p 7339jR/B4Qs5N7lVzAIXgPIw0lLUZAukMygiMO3GqpwGIM3xmHHzDQ7aAt4Jocymd7Cg Omrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=V3ChonAM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 24si5665113edv.346.2021.08.18.00.42.20; Wed, 18 Aug 2021 00:42:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=V3ChonAM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238874AbhHRHlR (ORCPT + 99 others); Wed, 18 Aug 2021 03:41:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239245AbhHRHlM (ORCPT ); Wed, 18 Aug 2021 03:41:12 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D911C061796; Wed, 18 Aug 2021 00:40:38 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id o10so1327142plg.0; Wed, 18 Aug 2021 00:40:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=he3hjgMVhcOXzxQ8ZzPKGe5qy8qOVQuZUYfKXwOfAPg=; b=V3ChonAMDLG13W4R9mt1UZfcDRlf3NYYG5Rp6zwLe9hoPv7kNaLSz1SBaGSu4gacb2 IG7pihFofk738zo0sUjjMECc8BKbXHoRFgXUaz+rksmgG1umJdIhslaO4DouScE25nrz QhQN0KBGfOlxOAV5gm+r9YxMmPtBF13v/W8YFP2iCl19RlJ5zdD+L2hOm2sa+1iKHZGz CgFFYbvwQ/FegyZK22MDmuuW+iQHHAazsx4WnIW9u2x3s0WyVCRHOYH7otiYZitptlk3 7J02sZUKJx/5shMUykUIDn5WogVBsFWvX2MIVtWcImlFFB8LyqmG2vbSKdj3J6amSb+W /hSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=he3hjgMVhcOXzxQ8ZzPKGe5qy8qOVQuZUYfKXwOfAPg=; b=YBXT09Z4Mm9MZxnPeLB53s6OMQFtI4qCWuuEQTx5ZdV/0kTADHqdeiPwsZcDyA7nk0 ej4+VNkKbgm9SzfQoIpRcQVAs0MW+VKHu7MUVpunVxU2/EUGpvbj9zbOW/TpiFCTFF5x hFtDIfAYc6TfbaDTJ2YO1oUyTSzW/CYula56SoKCIQZxQ+LRN/ITWQfDz2Ov26O+Wz5Y JqkmhbqE1ZezoGLqjm8oLWBYKiGEuDP5cVLJkpqDmB2HkQsTHgPp1sgplbbhHhG4WYOz BjfWenJVPyKCoxV3qliqtS9QlrrTq8Xigw6dSB448r6h5Pj1GRjSC1OZZPxndbuwj1kN kPGA== X-Gm-Message-State: AOAM531GLsxjwe9JoD/VPUAOj+REPbmkdvMp9N6kfEgWYvzS8vHKNI3x 3irW24mvyEMRqtcVBL2WlwA= X-Received: by 2002:a17:90a:b009:: with SMTP id x9mr7893927pjq.97.1629272437819; Wed, 18 Aug 2021 00:40:37 -0700 (PDT) Received: from localhost.localdomain ([118.200.190.93]) by smtp.gmail.com with ESMTPSA id u3sm3886729pjr.2.2021.08.18.00.40.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 00:40:37 -0700 (PDT) From: Desmond Cheong Zhi Xi To: maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@linux.ie, daniel@ffwll.ch, sumit.semwal@linaro.org, christian.koenig@amd.com, axboe@kernel.dk, oleg@redhat.com, tglx@linutronix.de, dvyukov@google.com, walter-zh.wu@mediatek.com Cc: Desmond Cheong Zhi Xi , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, skhan@linuxfoundation.org, gregkh@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org Subject: [PATCH v3 3/9] drm: check for null master in drm_is_current_master_locked Date: Wed, 18 Aug 2021 15:38:18 +0800 Message-Id: <20210818073824.1560124-4-desmondcheongzx@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210818073824.1560124-1-desmondcheongzx@gmail.com> References: <20210818073824.1560124-1-desmondcheongzx@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is a window after calling drm_master_release, and before a file is freed, where drm_file can have is_master set to true, but both the drm_file and drm_device have no master. This could result in wrongly approving permissions in drm_is_current_master_locked. Add a check that fpriv->master is non-NULl to guard against this scenario. Signed-off-by: Desmond Cheong Zhi Xi --- drivers/gpu/drm/drm_auth.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c index 8c0e0dba1611..f9267b21556e 100644 --- a/drivers/gpu/drm/drm_auth.c +++ b/drivers/gpu/drm/drm_auth.c @@ -66,7 +66,8 @@ static bool drm_is_current_master_locked(struct drm_file *fpriv) lockdep_assert_once(lockdep_is_held(&fpriv->minor->dev->master_lookup_lock) || lockdep_is_held(&fpriv->minor->dev->master_mutex)); - return fpriv->is_master && drm_lease_owner(fpriv->master) == fpriv->minor->dev->master; + return (fpriv->is_master && fpriv->master && + drm_lease_owner(fpriv->master) == fpriv->minor->dev->master); } /** -- 2.25.1