From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794061553; b=NHcwmf9SCbK/rq/rV4UjysjOzhqRcPfRwKgPcH5arBzZTjf/S1tdt0UwrYf1LuJTbtjZ 7sFgKDogQ3FBpsYaBFGyXiIoyqi/dCzucyUr7lmixHY15Q+aVXT4zlCBT6Wp9rMqJXfhu fiY/bwNekeYePaJnbduPespWGd9gPosT4ViG6lfcxSEBpm1wCDOfibMJ0JtSacDjyFMwY s5azxSF4zuqUSE1JqBk+VjqBy9QNIWRnFCvoMfWRNx79lSPkqlAp5rNP3GYcJcrd1fkBb hNuq35SNg/+DubDd0ganlOl0JVavZziZdBFxDDfPJuxdE9qWurnZ8vAF+u84RXmhpjg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794061553; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=f+aV2u4UM1L7bB8RzB4hF/0HDviY6RgmIgqc1lk4lXo=; b=oRp06G5yUv+UR0M+hUqmaMUlqsLHZUFWj6ldYgFXm31j69al/vu+am7TWcmXkzjaqOR5 BahQT74VAIgzTbDmnDXrRXc3BJKmCHjYK+WW6qa1xzq1KNWgTCmWaFwrNArTQkoTHYm/o VBkM3JWV4wxDXaFA0ZFG4nQ7N+OADz4h4uWimTRfMRP9UNnL0JO37Nb5q5o8LT6j/oFfE SSJcXlyRhhHWcdbU681zsdZom01M6Ax/2p7IbvB9M6qIfdo7gBSA2bFr97OGPP7R3m3r0 W4dVmASRZRt9ZEm9OqqDt3OLsIMtd9J5CcFXqISImn39tuW2HbrLBbF40OnoFa0mnNA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=GUO7ZF9X; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3BF3606A326; Sat, 7 Nov 2026 14:25:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=GUO7ZF9X Received: by smtp.kernel.org (Postfix) with ESMTPSA id 927301F0089F; Sat, 7 Nov 2026 14:25:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1794061552; bh=f+aV2u4UM1L7bB8RzB4hF/0HDviY6RgmIgqc1lk4lXo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GUO7ZF9XanfxU85qDr3gbO82OZTfqhgSThmCO2UQUuUU4vLmyR2EWwvOhXMhZuGxw 8f4l5KaiDtON8Nz29aX7+OPUOGUcKFmYPuXVSIxke6IyYTM1ZPuYxvSVNmMz56KoeD JYUHDzeivYRlemgv3tgztCC/xqVtbuagGBwMoOvc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, co+ed9902f2e44184d9@bugs.sh, Xiang Mei , Helge Deller Subject: [PATCH 6.12 0636/1536] fbdev: udlfb: dont rebuild the mode list while the framebuffer is in use Date: Sat, 7 Nov 2026 08:44:12 -0500 Message-ID: <20261107135015.398052133@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261107134957.653319350@linuxfoundation.org> References: <20261107134957.653319350@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xiang Mei commit ac9cfa552102b8e80e88c2872e80dc9cb5f07dda upstream. dlfb_setup_modes() frees info->modelist with fb_destroy_modelist() and rebuilds it, but fbcon holds raw pointers into that list in fb_display[i].mode and nothing un-publishes them the way do_unregister_framebuffer() and store_modes() do with fbcon_delete_modelist(). The function does refuse to install a new mode while the framebuffer has users (dlfb->fb_count != 0), but only after the list is already destroyed. Reached from the 0666 "edid" sysfs attribute, an unprivileged write to /sys/class/graphics/fb0/edid therefore fails with -EINVAL and still leaves every fb_display[i].mode dangling; the next console switch reads the freed fb_videomode in fb_videomode_to_var(). Test fb_count before touching the list. fbcon takes a reference through fbcon_open(), so that condition covers exactly the states in which fb_display[] points into the list, and the errno returned to userspace is unchanged. BUG: KASAN: slab-use-after-free in fb_videomode_to_var (drivers/video/fbdev/core/modedb.c:905) Read of size 4 at addr ffff8880107b449c by task kworker/1:1/47 Workqueue: events console_callback Call Trace: fb_videomode_to_var (drivers/video/fbdev/core/modedb.c:905) display_to_var (drivers/video/fbdev/core/fbcon.c:998) fbcon_switch (drivers/video/fbdev/core/fbcon.c:2182) redraw_screen (drivers/tty/vt/vt.c:994) complete_change_console (drivers/tty/vt/vt_ioctl.c:1141) console_callback (drivers/tty/vt/vt.c:3358) process_one_work (kernel/workqueue.c:3396) worker_thread (kernel/workqueue.c:3479 kernel/workqueue.c:3560) kthread (kernel/kthread.c:436) ret_from_fork (arch/x86/kernel/process.c:158) ret_from_fork_asm (arch/x86/entry/entry_64.S:245) ... The buggy address is located 28 bytes inside of freed 96-byte region [ffff8880107b4480, ffff8880107b44e0) Cc: stable@vger.kernel.org Fixes: 7d9485e2c53c ("Staging: udlfb: Add functions to expose sysfs metrics and controls") Reported-by: co+ed9902f2e44184d9@bugs.sh Closes: https://lore.kernel.org/all/1jSCSNaDKmuUG7h40rTsSl1rMaSwdlJef4rp%40bugs.sh/ Assisted-by: Claude:claude-opus-5 Signed-off-by: Xiang Mei Link: https://lore.kernel.org/all/1jSCSNaDKmuUG7h40rTsSl1rMaSwdlJef4rp%40bugs.sh/ Signed-off-by: Helge Deller Signed-off-by: Greg Kroah-Hartman --- drivers/video/fbdev/udlfb.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/video/fbdev/udlfb.c +++ b/drivers/video/fbdev/udlfb.c @@ -1293,6 +1293,11 @@ static int dlfb_setup_modes(struct dlfb_ goto error; } + if (dlfb->fb_count) { + result = -EINVAL; + goto error; + } + fb_destroy_modelist(&info->modelist); memset(&info->monspecs, 0, sizeof(info->monspecs));