[Bug 273566] stray characters contaminate serial console

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 04 Sep 2023 18:00:37 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=273566

            Bug ID: 273566
           Summary: stray characters contaminate serial console
           Product: Base System
           Version: CURRENT
          Hardware: arm
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: arm
          Assignee: freebsd-arm@FreeBSD.org
          Reporter: fbsd@www.zefox.net

From time to time serial console connections on raspberry Pi (2, 3 and 4)
systems allow stray characters to enter serial console commands. Since the
console is often used by root, this seems potentially insecure. 

The setup consists of a pair of Pi's. One holds a usb-serial adapter,
with the serial end connected to a second Pi's console uart. Connection 
is established by ssh into the first Pi, starting tip or cu, and then
logging into the second Pi into the usual way. Often, login is to root.

Often, the ssh connection to the first Pi drops spontaneously. It can be
re-established by repeating the connection procedure, if the original
shell running on the second Pi's serial console is still running the old
session remains up and prior commands can be run from history.

When that is done, sometimes the apparent "last words" to the second Pi
appear to be things that were never intentionally entered before the 
disconnect. Here's one example, in this case the terminal session is
running on a Pi4 running RasPiOS, the ssh connection is to a Pi2 running
FreeBSD 14.0-ALPHA4 armv7 1400097 (GENERIC) #1, the Pi running the serial
console is running 15-current:client_loop: send disconnect: Broken pipe
bob@raspberrypi:~ $ ssh 192.168.1.13
Password for bob@generic:
Last login: Mon Sep  4 08:14:21 2023 from 192.168.1.10
FreeBSD 14.0-ALPHA4 armv7 1400097 (GENERIC) #1 stable/14-n265029-d6fec2dacf80:
Mon Sep  4 02:12:35 PDT 2023

Welcome to FreeBSD!

Release Notes, Errata: https://www.FreeBSD.org/releases/
Security Advisories:   https://www.FreeBSD.org/security/
FreeBSD Handbook:      https://www.FreeBSD.org/handbook/
FreeBSD FAQ:           https://www.FreeBSD.org/faq/
Questions List:        https://www.FreeBSD.org/lists/questions/
FreeBSD Forums:        https://forums.FreeBSD.org/

Documents installed with the system are in the /usr/local/share/doc/freebsd/
directory, or can be installed later with:  pkg install en-freebsd-doc
For other languages, replace "en" with a language code like de or fr.

Show the version of FreeBSD installed:  freebsd-version ; uname -a
Please include that output and any error messages when posting questions.
Introduction to manual pages:  man man
FreeBSD directory layout:      man hier

To change this login announcement, see motd(5).
To see the last 10 lines of a long file, use "tail filename". To see the
first 10 lines, use "head filename". To see new lines as they're appended
to a file, use "tail -f filename".
                -- Dru <genesis@istar.ca>
bob@generic:~ % su
Password:
# tip ucom
Stale lock on cuaU0 PID=1181... overriding.
connected
Y\HHMHLN\247\261́\315m\335u違\311\351͡}}¥ѥѥ½
YHHMHLN��́�m�u違��͡}}�ѥѥ�: Command not found.
bob@pelorus:/usr/src % ½¹¹ѥ½¹±½͕åɕµ½ѕ¡½ÍÑ5)5)5)ÿ
Too many )'s.
bob@pelorus:/usr/src

If one types up-arrow to recall history, the first few old "commands"
are rubbish, though they are not un-displayable as would be expected
from line noise (the copy-paste from FreeBSD to RasPiOS is misleading).

In this example an FTDI-232 was in use, but PL2303 has behaved similarly.

The origin of the disconnect is unclear. I think it's a problem with
ssh between the RasPiOS terminal and the Pi holding the USB-serial 
adapter, but don't know how to tell for sure. It seems to be load-related,
with a busy FreeBSD Pi more inclined to drop connections even if the
connection itself is entirely idle. 

FWIW, stable/12 does not display this behavior, with ssh-usb-serial-console
connections staying up for days or weeks.

-- 
You are receiving this mail because:
You are the assignee for the bug.