]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: buffers/threads: always clear a buffer's head before releasing it
authorWilly Tarreau <w@1wt.eu>
Thu, 8 Aug 2019 05:53:20 +0000 (07:53 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 8 Aug 2019 06:07:45 +0000 (08:07 +0200)
commit3b091f80aa66d538ea65a1fd7e60acfb37c5421a
tree6edee242d3e6518147c14e11de575f7bc365b278
parent229e739c21e96dd2020f6351fcc10546a1848b50
BUG/MINOR: buffers/threads: always clear a buffer's head before releasing it

A small race exists in buffers with "show sess all". This one wants to show
some information grabbed from the buffer (especially in HTX mode). But the
thread owning this buffer might just be releasing its area, right after a
free() or munmap() call, resulting in a head that is not seen as empty yet
though the area was released. It may then be dereferenced by "show sess all"
causing a crash. Note that in practice it only happens in debug mode with
UAF enabled, but it's tricky enough to fix it right now.

This should be backported to stable versions which support threads and a
store barrier. It's worth noting that by performing the clearing first,
b_free() and b_drop() now become two exact equivalent.
doc/internals/buffer-api.txt
include/common/buffer.h