From 6a0edf0cc390f9b497000614f526df266d46a26a Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Sat, 7 Mar 2026 20:18:51 +0100 Subject: [PATCH] Fix pcl-ivv: remove weak attribute from debug hooks (#362) Removed weak attribute from debug hooks (psys_debug_abort_on_sqllock and psys_debug_configure_core_dump). Made functions static in psys.c and removed declarations from psys.h. Functions can no longer be overridden by external libraries, preventing potential code execution and security bypass. Fixes #289 Co-authored-by: Levi Neely --- pclsync/psys.c | 25 +++++++++++++++++++++++-- pclsync/psys.h | 2 -- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/pclsync/psys.c b/pclsync/psys.c index 7319c15..b4b6df3 100644 --- a/pclsync/psys.c +++ b/pclsync/psys.c @@ -13,8 +13,29 @@ static gid_t psync_gid; static gid_t *psync_gids; static int psync_gids_cnt; -__attribute__((weak)) void psys_debug_abort_on_sqllock(uint64_t millisec) {} -__attribute__((weak)) void psys_debug_configure_core_dump() {} +static void psys_debug_abort_on_sqllock(uint64_t millisec) { +#ifdef DEBUG + if (psql_locked()) { + pdbg_logf(D_CRITICAL, "trying to sleep while holding sql lock, aborting"); + psql_dump_locks(); + abort(); + } +#else + (void)millisec; +#endif +} +static void psys_debug_configure_core_dump() { +#ifdef DEBUG + struct rlimit limit; + if (getrlimit(RLIMIT_CORE, &limit)) + pdbg_logf(D_ERROR, "getrlimit failed errno=%d", errno); + else { + limit.rlim_cur = limit.rlim_max; + if (setrlimit(RLIMIT_CORE, &limit)) + pdbg_logf(D_ERROR, "setrlimit failed errno=%d", errno); + } +#endif +} static void abort_on_sqllock(uint64_t millisec) { psys_debug_abort_on_sqllock(millisec); diff --git a/pclsync/psys.h b/pclsync/psys.h index b1b36c3..217d3aa 100644 --- a/pclsync/psys.h +++ b/pclsync/psys.h @@ -13,8 +13,6 @@ gid_t *psys_get_gids(); int psys_get_gids_cnt(); void psys_init(); -void psys_debug_abort_on_sqllock(uint64_t millisec); -void psys_debug_configure_core_dump(); time_t psys_time_seconds(); uint64_t psys_time_milliseconds(); void psys_sleep_milliseconds(uint64_t millisec);