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 E955B1C4613; Tue, 8 Oct 2024 12:48:43 +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=1728391724; cv=none; b=T6GUmVQyLI/SBP7N0IhCH4gsSMyvIQIZtw6Fl+mPB9IU6Y0IcJ+GAAmsIPjdHo/mqZtVcl3ODVB6tXH4MDc/LEMfI8S67zgKtc7uaAoc25eRJXGsGcNW6sSEoDAhAhdKc1+1Nad9442ekfc6QV/REOjlBu9+hHrVrE2G2Z0ueuE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728391724; c=relaxed/simple; bh=KncRmxT9v7DZ5NwA0fw0MHpMGN5R7PzVQXclRfDwDOg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hR8kJdqZ4qF4iwHJR1p+Awg19UEUYJghKvDg1eJ4J0PB3gYRFyFkdM60ADTeN8QvkEaxLeZHSrrWO0caNoCUTqlBUG8IFUsp5/wF6t/ae9zdY+YEMxR9nEJJQCZr8CE4LrZLFa7i26ddDLiinnX6ZKr21m8956ARa+lBqxt5DD8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=BtjnCjJs; 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="BtjnCjJs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55C6CC4CECC; Tue, 8 Oct 2024 12:48:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728391723; bh=KncRmxT9v7DZ5NwA0fw0MHpMGN5R7PzVQXclRfDwDOg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BtjnCjJsn0Jg2myH4flDi9rBtHWvbsLxhyZNyNnzeC7LsuBgUSPS4FhLNWEUHqL+O gKvonWkCEgp5V/WzN4OPbVPIV+/J4hZqypGGSSglSYdjerJce/ezsOSj5zbxA2AsQw Fh9INw8bGyeRxh6s1LMrG+ukngB2mR3y1MxhuTQE= 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.11 202/558] drm/stm: Avoid use-after-free issues with crtc and plane Date: Tue, 8 Oct 2024 14:03:52 +0200 Message-ID: <20241008115710.296585251@linuxfoundation.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241008115702.214071228@linuxfoundation.org> References: <20241008115702.214071228@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.11-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