]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: shctx: Use the next block when data exactly filled a block
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 3 Feb 2026 06:46:22 +0000 (07:46 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 18 Feb 2026 08:44:15 +0000 (09:44 +0100)
commit9e17087aebe0130fc34aaab4e1981e60707e4a82
tree53b882fceae95dbf3cdfcc61f2a4ca8b06685bbe
parentb248b1c02175f190a03c1ff9258be03514320a8c
BUG/MEDIUM: shctx: Use the next block when data exactly filled a block

When the hot list was removed in 3.0, a regression was introduced.
Theorically, it is possible to override data in a block when new data are
appended. It happens when data are copied. If the data size is a multiple of
the block size, all data are copied and the last used block is full. But
instead of saving a reference on the next block as the restart point for the
next copies, we keep a reference on the last full one. On the next read, we
reuse this block and old data are crushed. To hit the bug, no new blocks
should be reserved between the two data copy attempts.

Concretely, for now, it seems not possible to hit the bug. But with a block
size set to 1024, if more than 1024 bytes are reseved, with a first copy of
1024 bytes and a second one with remaining data, data in the first block
will be crushed.

So to fix the bug, the reference of the last block used to write data (which
is in fact the next one to use to perform the next copy) is only updated
when a block is full. In that case the next block is used.

This patch should be backported as far as 3.0 after a period of observation.
src/shctx.c