Bug 194905

Summary: [util-linux] agetty reorders characters in login prompt
Product: Tools Reporter: Michael Tretter (m.tretter)
Component: OtherAssignee: Tools.Other (tools_other)
Status: RESOLVED MOVED    
Severity: normal CC: m.tretter
Priority: P1    
Hardware: ARM   
OS: Linux   
Kernel Version: 4.11-rc2, 4.4.52 Subsystem:
Regression: No Bisected commit-id:

Description Michael Tretter 2017-03-17 11:21:41 UTC
agetty sometimes changes the order of the characters of the username in the login prompt. For example, if I enter 'root' as username, the echo reads 'orot' and the login fails, because the user does not exist.

A little bit background on the issue: I am running automated tests on an embedded device with an i.MX6 processor which connects to the board via serial console with 115200 baud. The test waits for the login prompt and then sends the username via the serial console. In about 20 % of the test runs the echoed username slightly differs from the sent username and the test fails.

I can also reproduce the issue when connecting to the serial console via screen and pasting the username into the prompt. If I enter the username manually or connect strace to agetty, the username is always correct. I reproduced the problem on multiple different device (although all with the same SoC).

I tested it with util-linux 2.29 with Linux 4.11-rc2 and 4.4.52.

I was able to trace the issue to the wait_for_term_input() function.
This function reads the first (few) bytes from the input queue and
after reading reinserts the bytes with the TIOCSTI ioctl back into the
queue. If new bytes are inserted into the input queue before the
TIOCSTI happens, the input queue will contain the bytes in the wrong
order and later reads on the input queue will not yield the original
input.
Comment 1 Michael Tretter 2017-03-17 13:18:43 UTC
Moved to the util-linux mailing list: http://vger.kernel.org/vger-lists.html#util-linux