]> git.ipfire.org Git - thirdparty/xz.git/commit
liblzma: mt dec: Don't modify thr->in_size in the worker thread
authorLasse Collin <lasse.collin@tukaani.org>
Thu, 3 Apr 2025 11:34:42 +0000 (14:34 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Thu, 3 Apr 2025 12:49:42 +0000 (15:49 +0300)
commit6ff5b8c55960f9ebc917b668bd3567ef217175fa
tree97fdb97a7e21999c32e83d1d6554203b1213955b
parent1b874b4f04909b7bb5259cb612ecef39a434dde8
liblzma: mt dec: Don't modify thr->in_size in the worker thread

Don't set thr->in_size = 0 when returning the thread to the stack of
available threads. Not only is it useless, but the main thread may
read the value in SEQ_BLOCK_THR_RUN. With valid inputs, it made
no difference if the main thread saw the original value or 0. With
invalid inputs (when worker thread stops early), thr->in_size was
no longer modified after the previous commit with the security fix
("Don't free the input buffer too early").

So while the bug appears harmless now, it's important to fix it because
the variable was being modified without proper locking. It's trivial
to fix because there is no need to change the value. Only main thread
needs to set the value in (in SEQ_BLOCK_THR_INIT) when starting a new
Block before the worker thread is activated.

Fixes: 4cce3e27f529 ("liblzma: Add threaded .xz decompressor.")
Reviewed-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Thanks-to: Sam James <sam@gentoo.org>
(cherry picked from commit 8188048854e8d11071b8a50d093c74f4c030acc9)
src/liblzma/common/stream_decoder_mt.c