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 B28B31DEFE1; Tue, 8 Oct 2024 12:20:41 +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=1728390041; cv=none; b=RMgDHQl4MkYAaj5R5ObhhB4cLG0/m/BT0ojNdLth/x0A9OhWLrNWwwc2mcSOt+GtF4+GAnlwJR4JcOmb7pB/30tdDzNwWjgW1ZtPguaRTm8pD10DPDMEspN3t4oElaUyDdw22J+A3fteL3qUm1JRjIaFNzgXwm5xHeMjWTqcfU4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728390041; c=relaxed/simple; bh=Ub/HuRS9WoQmskrPmicmxmDzwWnnCi049r5uW3WPjDg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pk625s+sN2NHMQJMOg0sWzUJnRw0EjK/4bLDs/vjSpsU66sWLYwBlcXv3XmzLcoKhWBxZk2kGzpvTJwCnGKMwE3ifhmrOMZxtfbNTEL7imCylGYNf2jz8GH0liPg40RhboS0MdOH09vR4eQmu/riHy5RpDq3HQrKD3NuMm8BBc0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=u/6VeJwa; 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="u/6VeJwa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18F65C4CEC7; Tue, 8 Oct 2024 12:20:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728390041; bh=Ub/HuRS9WoQmskrPmicmxmDzwWnnCi049r5uW3WPjDg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u/6VeJwas5g4qWrQVHC/rMyV9vf8PtPaiK5vOOON2K6QzUel6ZZapNUjWrZZ9pVGF Zm+wb51muwyI3PzieYMknWW/1MhBrbD0vjZHxQZiSDMrVQT74E+FIFAo8qWM7afJ0I v3aK7z+5f3plsf0bIe4nPJQINEElVknobkukCmfM= 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.10 173/482] drm/stm: Avoid use-after-free issues with crtc and plane Date: Tue, 8 Oct 2024 14:03:56 +0200 Message-ID: <20241008115655.113925490@linuxfoundation.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241008115648.280954295@linuxfoundation.org> References: <20241008115648.280954295@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.10-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