From 916c887817174a7f104f990c29d4f2037c8650be Mon Sep 17 00:00:00 2001 From: Yu Shi Date: Fri, 13 Dec 2024 14:42:56 +0000 Subject: [PATCH 1/3] resolve potential attack in linker connection building --- 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..5b4b86ce67f8 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; From fdfb700bb579561f5742a50dd54325902b538c16 Mon Sep 17 00:00:00 2001 From: Yu Shi Date: Fri, 13 Dec 2024 14:48:11 +0000 Subject: [PATCH 2/3] fix condition --- src/network/linkers_socket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/linkers_socket.cpp b/src/network/linkers_socket.cpp index 5b4b86ce67f8..8de48f3d0ae6 100644 --- a/src/network/linkers_socket.cpp +++ b/src/network/linkers_socket.cpp @@ -157,7 +157,7 @@ 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_) { + 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 From 51cea72ef0138d3f8684690a9b288cb172cae27c Mon Sep 17 00:00:00 2001 From: Yu Shi Date: Fri, 13 Dec 2024 14:49:01 +0000 Subject: [PATCH 3/3] fix error message --- src/network/linkers_socket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/linkers_socket.cpp b/src/network/linkers_socket.cpp index 8de48f3d0ae6..91d618bf1a2d 100644 --- a/src/network/linkers_socket.cpp +++ b/src/network/linkers_socket.cpp @@ -158,7 +158,7 @@ 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_); + 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);