Re: [PATCH 2/3] serial: Move LF -> CRLF replacement from serial console to kdb

Amal <[email protected]> Wed, 11 Dec 2024 15:40:41 +0000
Newsgroups org.kernel.vger.linux-debuggers,org.kernel.vger.linux-serial
Message-ID <CAOfKSRNGdeFgidKoD9wpvce2HZnOEXyXt5mbeMqmr90RTe9XqA@mail.gmail.com>
On Tue, Dec 10, 2024 at 3:16 PM Daniel Thompson <[email protected]> wrote:
>
> On Tue, Dec 10, 2024 at 05:34:47AM -0800, Amal Raj T wrote:
> > From: Amal Raj T <[email protected]>
> >
> > The current implementation of `poll_put_char` in the serial console driver
> > performs LF -> CRLF replacement, which can corrupt binary data. Since kdb
> > is the only user of `poll_put_char`, this patch moves the LF -> CRLF
> > replacement logic to kdb.
>
> This description only explains why it is safe to change
> uart_poll_put_char() but...
>
>
>
> > Link: https://lore.kernel.org/linux-debuggers/Zy093jVKPs9gSVx2@telecaster/
> >
> > Signed-off-by: Amal Raj T <[email protected]>
> > ---
> >  drivers/tty/serial/serial_core.c | 4 ----
> >  kernel/debug/kdb/kdb_io.c        | 2 ++
> >  2 files changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> > index 74fa02b23772..ed18492b7f8f 100644
> > --- a/drivers/tty/serial/serial_core.c
> > +++ b/drivers/tty/serial/serial_core.c
> > @@ -2142,8 +2142,6 @@ void uart_console_write(struct uart_port *port, const char *s,
> >       unsigned int i;
> >
> >       for (i = 0; i < count; i++, s++) {
> > -             if (*s == '\n')
> > -                     putchar(port, '\r');
> >               putchar(port, *s);
> >       }
> >  }
>
> ... kgdb isn't the only user of uart_console_write() though, right?
Yes, the replacement should be only for uart_poll_put_char, fixed this in v2
>
>
> Daniel.