[ Let's see how long this lasts, but I've got a generator for the
laptop, and hopefully I'll be able to start doing pulls tonight, and
get "real" power tomorrow ]

On Sat, Feb 20, 2021 at 11:30 AM Al Viro <v...@zeniv.linux.org.uk> wrote:
>
> IOW, it's not iov_iter_revert() being weird or do_tty_write() misuing it -
> it's tpk_write() playing silly buggers.

Ok, that's actually not as bad I was was afraid it might be.

> Do we want to preserve that weirdness of /dev/ttyprintk writes?
> That's orthogonal to the iov_iter uses in there.

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;

                /* FIXME! Have Al check this! */
                if (ret != size)

in there. Because right now we clearly do strange and not-so-wonderful
things if the write routine returns a bigger value than it was
passed.. Not limited to that iov_iter_revert() thing, but the whole
loop.

Comments?

              Linus

Reply via email to