]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
fbdev: serialize mode sysfs access with lock_fb_info()
authorMelbin K Mathew <mlbnkm1@gmail.com>
Wed, 1 Jul 2026 23:42:48 +0000 (01:42 +0200)
committerHelge Deller <deller@gmx.de>
Sat, 8 Aug 2026 06:08:58 +0000 (08:08 +0200)
commit061db6b7a910b8378f3b2df64f8c0a3ddc6e85f2
tree769b4d9b2c4f9f0d94c3caeb1fb67b008538f29a
parent95e647d2a5304a8fd11f1ba3c8502de700650131
fbdev: serialize mode sysfs access with lock_fb_info()

show_mode(), show_modes(), and store_mode() access fb_info->modelist
and fb_info->mode without holding lock_fb_info(). store_modes() takes
lock_fb_info() while replacing the modelist and freeing the old one.

A concurrent reader or writer can load a pointer to an old modelist
entry before store_modes() frees it, then dereference freed memory or
store a stale freed pointer in fb_info->mode.

Take lock_fb_info() in show_mode(), show_modes(), and store_mode() to
serialize with store_modes(). In show_mode(), copy the mode to the
stack and format after dropping the lock. In store_mode(), split
activate() into a _locked variant to avoid double-locking, and hold
the locks for the modelist walk, mode conversion, activation, and
fb_info->mode assignment together.

Cc: stable@vger.kernel.org # v7.1+
Signed-off-by: Melbin K Mathew <mlbnkm1@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
drivers/video/fbdev/core/fbsysfs.c