summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2021-06-21 15:49:34 +0200
committerAndreas Kling <kling@serenityos.org>2021-06-21 16:57:07 +0200
commitae6367999f9b9b78994d92b523e9b964e28b17f2 (patch)
treeb9cec59146d27e3a92220fb3580c49ea8814e438
parent08e2dc22be85aa55ae5380d50ccda826eed96e30 (diff)
downloadserenity-ae6367999f9b9b78994d92b523e9b964e28b17f2.zip
Kernel: Fix assertion failure on large TTY writes
The `File::can_write` mechanism lets us check that writes won't block, meaning some bytes can be immediately written to the underlying device. This means calling `File::write` in a situation where no data could be written is a logic error, which we `VERIFY()` in `Process::do_write()`. TTY, in particular, processes the write in 256-byte buffered chunks. Previously, we would assert that none of these sub-writes returned zero. This was a logic error, as this rejected some successful writes. For example, if there was exactly enough free space in `SlavePty`'s internal buffer for the previous sub-write to complete fully. This made it impossible to perform writes larger than `SlavePty`'s internal buffer. Note that it's not an issue if `on_tty_write` returns zero, as partial writes are handled correctly by the `buffer.read_buffered` helper. We won't spin in a loop trying to write to a full buffer. Fixes #8090
-rw-r--r--Kernel/TTY/TTY.cpp1
1 files changed, 0 insertions, 1 deletions
diff --git a/Kernel/TTY/TTY.cpp b/Kernel/TTY/TTY.cpp
index a17a59fab4..407bc2413d 100644
--- a/Kernel/TTY/TTY.cpp
+++ b/Kernel/TTY/TTY.cpp
@@ -97,7 +97,6 @@ KResultOr<size_t> TTY::write(FileDescription&, u64, const UserOrKernelBuffer& bu
});
}
auto bytes_written_or_error = on_tty_write(UserOrKernelBuffer::for_kernel_buffer(modified_data), modified_data_size);
- VERIFY(bytes_written_or_error.is_error() || bytes_written_or_error.value() != 0);
if (bytes_written_or_error.is_error() || !(m_termios.c_oflag & OPOST) || !(m_termios.c_oflag & ONLCR))
return bytes_written_or_error;
auto bytes_written = bytes_written_or_error.value();