about summary refs log tree commit diff
path: root/cgit.png
diff options
context:
space:
mode:
authorJohn Keeping <john@keeping.me.uk>2018-06-20 07:29:14 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-06-27 18:13:03 +0200
commitb31e99887b17f513289fb11227b2484504e85b6c (patch)
treefd4b868e415db4de0577495eabf48e6bf814d408 /cgit.png
parentgit: update to v2.18.0 (diff)
downloadcgit-pink-b31e99887b17f513289fb11227b2484504e85b6c.tar.gz
cgit-pink-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 '')
0 files changed, 0 insertions, 0 deletions
fecd58a6f9f902ad8bf99&follow=1'>Don't render every PM as a pingJune McEnroe 2018-09-11Add urlOpenMatchJune McEnroe 2018-09-10Depend on man.sh for chroot.tar targetJune McEnroe 2018-09-10Set LESSSECURE=1 in man.shJune McEnroe 2018-09-10Add /man commandJune McEnroe 2018-09-10Install man page in chrootJune McEnroe 2018-09-10Install man pageJune McEnroe 2018-09-10Split keys into subsections and document colorsJune McEnroe 2018-09-10Add "blank" lines to chatte.1June McEnroe 2018-09-10Document key bindings in chatte.1June McEnroe 2018-09-08Document slash commands in chatte.1June McEnroe