diff options
author | John Keeping <john@keeping.me.uk> | 2018-06-20 07:29:14 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-06-27 18:13:03 +0200 |
commit | b31e99887b17f513289fb11227b2484504e85b6c (patch) | |
tree | fd4b868e415db4de0577495eabf48e6bf814d408 /Makefile | |
parent | 255b78ff5291cef79978b025c9872f801de89e23 (diff) |
cache: close race window when unlocking slots
We use POSIX advisory record locks to control access to cache slots, but
these have an unhelpful behaviour in that they are released when any
file descriptor referencing the file is closed by this process.
Mostly this is okay, since we know we won't be opening the lock file
anywhere else, but there is one place that it does matter: when we
restore stdout we dup2() over a file descriptor referring to the file,
thus closing that descriptor.
Since we restore stdout before unlocking the slot, this creates a window
during which the slot content can be overwritten. The fix is reasonably
straightforward: simply restore stdout after unlocking the slot, but the
diff is a bit bigger because this requires us to move the temporary
stdout FD into struct cache_slot.
Signed-off-by: John Keeping <john@keeping.me.uk>
Reviewed-by: Christian Hesse <mail@eworm.de>
Diffstat (limited to 'Makefile')
0 files changed, 0 insertions, 0 deletions