From 8d103f7bbce0cd0b41523a5ab894ad6b0547c357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ondr=CC=8Cej=20Sury=CC=81?= Date: Wed, 8 Feb 2023 09:29:54 +0100 Subject: [PATCH] Enforce version drift limits for libuv libuv support for receiving multiple UDP messages in a single system call (recvmmsg()) has been tweaked several times between libuv versions 1.35.0 and 1.40.0. Mixing and matching libuv versions within that span may lead to assertion failures and is therefore considered harmful, so try to limit potential damage be preventing users from mixing libuv versions with distinct sets of recvmmsg()-related flags. (cherry picked from commit 735d09bffed7febe636542c07f3269b407e6113c) --- lib/isc/netmgr/netmgr.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index 816e185de0..ee96138721 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -204,8 +204,10 @@ isc__nm_threadpool_initialize(uint32_t workers) { #elif HAVE_DECL_UV_UDP_MMSG_FREE #define MINIMAL_UV_VERSION UV_VERSION(1, 40, 0) #elif HAVE_DECL_UV_UDP_RECVMMSG +#define MAXIMAL_UV_VERSION UV_VERSION(1, 39, 99) #define MINIMAL_UV_VERSION UV_VERSION(1, 37, 0) #else +#define MAXIMAL_UV_VERSION UV_VERSION(1, 34, 99) #define MINIMAL_UV_VERSION UV_VERSION(1, 0, 0) #endif @@ -216,10 +218,19 @@ isc__netmgr_create(isc_mem_t *mctx, uint32_t workers, isc_nm_t **netmgrp) { REQUIRE(workers > 0); +#ifdef MAXIMAL_UV_VERSION + if (uv_version() > MAXIMAL_UV_VERSION) { + FATAL_ERROR("libuv version too new: running with libuv %s " + "when compiled with libuv %s will lead to " + "libuv failures", + uv_version_string(), UV_VERSION_STRING); + } +#endif /* MAXIMAL_UV_VERSION */ + if (uv_version() < MINIMAL_UV_VERSION) { FATAL_ERROR("libuv version too old: running with libuv %s " "when compiled with libuv %s will lead to " - "libuv failures because of unknown flags", + "libuv failures", uv_version_string(), UV_VERSION_STRING); }