Re: WARNING in iov_iter_revert (2)

From: Linus Torvalds
Date: Sun Feb 21 2021 - 12:21:15 EST


On Sat, Feb 20, 2021 at 4:45 PM Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> I don't think the ttyprintk weirdness was intentional. I'd fix that,
> but in the meantime clearly we should make do_tty_write() protect
> against this insanity, and do something like
>
> --- a/drivers/tty/tty_io.c
> +++ b/drivers/tty/tty_io.c
> @@ -961,6 +961,9 @@ static inline ssize_t do_tty_write(
> ret = write(tty, file, tty->write_buf, size);
> if (ret <= 0)
> break;
> + /* ttyprintk historical oddity */
> + if (ret > size)
> + break;

Actually, we need to move the

written += ret;

line up above this thing too, so that we get the expected insane
return value to user space.

Of course, if ttyprintk gets fixed, this is all moot, but I've applied
this patch for now (since I was doing Greg's tty pull).

I've marked it as "fixing" 9bb48c82aced ("tty: implement write_iter")
even if the real cause is much older - the WARNING is new.

Linus

PS. Just lost power again. Oh joy.