Date: Tue, 23 Jun 2020 11:50:54 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 247498] vd_kbstate not getting reset after keyboard detach/attach? Message-ID: <bug-247498-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D247498 Bug ID: 247498 Summary: vd_kbstate not getting reset after keyboard detach/attach? Product: Base System Version: 12.1-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: billblake2018@gmail.com I have discovered a condition under which pressing a key results in an inpu= t of the ESC character followed by the key WITHOUT my holding down any ALT key.= =20 (See VT_ALT_TO_ESC_HACK.) This is using the vt driver on 12.1-RELEASE with = no relevant changes to the GENERIC kernel config. The bug is NOT reliably reproducible. I discovered the bug while putting together a script to secure my laptop and power down the screen when I close my laptop's lid. The script (invoked via devd), switches to the X console, uses DPMS to turn off my display, disables the mouse, and detaches the keyboard with "kbdcontrol -A atkbd0". (Why, you ask? Because when using vt, only X can turn off my display, but keyboard locking is worthless when running X. This was the only way I found to save power *and* secure my system when the lid is closed.) When the lid is open= ed, a program is called to switch to an unused virtual console, reattach the keyboard (with the KBADDKB ioctl), and read a password (with console switch= ing disabled). Most of the time, this worked as expected. Every once in awhile, however, = the program would not accept my password. After some debugging, I discovered t= hat the reason was that the kernel was returning my keyboard input with an ESC character before every character I typed. Looking around, I found that the= re is exactly one place where that could be happening, in sys/dev/vt/vt_core.c, line 961, and that it would do this only if ALKED is set in vd->vd_kbstate,= a field that *should* only be set while one of my ALT keys is pressed. I confirmed that this was the likely culprit by pressing my left ALT key while the bug manifested--the kernel immediately stopped adding the ESC character= s. I no longer have the kernel knowledge (or the time) track this bug to its l= air, but it seems fairly obvious that vd_kbstate is not getting properly initial= ized when the keyboard is reattached. This is relatively harmless; that field controls only the one thing, and the problem is remedied by merely hitting = an ALT key. Of greater concern is the possibility that some *other* field is = not getting reinitialized after a keyboard detach/attach sequence, which sugges= ts that a review of the keyboard attach code is in order. --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-247498-227>