Re: [PATCH] vt: keyboard: serialize KDGETLED with keyboard_tasklet

From: Greg KH

Date: Sun May 10 2026 - 12:23:24 EST


On Sun, May 10, 2026 at 11:13:48AM +0800, Cen Zhang wrote:
> KDGETLED reaches getledstate() and samples ledstate without serializing
> against keyboard_tasklet.
>
> That is problematic because kbd_bh() temporarily stores ~leds into
> ledstate during a VT switch to force LED propagation before committing
> the final value. An unlocked KDGETLED can therefore observe that
> internal sentinel instead of the last committed LED state.

Why is that an issue?

> Other ledstate readers in this file already quiesce keyboard_tasklet
> before sampling the value. Do the same in getledstate() so the ioctl
> only returns a stable snapshot.

stable for "what" exactly? This is a snapshot in time, be it before or
after it changes is not always going to really matter here, as it can
change right after you "enable" the tasklet, right?

thanks,

greg k-h