Bug 62821

Summary: Console allows login prompt to be backspaced after delete key
Product: Drivers Reporter: Phillip Susi (phill)
Component: Console/FramebuffersAssignee: James Simmons (jsimmons)
Status: CLOSED INVALID    
Severity: low CC: alan
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.8.11 Subsystem:
Regression: No Bisected commit-id:

Description Phillip Susi 2013-10-11 01:35:16 UTC
While at a login prompt on a VT, pressing the delete key followed by up to 3 backspace keys will delete up to 3 characters of the login prompt.  This can be repeated to delete the whole line.  This appears to be a bug in the console driver, since sending a SIGSTOP to getty does not make it go away, and it does not happen with a getty run on a pty from a gnome-terminal.

Original report: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1068578
Comment 1 Alan 2013-11-13 13:38:29 UTC
As far as I can see this is entirely userspace. File an ubuntu buggy against whatever getty is being used.
Comment 2 Phillip Susi 2013-11-13 14:24:54 UTC
Please bother reading before closing bugs; I clearly explained that getty is ruled out.
Comment 3 Alan 2013-11-13 17:57:39 UTC
Please bother learning how the tty layer works.
Comment 4 Phillip Susi 2013-11-13 18:24:27 UTC
A snarky comment does not explain where the problem is nor why it shouldn't be fixed.  I believe I do know how the tty layer works, which should be evident in my analysis of the problem.

If you are going to mark a bug as wont fix, then you need to explain why the fix would be undesirable.
Comment 5 Alan 2013-11-13 18:42:13 UTC
The tty layer implements posix tty semantics and an emulated vt console. The behaviour you see is what I would expect for the terminal settings in use by the standard getty process on a console and identical to a real vt terminal which is the benchmark.

The "del" button on a keyboard is by default mapped to ^[[3

Now does it make sense ?
Comment 6 Phillip Susi 2013-11-13 19:49:09 UTC
Yes, that is the problem: the del key counts as 4 bytes, so 4 gets added to the count of characters on the line, and so you can backspace those 4 characters.  This is what happens with echoctl on.  With it off, those characters are not echoed, and so should not allow 4 backspaces.  It appears that what is going on is that the 4 characters are added, then the check for -ecoctl is made, and only one of them is subtracted back out, leaving you able to backspace 3 extra characters that you are not supposed to be able to backspace ( because they were never echoed ).

Under a pty in an ssh session with -echoctl, it correctly does not allow you to backspace extra unechoed characters.  The console tty driver should behave the same way, and it is fairly obvious that it tries to, but didn't get it right.
Comment 7 Alan 2013-11-13 22:46:15 UTC
The characters *are* echoed. They don't produce output movements but the tty layer does not know that
Comment 8 Phillip Susi 2013-11-14 16:28:52 UTC
If that were true, then you would be able to backspace all 4 characters, not just 3, and pseudo terminals would behave the same way.
Comment 9 Alan 2013-11-14 20:25:47 UTC
All 4 characters ???? there are 3. The pty case is different because the key codes are not the same.

Please learn about the tty layer or let someone in Ubuntu who understands tty coding help you. In particular ask them to explain the userspace C library "readline" if you want your getty to be "smart".