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 918BA1D3653; Tue, 8 Oct 2024 13:16:07 +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=1728393367; cv=none; b=K3qJ1bBjJrp2zEapQ8ou0DyxX1kwq0TS24xxQ8hratGbK0Xsr2M0kEtoEdyu4G3T+Nq6dHNY38/nzj76z9QKykgfLnlx+6rEMHdKmdpQk4NvTfExxWnm8t5aICUIGut+1hHBF1w04OVRGJkUiq7EmVdc4MyTV+bHyEiB34RHmgA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728393367; c=relaxed/simple; bh=zOWx1OXUHnhgYnu0rAgqDQsLapHN+j7zv8lv22AOHas=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iyftOjcH2bjMXrT7/+wPUuGra57t8PBnR/UaNWespaljj+XE+AiMNQh97+HjbCMFscJAUIa5qveRolswOWnlh6j4oyMmOQ6DkErp3krRH3seVawH6Dc9fWjCmoGxpEIeHYYq1OZtzebj88kVW9jFc9Ms+aee3NPEkPC+C0cQOoA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=i9xCT+59; 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="i9xCT+59" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F240EC4CEC7; Tue, 8 Oct 2024 13:16:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728393367; bh=zOWx1OXUHnhgYnu0rAgqDQsLapHN+j7zv8lv22AOHas=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i9xCT+59DaJmQJtJ0yMhL6f2ZqB1lvMLF072/pOVlN6ljg/y+wwZ2Ee/zo7XXDwu4 EJg45eJmti/IFJ32W414B+MJaf4RwKD7g9D4Bxi4+LdzZVKCu1YKisfBgU05KSCvJu 7e6s/TIbWcswCM1VpffJeuBjtqExYauc4zIwr4As= 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.6 131/386] drm/stm: Avoid use-after-free issues with crtc and plane Date: Tue, 8 Oct 2024 14:06:16 +0200 Message-ID: <20241008115634.591931252@linuxfoundation.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241008115629.309157387@linuxfoundation.org> References: <20241008115629.309157387@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-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 4d2db079ad4ff..e1232f74dfa53 100644 --- a/drivers/gpu/drm/stm/drv.c +++ b/drivers/gpu/drm/stm/drv.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "ltdc.h" @@ -75,7 +76,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 5aec1e58c968c..056642d12265c 100644 --- a/drivers/gpu/drm/stm/ltdc.c +++ b/drivers/gpu/drm/stm/ltdc.c @@ -36,6 +36,7 @@ #include #include #include +#include #include