diff options
author | Takashi Yano <takashi.yano@nifty.ne.jp> | 2023-08-04 11:45:34 +0300 |
---|---|---|
committer | Takashi Yano <takashi.yano@nifty.ne.jp> | 2023-08-04 11:49:29 +0300 |
commit | 3b4f6217c371cf70d5ec5137436cfa5892bb45e8 (patch) | |
tree | 5b02f7f74808559ef59e53b6d29a719302290244 /newlib/libc/include/sys/cdefs.h | |
parent | ab78bd2d228027d0ac5a84bfc409444d3ce18948 (diff) |
Cygwin: pty: Fix thread safety of readahead buffer handling in pty master.
Previously, though readahead buffer handling in pty master was not
fully thread-safe, accept_input() was called from peek_pipe() thread
in select.cc. This caused the problem reported in:
https://cygwin.com/pipermail/cygwin/2023-July/253984.html
The mechanism of the problem is:
1) accept_input() which is called from peek_pipe() thread calls
eat_readahead(-1) before reading readahead buffer. This allows
writing to the readahead buffer from another (main) thread.
2) The main thread calls fhandler_pty_master::write() just after
eat_readahead(-1) was called and before reading the readahead
buffer by accept_input() called from peek_pipe() thread. This
overwrites the readahead buffer.
3) The read result from readahead buffer which was overwritten is
sent to the slave.
This patch makes readahead buffer handling fully thread-safe using
input_mutex to resolve this issue.
Fixes: 7b03b0d8cee0 ("select.cc (peek_pipe): Call flush_to_slave whenever we're checking for a pty master.")
Reported-by: Thomas Wolff <towo@towo.net>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Diffstat (limited to 'newlib/libc/include/sys/cdefs.h')
0 files changed, 0 insertions, 0 deletions