mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-14 01:30:54 +00:00
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.
This commit is contained in:
parent
9578524091
commit
51f291c795
@ -12000,7 +12000,7 @@ static int hlua_filter_callback(struct stream *s, struct filter *filter, const c
|
||||
goto end;
|
||||
|
||||
if (!HLUA_IS_RUNNING(flt_hlua)) {
|
||||
int extra_idx = lua_gettop(flt_hlua->T);
|
||||
int extra_idx;
|
||||
|
||||
/* The following Lua calls can fail. */
|
||||
if (!SET_SAFE_LJMP(flt_hlua)) {
|
||||
@ -12014,6 +12014,8 @@ static int hlua_filter_callback(struct stream *s, struct filter *filter, const c
|
||||
goto end;
|
||||
}
|
||||
|
||||
extra_idx = lua_gettop(flt_hlua->T);
|
||||
|
||||
/* Check stack size. */
|
||||
if (!lua_checkstack(flt_hlua->T, 3)) {
|
||||
SEND_ERR(s->be, "Lua filter '%s': full stack.\n", conf->reg->name);
|
||||
|
Loading…
Reference in New Issue
Block a user