From 1c5786e3c581ba560354bc821b3f17e5491f846a Mon Sep 17 00:00:00 2001 From: XMRig Date: Sat, 23 Mar 2024 16:21:54 +0700 Subject: [PATCH 1/5] v6.21.3-dev --- src/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index 4cb5a505..aa877312 100644 --- a/src/version.h +++ b/src/version.h @@ -22,7 +22,7 @@ #define APP_ID "xmrig" #define APP_NAME "XMRig" #define APP_DESC "XMRig miner" -#define APP_VERSION "6.21.2" +#define APP_VERSION "6.21.3-dev" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2024 xmrig.com" @@ -30,7 +30,7 @@ #define APP_VER_MAJOR 6 #define APP_VER_MINOR 21 -#define APP_VER_PATCH 2 +#define APP_VER_PATCH 3 #ifdef _MSC_VER # if (_MSC_VER >= 1930) From 1f7e635b04aef8477379ebd990dcdb862836a5a1 Mon Sep 17 00:00:00 2001 From: XMRig Date: Tue, 26 Mar 2024 21:46:18 +0700 Subject: [PATCH 2/5] Use internal logger for error message. --- src/base/api/Api.cpp | 13 +++++++------ src/base/api/Api.h | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/base/api/Api.cpp b/src/base/api/Api.cpp index e0907a84..77f8e4aa 100644 --- a/src/base/api/Api.cpp +++ b/src/base/api/Api.cpp @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2023 SChernykh - * Copyright (c) 2016-2023 XMRig , + * Copyright (c) 2018-2024 SChernykh + * Copyright (c) 2016-2024 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,6 +25,8 @@ #include "base/crypto/keccak.h" #include "base/io/Env.h" #include "base/io/json/Json.h" +#include "base/io/log/Log.h" +#include "base/io/log/Tags.h" #include "base/kernel/Base.h" #include "base/tools/Chrono.h" #include "base/tools/Cvt.h" @@ -39,7 +41,6 @@ #include -#include namespace xmrig { @@ -81,8 +82,7 @@ static rapidjson::Value getResources(rapidjson::Document &doc) xmrig::Api::Api(Base *base) : m_base(base), - m_timestamp(Chrono::currentMSecsSinceEpoch()), - m_httpd(nullptr) + m_timestamp(Chrono::currentMSecsSinceEpoch()) { base->addListener(this); @@ -118,7 +118,8 @@ void xmrig::Api::start() if (!m_httpd) { m_httpd = new Httpd(m_base); if (!m_httpd->start()) { - std::cerr << "HTTP server failed to start." << std::endl; + LOG_ERR("%s " RED_BOLD("HTTP API server failed to start."), Tags::network()); + delete m_httpd; // Properly handle failure to start m_httpd = nullptr; } diff --git a/src/base/api/Api.h b/src/base/api/Api.h index 7c686ff4..f3ad04c1 100644 --- a/src/base/api/Api.h +++ b/src/base/api/Api.h @@ -1,6 +1,6 @@ /* XMRig - * Copyright (c) 2018-2023 SChernykh - * Copyright (c) 2016-2023 XMRig , + * Copyright (c) 2018-2024 SChernykh + * Copyright (c) 2016-2024 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From c7c26d97fe6474416aaf8263d2b08ba00100f010 Mon Sep 17 00:00:00 2001 From: SChernykh <15806605+SChernykh@users.noreply.github.com> Date: Sat, 13 Apr 2024 20:32:16 +0200 Subject: [PATCH 3/5] RandomX: check pointer sizes during JIT initialization --- src/crypto/randomx/randomx.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/crypto/randomx/randomx.cpp b/src/crypto/randomx/randomx.cpp index ed520aa8..0485d4ec 100644 --- a/src/crypto/randomx/randomx.cpp +++ b/src/crypto/randomx/randomx.cpp @@ -260,6 +260,7 @@ typedef void(randomx::JitCompilerX86::* InstructionGeneratorX86_2)(const randomx #define JIT_HANDLE(x, prev) do { \ const InstructionGeneratorX86_2 p = &randomx::JitCompilerX86::h_##x; \ + static_assert(sizeof(p) == sizeof(randomx::JitCompilerX86::engine[k]), "Pointer size mismatch"); \ memcpy(randomx::JitCompilerX86::engine + k, &p, sizeof(p)); \ } while (0) From caae7c64f0c920b633b78fb03413fdb67d459f3e Mon Sep 17 00:00:00 2001 From: SChernykh <15806605+SChernykh@users.noreply.github.com> Date: Sun, 14 Apr 2024 09:13:00 +0200 Subject: [PATCH 4/5] RandomX: correct memcpy size for JIT initialization No buffer overflow, better fix for `_FORTIFY_SOURCE` --- src/crypto/randomx/jit_compiler_a64.cpp | 2 +- src/crypto/randomx/jit_compiler_a64.hpp | 2 +- src/crypto/randomx/jit_compiler_x86.cpp | 2 +- src/crypto/randomx/jit_compiler_x86.hpp | 2 +- src/crypto/randomx/randomx.cpp | 3 +-- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/crypto/randomx/jit_compiler_a64.cpp b/src/crypto/randomx/jit_compiler_a64.cpp index 4bfe157e..05dac9f7 100644 --- a/src/crypto/randomx/jit_compiler_a64.cpp +++ b/src/crypto/randomx/jit_compiler_a64.cpp @@ -1078,6 +1078,6 @@ void JitCompilerA64::h_NOP(Instruction& instr, uint32_t& codePos) { } -InstructionGeneratorA64 JitCompilerA64::engine[257] = {}; +InstructionGeneratorA64 JitCompilerA64::engine[256] = {}; } diff --git a/src/crypto/randomx/jit_compiler_a64.hpp b/src/crypto/randomx/jit_compiler_a64.hpp index 15c90af8..32ff5166 100644 --- a/src/crypto/randomx/jit_compiler_a64.hpp +++ b/src/crypto/randomx/jit_compiler_a64.hpp @@ -74,7 +74,7 @@ namespace randomx { void enableWriting() const; void enableExecution() const; - static InstructionGeneratorA64 engine[257]; + static InstructionGeneratorA64 engine[256]; private: const bool hugePages; diff --git a/src/crypto/randomx/jit_compiler_x86.cpp b/src/crypto/randomx/jit_compiler_x86.cpp index 78ab8b58..7f9fb3b6 100644 --- a/src/crypto/randomx/jit_compiler_x86.cpp +++ b/src/crypto/randomx/jit_compiler_x86.cpp @@ -1443,6 +1443,6 @@ namespace randomx { emitByte(0x90, code, codePos); } - alignas(64) InstructionGeneratorX86 JitCompilerX86::engine[257] = {}; + alignas(64) InstructionGeneratorX86 JitCompilerX86::engine[256] = {}; } diff --git a/src/crypto/randomx/jit_compiler_x86.hpp b/src/crypto/randomx/jit_compiler_x86.hpp index 11106b2f..15261922 100644 --- a/src/crypto/randomx/jit_compiler_x86.hpp +++ b/src/crypto/randomx/jit_compiler_x86.hpp @@ -81,7 +81,7 @@ namespace randomx { void enableWriting() const; void enableExecution() const; - alignas(64) static InstructionGeneratorX86 engine[257]; + alignas(64) static InstructionGeneratorX86 engine[256]; private: int registerUsage[RegistersCount] = {}; diff --git a/src/crypto/randomx/randomx.cpp b/src/crypto/randomx/randomx.cpp index 0485d4ec..9047293b 100644 --- a/src/crypto/randomx/randomx.cpp +++ b/src/crypto/randomx/randomx.cpp @@ -260,8 +260,7 @@ typedef void(randomx::JitCompilerX86::* InstructionGeneratorX86_2)(const randomx #define JIT_HANDLE(x, prev) do { \ const InstructionGeneratorX86_2 p = &randomx::JitCompilerX86::h_##x; \ - static_assert(sizeof(p) == sizeof(randomx::JitCompilerX86::engine[k]), "Pointer size mismatch"); \ - memcpy(randomx::JitCompilerX86::engine + k, &p, sizeof(p)); \ + memcpy(randomx::JitCompilerX86::engine + k, &p, sizeof(randomx::JitCompilerX86::engine[k])); \ } while (0) #elif (XMRIG_ARM == 8) From 57f3e9c3daad45b25d39f3011cf51b28c7511184 Mon Sep 17 00:00:00 2001 From: xmrig Date: Tue, 23 Apr 2024 16:17:26 +0700 Subject: [PATCH 5/5] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e93d79d..df4440a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# v6.21.3 +- [#3462](https://github.com/xmrig/xmrig/pull/3462) RandomX: correct memcpy size for JIT initialization. + # v6.21.2 - The dependencies of all prebuilt releases have been updated. Support for old Ubuntu releases has been dropped. - [#2800](https://github.com/xmrig/xmrig/issues/2800) Fixed donation with GhostRider algorithm for builds without KawPow algorithm.