From 61517f8280844c406ab37638eaae2435bb41d350 Mon Sep 17 00:00:00 2001 From: firest Date: Fri, 18 Nov 2022 14:23:49 +0800 Subject: [PATCH 1/2] chore: make remsh node name away from the atom table overflow --- bin/emqx | 2 +- bin/nodetool | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/emqx b/bin/emqx index cdbb7c9de..04e6b201a 100755 --- a/bin/emqx +++ b/bin/emqx @@ -319,7 +319,7 @@ relx_rem_sh() { # Generate a random id relx_gen_id() { - od -t x -N 4 /dev/urandom | head -n1 | awk '{print $2}' + od -t u -N 4 /dev/urandom | head -n1 | awk '{print $2 % 1000}' } # Control a node diff --git a/bin/nodetool b/bin/nodetool index c3bfe5b3c..234dabb97 100755 --- a/bin/nodetool +++ b/bin/nodetool @@ -202,7 +202,12 @@ nodename(Name) -> this_node_name(Name) -> [Node, Host] = re:split(Name, "@", [{return, list}, unicode]), - list_to_atom(lists:concat(["remsh_maint_", Node, os:getpid(), "@", Host])). + list_to_atom(lists:concat(["remsh_maint_", Node, node_name_suffix_id(), "@", Host])). + +%% use the reversed value that from pid mod 1000 as the node name suffix +node_name_suffix_id() -> + Pid = os:getpid(), + string:slice(string:reverse(Pid), 0, 3). %% For windows??? create_mnesia_dir(DataDir, NodeName) -> From 2cdc953435fba8f3f72a82e23b788232925a9b28 Mon Sep 17 00:00:00 2001 From: firest Date: Fri, 18 Nov 2022 14:29:29 +0800 Subject: [PATCH 2/2] chore: update changes --- changes/v4.3.23-en.md | 2 ++ changes/v4.3.23-zh.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/changes/v4.3.23-en.md b/changes/v4.3.23-en.md index fbc662fc2..c3d6216ed 100644 --- a/changes/v4.3.23-en.md +++ b/changes/v4.3.23-en.md @@ -6,6 +6,8 @@ - Print a warning message when boot with the default (insecure) Erlang cookie [#9340](https://github.com/emqx/emqx/pull/9340). +- Improve node name generation rules to avoid potential atom table overflow risk [#9391](https://github.com/emqx/emqx/pull/9391). + ## Bug fixes - Fix a bug where the JWT ACL would not short-circuit with a deny response when the token is expired [#9338](https://github.com/emqx/emqx/pull/9338). diff --git a/changes/v4.3.23-zh.md b/changes/v4.3.23-zh.md index 14f9c33e1..4f486f186 100644 --- a/changes/v4.3.23-zh.md +++ b/changes/v4.3.23-zh.md @@ -6,6 +6,8 @@ - 使用默认的(不安全的) Erlang cookie 进行启动时,将会打印一条警告信息 [#9340](https://github.com/emqx/emqx/pull/9340)。 +- 改进了节点名称生成规则,以避免潜在的原子表溢出风险 [#9391](https://github.com/emqx/emqx/pull/9391)。 + ## 修复 - 修复 JWT ACL 在令牌超期后授权检查不生效的问题 [#9338](https://github.com/emqx/emqx/pull/9338)。