From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 EB75434107D; Thu, 2 Jul 2026 16:43:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783010630; cv=none; b=FNuNn6hyCW4YiZGj58aWY8X9McHVYmhuz0eeeyfPeUxKOQl3gYO0t4pPHRhoMH4ayOJbzQQaW6p4cT6nN5Gn2NZ47jPv3R01ZPQDyNIbpAj9payfdZbMzeWoPDKlVFaTox7OmNmn95oyxmt74Gb1nn7ZucTcyHmgZSixg7yM25o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783010630; c=relaxed/simple; bh=fwprHNEhCWjOl+whDHL2/wNidYAVJeBBVj9DTvKUdVA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h5OQiwlV+yKa1Iy45aIcNHyZej2xpdBU+StZZBXaL4558lMxvXM0t/S9DVWoWVZE55ercQydXv+xPz/A4iWnMBHWxzp6fVl6+8fGloEHjVW6NqX/UKsc2rMf+n1CFCDthvjIeeOtHBbhBqmy73+r24G0SKKsO9NmL2PVkQorwuM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=eGUYsDd+; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="eGUYsDd+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D4BF1F000E9; Thu, 2 Jul 2026 16:43:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1783010629; bh=/07RTFSguWiRhQdiUDHEBsVlbH26Iad7eYIM7O+HLoA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eGUYsDd+rocQb4iie+pPix6I3Zv3t/AVIxiujSF8WeM6uVlEojC7XbHu20r1BTK07 39ZeJec4K2Sric9dSaMvbpWbR+BQwDYHGqqbVWby7eVbs7Gg2YmkAeOigrI0RpnzqS cfXzFhBXcxSPupU7RXhCT8LSyIWQbNfoh3APc/QI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tuo Li , Helge Deller Subject: [PATCH 6.12 182/204] fbdev: modedb: fix a possible UAF in fb_find_mode() Date: Thu, 2 Jul 2026 18:20:39 +0200 Message-ID: <20260702155122.471742354@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260702155118.667618796@linuxfoundation.org> References: <20260702155118.667618796@linuxfoundation.org> User-Agent: quilt/0.69 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-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tuo Li commit 85b6256469cebdac395e7447147e06b2e151014f upstream. If mode_option is NULL, it is assigned from mode_option_buf: if (!mode_option) { fb_get_options(NULL, &mode_option_buf); mode_option = mode_option_buf; } Later, name is assigned from mode_option: const char *name = mode_option; However, mode_option_buf is freed before name is no longer used: kfree(mode_option_buf); while name is still accessed by: if ((name_matches(db[i], name, namelen) || Since name aliases mode_option_buf, this may result in a use-after-free. Fix this by extending the lifetime of mode_option_buf until the end of the function by using scope-based resource management for cleanup. Signed-off-by: Tuo Li Cc: stable@vger.kernel.org # v6.5+ Signed-off-by: Helge Deller Signed-off-by: Greg Kroah-Hartman --- drivers/video/fbdev/core/modedb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/video/fbdev/core/modedb.c +++ b/drivers/video/fbdev/core/modedb.c @@ -625,7 +625,7 @@ int fb_find_mode(struct fb_var_screeninf const struct fb_videomode *default_mode, unsigned int default_bpp) { - char *mode_option_buf = NULL; + char *mode_option_buf __free(kfree) = NULL; int i; /* Set up defaults */ @@ -723,7 +723,6 @@ int fb_find_mode(struct fb_var_screeninf res_specified = 1; } done: - kfree(mode_option_buf); if (cvt) { struct fb_videomode cvt_mode; int ret;