]> sourceware.org Git - newlib-cygwin.git/commit
Cygwin: console: Fix a race issue between close() and open().
authorTakashi Yano <takashi.yano@nifty.ne.jp>
Mon, 4 Mar 2024 02:32:34 +0000 (11:32 +0900)
committerTakashi Yano <takashi.yano@nifty.ne.jp>
Mon, 4 Mar 2024 02:58:09 +0000 (11:58 +0900)
commitb160b690b6ace93ee4225f14a9287549e37f4a71
tree48624d86e60f21a54b4f7e7aa680d75523362804
parentabb532a87ff6ed37f6ee2c8a58c65178a15aa345
Cygwin: console: Fix a race issue between close() and open().

The open() call for console sometimes fails if the console owner
process is closing the console by close() at the same time. This
is due to mismatch state of con.owner variable and attaching state
to the console. With this patch, checking con.owner and attaching
to con.owner sequence in open(), and resetting con.owner and freeing
console sequence in close() are guarded by output_mutex to avoid
such a race issue.
Addresses: https://cygwin.com/pipermail/cygwin/2024-March/255575.html

Fixes: 3721a756b0d8 ("Cygwin: console: Make the console accessible from other terminals.")
Reported-by: Kate Deplaix <kit-ty-kate@outlook.com>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
winsup/cygwin/fhandler/console.cc
winsup/cygwin/release/3.5.2
This page took 0.029417 seconds and 5 git commands to generate.