]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: hlua: enforce proper running context for register_x functions
authorAurelien DARRAGON <adarragon@haproxy.com>
Fri, 24 Feb 2023 08:43:54 +0000 (09:43 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 5 Apr 2023 06:58:16 +0000 (08:58 +0200)
commit87f52974ba9ae91479fb4ea01dee52ebc6536d1b
tree2226bdb846fadce5259d7e8505a9f5f4395454b4
parent795441073cc115838bef0817059b7c4e0878a3bf
BUG/MINOR: hlua: enforce proper running context for register_x functions

register_{init, converters, fetches, action, service, cli, filter} are
meant to run exclusively from body context according to the
documentation (unlike register_task which is designed to work from both
init and runtime contexts)

A quick code inspection confirms that only register_task implements
the required precautions to make it safe out of init context.

Trying to use those register_* functions from a runtime lua task will
lead to a program crash since they all assume that they are running from
the main lua context and with no concurrent runs:

    core.register_task(function()
      core.register_init(function()
      end)
    end)

When loaded from the config, the above example would segfault.

To prevent this undefined behavior, we now report an explicit error if
the user tries to use such functions outside of init/body context.

This should be backported in every stable versions.
[prior to 2.5 lua filter API did not exist, the hlua_register_filter()
part should be skipped]
src/hlua.c