epmd: a client that closes early crashes the server on the PORT_PLEASE2 and NAMES responses

オープン 初心者向け
#2,476 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
erlang
領域
backend

調査の方向性

libs/avm_network/src/epmd.erlを読み、?PORT_PLEASE2_REQと?NAMES_REQに対するprocess_req/3の分岐に注目し、#2345で変更されたALIVE2分岐と送信処理を比較してください。送信失敗がどのように処理されるか、またサーバーが登録済みノードを保持することを確認してください。どちらの応答も送信に失敗してもepmd gen_serverがクラッシュしなければ完了です。

索引モデルが issue の本文から書いたものです。

説明

Affected: release-0.7 at ca1583068, libs/avm_network/src/epmd.erl,
process_req/3 for ?PORT_PLEASE2_REQ and ?NAMES_REQ.
#2345 fixes the same problem for the ALIVE2 response only.

What happens

The responses are sent with ok = socket:send(Socket, ...).

When the client has already closed the connection, socket:send/2 does not
return ok (on release-0.7 it returns {ok, Data} for a closed connection,
with #2345 it returns {error, closed} or {error, epipe}). The badmatch
crashes the epmd gen_server, and every registered node is forgotten.

How to reproduce

Start the epmd, then from any client:

{ok, S} = socket:open(inet, stream, tcp),
ok = socket:setopt(S, {socket, linger}, #{onoff => true, linger => 0}),
ok = socket:connect(S, #{family => inet, addr => loopback, port => 4369}),
ok = socket:send(S, <<2:16, 122, "x">>),   % PORT_PLEASE2_REQ for node "x"
ok = socket:close(S).                       % reset, no reply is read

The server's reply fails and the epmd process crashes. The race is easiest to
hit with a slow server, for example under valgrind.

Suggested fix

Handle {error, _} like the ALIVE2 branch does after #2345: close the socket
and keep the state.

主要言語
Erlang
スター
2.3k
フォーク
171
平均マージ
4日 11時間
マージ済み PR(30日)
20

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

atomvm/AtomVM のほかの issue

atomvm/AtomVM の issue をすべて見る

似ている issue

Backend & API Design の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。