Merge pull request #10078 from qzhuyan/fix/william/inval-listener-options-segfault

fix: inval listener option cause segfault
This commit is contained in:
William Yang 2023-03-07 09:26:27 +01:00 committed by GitHub
commit 422f8e3be3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 11 deletions

View File

@ -24,7 +24,7 @@ IsQuicSupp = fun() ->
end, end,
Bcrypt = {bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {tag, "0.6.0"}}}, Bcrypt = {bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {tag, "0.6.0"}}},
Quicer = {quicer, {git, "https://github.com/emqx/quic.git", {tag, "0.0.111"}}}. Quicer = {quicer, {git, "https://github.com/emqx/quic.git", {tag, "0.0.113"}}}.
Dialyzer = fun(Config) -> Dialyzer = fun(Config) ->
{dialyzer, OldDialyzerConfig} = lists:keyfind(dialyzer, 1, Config), {dialyzer, OldDialyzerConfig} = lists:keyfind(dialyzer, 1, Config),

View File

@ -537,10 +537,12 @@ ensure_quic_listener(Name, UdpPort, ExtraSettings) ->
mountpoint => <<>>, mountpoint => <<>>,
zone => default zone => default
}, },
emqx_config:put([listeners, quic, Name], maps:merge(Conf, ExtraSettings)), Conf2 = maps:merge(Conf, ExtraSettings),
case emqx_listeners:start_listener(quic, Name, Conf) of emqx_config:put([listeners, quic, Name], Conf2),
case emqx_listeners:start_listener(emqx_listeners:listener_id(quic, Name)) of
ok -> ok; ok -> ok;
{error, {already_started, _Pid}} -> ok {error, {already_started, _Pid}} -> ok;
Other -> throw(Other)
end. end.
%% %%

View File

@ -33,7 +33,8 @@ all() ->
{group, mstream}, {group, mstream},
{group, shutdown}, {group, shutdown},
{group, misc}, {group, misc},
t_listener_with_lowlevel_settings t_listener_with_lowlevel_settings,
t_listener_inval_settings
]. ].
groups() -> groups() ->
@ -1885,8 +1886,17 @@ t_multi_streams_sub_0_rtt_stream_data_cont(Config) ->
ok = emqtt:disconnect(C), ok = emqtt:disconnect(C),
ok = emqtt:disconnect(C0). ok = emqtt:disconnect(C0).
t_listener_inval_settings(_Config) ->
LPort = select_port(),
%% too small
LowLevelTunings = #{stream_recv_buffer_default => 1024},
?assertThrow(
{error, {failed_to_start, _}},
emqx_common_test_helpers:ensure_quic_listener(?FUNCTION_NAME, LPort, LowLevelTunings)
).
t_listener_with_lowlevel_settings(_Config) -> t_listener_with_lowlevel_settings(_Config) ->
LPort = 24567, LPort = select_port(),
LowLevelTunings = #{ LowLevelTunings = #{
max_bytes_per_key => 274877906, max_bytes_per_key => 274877906,
%% In conf schema we use handshake_idle_timeout %% In conf schema we use handshake_idle_timeout
@ -1897,7 +1907,7 @@ t_listener_with_lowlevel_settings(_Config) ->
%% tls_client_max_send_buffer, %% tls_client_max_send_buffer,
tls_server_max_send_buffer => 10240, tls_server_max_send_buffer => 10240,
stream_recv_window_default => 1024, stream_recv_window_default => 1024,
stream_recv_buffer_default => 1024, stream_recv_buffer_default => 10240,
conn_flow_control_window => 1024, conn_flow_control_window => 1024,
max_stateless_operations => 16, max_stateless_operations => 16,
initial_window_packets => 1300, initial_window_packets => 1300,
@ -1936,8 +1946,7 @@ t_listener_with_lowlevel_settings(_Config) ->
{ok, _, [_SubQos]} = emqtt:subscribe_via(C, {new_data_stream, []}, #{}, [ {ok, _, [_SubQos]} = emqtt:subscribe_via(C, {new_data_stream, []}, #{}, [
{<<"test/1/3">>, [{qos, 2}]} {<<"test/1/3">>, [{qos, 2}]}
]), ]),
ok = emqtt:disconnect(C), ok = emqtt:disconnect(C).
emqx_listeners:stop_listener(emqx_listeners:listener_id(quic, ?FUNCTION_NAME)).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Helper functions %% Helper functions

View File

@ -0,0 +1,2 @@
Fix an issue that invalid QUIC listener setting could casue segfault.

View File

@ -0,0 +1,2 @@
修复了无效的 QUIC 监听器设置可能导致 segfault 的问题。

View File

@ -648,7 +648,7 @@ defmodule EMQXUmbrella.MixProject do
defp quicer_dep() do defp quicer_dep() do
if enable_quicer?(), if enable_quicer?(),
# in conflict with emqx and emqtt # in conflict with emqx and emqtt
do: [{:quicer, github: "emqx/quic", tag: "0.0.111", override: true}], do: [{:quicer, github: "emqx/quic", tag: "0.0.113", override: true}],
else: [] else: []
end end

View File

@ -39,7 +39,7 @@ bcrypt() ->
{bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {tag, "0.6.0"}}}. {bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {tag, "0.6.0"}}}.
quicer() -> quicer() ->
{quicer, {git, "https://github.com/emqx/quic.git", {tag, "0.0.111"}}}. {quicer, {git, "https://github.com/emqx/quic.git", {tag, "0.0.113"}}}.
jq() -> jq() ->
{jq, {git, "https://github.com/emqx/jq", {tag, "v0.3.9"}}}. {jq, {git, "https://github.com/emqx/jq", {tag, "v0.3.9"}}}.