From b33a12ea3883f306388e69f12ceb421b1ee7ec29 Mon Sep 17 00:00:00 2001 From: shiyu1994 Date: Sat, 14 Dec 2024 12:12:17 +0800 Subject: [PATCH] [fix] resolve potential attack in linker connection building (#6752) --- src/network/linkers_socket.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/network/linkers_socket.cpp b/src/network/linkers_socket.cpp index 69e92a81b8eb..91d618bf1a2d 100644 --- a/src/network/linkers_socket.cpp +++ b/src/network/linkers_socket.cpp @@ -157,6 +157,9 @@ void Linkers::ListenThread(int incoming_cnt) { } int* ptr_in_rank = reinterpret_cast(buffer); int in_rank = *ptr_in_rank; + if (in_rank < 0 || in_rank >= num_machines_) { + Log::Fatal("Invalid rank %d found during initialization of linkers. The world size is %d.", in_rank, num_machines_); + } // add new socket SetLinker(in_rank, handler); ++connected_cnt;