BUG/MINOR: hlua: improper lock usage in hlua_filter_callback()
authorAurelien DARRAGON <adarragon@haproxy.com>
Mon, 4 Mar 2024 10:06:24 +0000 (11:06 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Mon, 4 Mar 2024 15:47:17 +0000 (16:47 +0100)
commit51f291c795570d7da9cc230616a41d55eca93f1a
tree7d43ebb740bb6ce57185b033d96a6e2feb72c628
parent957852409177efb36171f718ffef2be0fd919588
BUG/MINOR: hlua: improper lock usage in hlua_filter_callback()

In hlua_filter_callback(), some lua stack work is performed under
SET_SAFE_LJMP() guard which also takes care of locking the hlua context
when needed. However, a lua_gettop() call is performed out of the guard,
thus it is unsafe in multithreading context if the script is loaded using
'lua-load' because in this case the main lua stack is shared between
threads and each access to a lua stack must be performed under the lock,
thus we move lua_gettop() call under the lock.

It should be backported up to 2.6.
src/hlua.c