diff options
author | John Keeping | 2018-06-20 07:29:14 +0200 |
---|---|---|
committer | Jason A. Donenfeld | 2018-06-27 18:13:03 +0200 |
commit | b31e99887b17f513289fb11227b2484504e85b6c (patch) | |
tree | fd4b868e415db4de0577495eabf48e6bf814d408 /configfile.h | |
parent | git: update to v2.18.0 (diff) | |
download | cgit-b31e99887b17f513289fb11227b2484504e85b6c.tar.gz cgit-b31e99887b17f513289fb11227b2484504e85b6c.zip |
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 'configfile.h')
0 files changed, 0 insertions, 0 deletions