From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDCC41AAE13; Mon, 14 Oct 2024 15:15:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918956; cv=none; b=RBjve1l5HSiSSwO4G1C1qvL0Q6Y7fGmWJhn2fL0RDZQZMh7PjX7VRTWcp3qOnVp4T87pEemqHNf9YnG+kCAcc3hSqxdhUJ1vaLlhsLY0+XQHuhS9e6N/HIMyrdPHj4DU+RUrb1rQtXjv/rVZWtBf07m+XlPpZ3KNJXtt0zpicZA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728918956; c=relaxed/simple; bh=fAlJPAhYXY9FArfY0jKuPy5O3c6tKm5L7AqhNuBzSr0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tvufE+gW3rqp0Y+Ypi5mGyiMTpSGAlaLLMML7OWrE1vvrTH7CEioBhfTT6uyjtoTdNs3jbRK78fivL1LLxDYp7G5J/iLzeAbZI/axqoK3672zSohZ3DaPZvDjsMpHttydQOzYBMnVhIWksrJAk7Nkhookj8HpJGl9N2PjoqIXC4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=W8SrnW/y; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="W8SrnW/y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E77CC4CEC3; Mon, 14 Oct 2024 15:15:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728918956; bh=fAlJPAhYXY9FArfY0jKuPy5O3c6tKm5L7AqhNuBzSr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W8SrnW/yVJtk4GGS+uW0UJx8dWSgQsc7EnPDJ0NvCVl6MnUDCdHKH0EKRY4X4Ez0n mFFPAivD6ZTxwSmtNFqcbfredXXtFsm4ensUGR7hvNWUIZunB/qteCVzR+Bvl7f54d EL42/LibsGVuLIUf6mEDwqZPVk1Zkqb2eYEZLjc0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Katya Orlova , =?UTF-8?q?Rapha=C3=ABl=20Gallais-Pou?= , Sasha Levin Subject: [PATCH 6.1 472/798] drm/stm: Avoid use-after-free issues with crtc and plane Date: Mon, 14 Oct 2024 16:17:06 +0200 Message-ID: <20241014141236.520672951@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241014141217.941104064@linuxfoundation.org> References: <20241014141217.941104064@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Katya Orlova [ Upstream commit 19dd9780b7ac673be95bf6fd6892a184c9db611f ] ltdc_load() calls functions drm_crtc_init_with_planes(), drm_universal_plane_init() and drm_encoder_init(). These functions should not be called with parameters allocated with devm_kzalloc() to avoid use-after-free issues [1]. Use allocations managed by the DRM framework. Found by Linux Verification Center (linuxtesting.org). [1] https://lore.kernel.org/lkml/u366i76e3qhh3ra5oxrtngjtm2u5lterkekcz6y2jkndhuxzli@diujon4h7qwb/ Signed-off-by: Katya Orlova Acked-by: Raphaƫl Gallais-Pou Link: https://patchwork.freedesktop.org/patch/msgid/20240216125040.8968-1-e.orlova@ispras.ru Signed-off-by: Raphael Gallais-Pou Signed-off-by: Sasha Levin --- drivers/gpu/drm/stm/drv.c | 3 +- drivers/gpu/drm/stm/ltdc.c | 73 ++++++++++---------------------------- 2 files changed, 20 insertions(+), 56 deletions(-) diff --git a/drivers/gpu/drm/stm/drv.c b/drivers/gpu/drm/stm/drv.c index 77b1b10456f52..7a3f1b4020292 100644 --- a/drivers/gpu/drm/stm/drv.c +++ b/drivers/gpu/drm/stm/drv.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "ltdc.h" @@ -74,7 +75,7 @@ static int drv_load(struct drm_device *ddev) DRM_DEBUG("%s\n", __func__); - ldev = devm_kzalloc(ddev->dev, sizeof(*ldev), GFP_KERNEL); + ldev = drmm_kzalloc(ddev, sizeof(*ldev), GFP_KERNEL); if (!ldev) return -ENOMEM; diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c index b8c1636168cfa..1d22afcf34ba7 100644 --- a/drivers/gpu/drm/stm/ltdc.c +++ b/drivers/gpu/drm/stm/ltdc.c @@ -37,6 +37,7 @@ #include #include #include +#include #include