redis: Bump to 7.0.6

This commit is contained in:
Tee KOBAYASHI 2022-12-13 11:35:09 +09:00 committed by xtkoba
parent 3e8fce2eef
commit 2d09944c86
7 changed files with 76 additions and 249 deletions

View File

@ -1,21 +0,0 @@
diff -uNr redis-6.0.9/src/bio.c redis-6.0.9.mod/src/bio.c
--- redis-6.0.9/src/bio.c 2020-10-27 07:12:01.000000000 +0000
+++ redis-6.0.9.mod/src/bio.c 2020-11-22 17:02:03.692060558 +0000
@@ -266,15 +266,7 @@
for (j = 0; j < BIO_NUM_OPS; j++) {
if (bio_threads[j] == pthread_self()) continue;
- if (bio_threads[j] && pthread_cancel(bio_threads[j]) == 0) {
- if ((err = pthread_join(bio_threads[j],NULL)) != 0) {
- serverLog(LL_WARNING,
- "Bio thread for job type #%d can not be joined: %s",
- j, strerror(err));
- } else {
- serverLog(LL_WARNING,
- "Bio thread for job type #%d terminated",j);
- }
- }
+ pthread_kill(bio_threads[j], 0);
+ serverLog(LL_WARNING, "Bio thread for job type #%d terminated",j);
}
}

View File

@ -2,11 +2,10 @@ TERMUX_PKG_HOMEPAGE=https://redis.io/
TERMUX_PKG_DESCRIPTION="In-memory data structure store used as a database, cache and message broker"
TERMUX_PKG_LICENSE="BSD 3-Clause"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=6.2.7
TERMUX_PKG_REVISION=1
TERMUX_PKG_VERSION=7.0.6
TERMUX_PKG_SRCURL=https://download.redis.io/releases/redis-$TERMUX_PKG_VERSION.tar.gz
TERMUX_PKG_SHA256=b7a79cc3b46d3c6eb52fa37dde34a4a60824079ebdfb3abfbbfa035947c55319
TERMUX_PKG_DEPENDS="libandroid-execinfo"
TERMUX_PKG_SHA256=7b33a7e890d13e27af1f246acb16312669ad8a1d56ce8f807dfbcd3c09aa7bb3
TERMUX_PKG_DEPENDS="libandroid-execinfo, libandroid-glob"
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_CONFFILES="etc/redis.conf"
@ -16,7 +15,7 @@ termux_step_pre_configure() {
CPPFLAGS+=" -DHAVE_BACKTRACE"
CFLAGS+=" $CPPFLAGS"
LDFLAGS+=" -landroid-execinfo"
LDFLAGS+=" -landroid-execinfo -landroid-glob"
}
termux_step_post_make_install() {

View File

@ -1,22 +0,0 @@
diff -uNr redis-6.0.9/src/networking.c redis-6.0.9.mod/src/networking.c
--- redis-6.0.9/src/networking.c 2020-10-27 07:12:01.000000000 +0000
+++ redis-6.0.9.mod/src/networking.c 2020-11-22 17:06:47.317043042 +0000
@@ -3082,16 +3082,8 @@
int err, j;
for (j = 0; j < server.io_threads_num; j++) {
if (io_threads[j] == pthread_self()) continue;
- if (io_threads[j] && pthread_cancel(io_threads[j]) == 0) {
- if ((err = pthread_join(io_threads[j],NULL)) != 0) {
- serverLog(LL_WARNING,
- "IO thread(tid:%lu) can not be joined: %s",
- (unsigned long)io_threads[j], strerror(err));
- } else {
- serverLog(LL_WARNING,
- "IO thread(tid:%lu) terminated",(unsigned long)io_threads[j]);
- }
- }
+ pthread_kill(io_threads[j], 0);
+ serverLog(LL_WARNING, "IO thread(tid:%lu) terminated",(unsigned long)io_threads[j]);
}
}

View File

@ -1,11 +1,72 @@
--- ./src/debug.c.orig 2021-05-01 14:39:04.609215050 +0000
+++ ./src/debug.c 2021-05-01 14:39:20.555895312 +0000
@@ -1706,7 +1706,7 @@
--- a/src/bio.c
+++ b/src/bio.c
@@ -295,7 +295,11 @@ void bioKillThreads(void) {
for (j = 0; j < BIO_NUM_OPS; j++) {
if (bio_threads[j] == pthread_self()) continue;
+#ifndef __ANDROID__
if (bio_threads[j] && pthread_cancel(bio_threads[j]) == 0) {
+#else
+ if (bio_threads[j] && pthread_kill(bio_threads[j], SIGUSR2) == 0) {
+#endif
if ((err = pthread_join(bio_threads[j],NULL)) != 0) {
serverLog(LL_WARNING,
"Bio thread for job type #%d can not be joined: %s",
--- a/src/debug.c
+++ b/src/debug.c
@@ -1708,7 +1708,11 @@ int memtest_test_linux_anonymous_maps(vo
static void killMainThread(void) {
int err;
- if (pthread_self() != server.main_thread_id && pthread_cancel(server.main_thread_id) == 0) {
+ if (pthread_self() != server.main_thread_id && pthread_kill(server.main_thread_id, 0) == 0) {
+#ifndef __ANDROID__
if (pthread_self() != server.main_thread_id && pthread_cancel(server.main_thread_id) == 0) {
+#else
+ if (pthread_self() != server.main_thread_id && pthread_kill(server.main_thread_id, SIGUSR2) == 0) {
+#endif
if ((err = pthread_join(server.main_thread_id,NULL)) != 0) {
serverLog(LL_WARNING, "main thread can not be joined: %s", strerror(err));
} else {
--- a/src/networking.c
+++ b/src/networking.c
@@ -3606,7 +3606,11 @@ void killIOThreads(void) {
int err, j;
for (j = 0; j < server.io_threads_num; j++) {
if (io_threads[j] == pthread_self()) continue;
+#ifndef __ANDROID__
if (io_threads[j] && pthread_cancel(io_threads[j]) == 0) {
+#else
+ if (io_threads[j] && pthread_kill(io_threads[j], SIGUSR2) == 0) {
+#endif
if ((err = pthread_join(io_threads[j],NULL)) != 0) {
serverLog(LL_WARNING,
"IO thread(tid:%lu) can not be joined: %s",
--- a/src/server.c
+++ b/src/server.c
@@ -3144,12 +3144,27 @@ void resetServerStats(void) {
server.aof_delayed_fsync = 0;
}
+#ifdef __ANDROID__
+static void threadSignalHandler(int signum) {
+ pthread_exit(0);
+}
+#endif
+
/* Make the thread killable at any time, so that kill threads functions
* can work reliably (default cancelability type is PTHREAD_CANCEL_DEFERRED).
* Needed for pthread_cancel used by the fast memory test used by the crash report. */
void makeThreadKillable(void) {
+#ifndef __ANDROID__
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+#else
+ struct sigaction actions;
+ memset(&actions, 0, sizeof(actions));
+ sigemptyset(&actions.sa_mask);
+ actions.sa_flags = 0;
+ actions.sa_handler = threadSignalHandler;
+ sigaction(SIGUSR2, &actions, NULL);
+#endif
}
void initServer(void) {

View File

@ -1,175 +0,0 @@
Borrowed from https://github.com/gentoo/gentoo/blob/1f50e0472587273c96c7aec4271692027b8c753c/dev-db/redis/files/redis-6.2.7-cve-2022-3647.patch
This is backported patch from upstream commit for version 6.2.7 which fixes CVE-2022-3647.
Upstream-commit: https://github.com/redis/redis/commit/0bf90d944313919eb8e63d3588bf63a367f020a3
Bug: https://bugs.gentoo.org/877863
diff --git a/src/debug.c b/src/debug.c
index 71ef51f8b..40fffec52 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -1019,61 +1019,88 @@ void bugReportStart(void) {
}
#ifdef HAVE_BACKTRACE
-static void *getMcontextEip(ucontext_t *uc) {
+
+/* Returns the current eip and set it to the given new value (if its not NULL) */
+static void* getAndSetMcontextEip(ucontext_t *uc, void *eip) {
+#define NOT_SUPPORTED() do {\
+ UNUSED(uc);\
+ UNUSED(eip);\
+ return NULL;\
+} while(0)
+#define GET_SET_RETURN(target_var, new_val) do {\
+ void *old_val = (void*)target_var; \
+ if (new_val) { \
+ void **temp = (void**)&target_var; \
+ *temp = new_val; \
+ } \
+ return old_val; \
+} while(0)
#if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_6)
/* OSX < 10.6 */
#if defined(__x86_64__)
- return (void*) uc->uc_mcontext->__ss.__rip;
+ GET_SET_RETURN(uc->uc_mcontext->__ss.__rip, eip);
#elif defined(__i386__)
- return (void*) uc->uc_mcontext->__ss.__eip;
+ GET_SET_RETURN(uc->uc_mcontext->__ss.__eip, eip);
#else
- return (void*) uc->uc_mcontext->__ss.__srr0;
+ GET_SET_RETURN(uc->uc_mcontext->__ss.__srr0, eip);
#endif
#elif defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_6)
/* OSX >= 10.6 */
#if defined(_STRUCT_X86_THREAD_STATE64) && !defined(__i386__)
- return (void*) uc->uc_mcontext->__ss.__rip;
+ GET_SET_RETURN(uc->uc_mcontext->__ss.__rip, eip);
#elif defined(__i386__)
- return (void*) uc->uc_mcontext->__ss.__eip;
+ GET_SET_RETURN(uc->uc_mcontext->__ss.__eip, eip);
#else
/* OSX ARM64 */
- return (void*) arm_thread_state64_get_pc(uc->uc_mcontext->__ss);
+ void *old_val = (void*)arm_thread_state64_get_pc(uc->uc_mcontext->__ss);
+ if (eip) {
+ arm_thread_state64_set_pc_fptr(uc->uc_mcontext->__ss, eip);
+ }
+ return old_val;
#endif
#elif defined(__linux__)
/* Linux */
#if defined(__i386__) || ((defined(__X86_64__) || defined(__x86_64__)) && defined(__ILP32__))
- return (void*) uc->uc_mcontext.gregs[14]; /* Linux 32 */
+ GET_SET_RETURN(uc->uc_mcontext.gregs[14], eip);
#elif defined(__X86_64__) || defined(__x86_64__)
- return (void*) uc->uc_mcontext.gregs[16]; /* Linux 64 */
+ GET_SET_RETURN(uc->uc_mcontext.gregs[16], eip);
#elif defined(__ia64__) /* Linux IA64 */
- return (void*) uc->uc_mcontext.sc_ip;
+ GET_SET_RETURN(uc->uc_mcontext.sc_ip, eip);
#elif defined(__arm__) /* Linux ARM */
- return (void*) uc->uc_mcontext.arm_pc;
+ GET_SET_RETURN(uc->uc_mcontext.arm_pc, eip);
#elif defined(__aarch64__) /* Linux AArch64 */
- return (void*) uc->uc_mcontext.pc;
+ GET_SET_RETURN(uc->uc_mcontext.pc, eip);
+ #else
+ NOT_SUPPORTED();
#endif
#elif defined(__FreeBSD__)
/* FreeBSD */
#if defined(__i386__)
- return (void*) uc->uc_mcontext.mc_eip;
+ GET_SET_RETURN(uc->uc_mcontext.mc_eip, eip);
#elif defined(__x86_64__)
- return (void*) uc->uc_mcontext.mc_rip;
+ GET_SET_RETURN(uc->uc_mcontext.mc_rip, eip);
+ #else
+ NOT_SUPPORTED();
#endif
#elif defined(__OpenBSD__)
/* OpenBSD */
#if defined(__i386__)
- return (void*) uc->sc_eip;
+ GET_SET_RETURN(uc->sc_eip, eip);
#elif defined(__x86_64__)
- return (void*) uc->sc_rip;
+ GET_SET_RETURN(uc->sc_rip, eip);
+ #else
+ NOT_SUPPORTED();
#endif
#elif defined(__NetBSD__)
#if defined(__i386__)
- return (void*) uc->uc_mcontext.__gregs[_REG_EIP];
+ GET_SET_RETURN(uc->uc_mcontext.__gregs[_REG_EIP], eip);
#elif defined(__x86_64__)
- return (void*) uc->uc_mcontext.__gregs[_REG_RIP];
+ GET_SET_RETURN(uc->uc_mcontext.__gregs[_REG_RIP], eip);
+ #else
+ NOT_SUPPORTED();
#endif
#elif defined(__DragonFly__)
- return (void*) uc->uc_mcontext.mc_rip;
+ GET_SET_RETURN(uc->uc_mcontext.mc_rip, eip);
#else
return NULL;
#endif
@@ -1800,6 +1827,10 @@ void dumpCodeAroundEIP(void *eip) {
}
}
+void invalidFunctionWasCalled() {}
+
+typedef void (*invalidFunctionWasCalledType)();
+
void sigsegvHandler(int sig, siginfo_t *info, void *secret) {
UNUSED(secret);
UNUSED(info);
@@ -1817,13 +1848,30 @@ void sigsegvHandler(int sig, siginfo_t *info, void *secret) {
#ifdef HAVE_BACKTRACE
ucontext_t *uc = (ucontext_t*) secret;
- void *eip = getMcontextEip(uc);
+ void *eip = getAndSetMcontextEip(uc, NULL);
if (eip != NULL) {
serverLog(LL_WARNING,
"Crashed running the instruction at: %p", eip);
}
- logStackTrace(getMcontextEip(uc), 1);
+ if (eip == info->si_addr) {
+ /* When eip matches the bad address, it's an indication that we crashed when calling a non-mapped
+ * function pointer. In that case the call to backtrace will crash trying to access that address and we
+ * won't get a crash report logged. Set it to a valid point to avoid that crash. */
+
+ /* This trick allow to avoid compiler warning */
+ void *ptr;
+ invalidFunctionWasCalledType *ptr_ptr = (invalidFunctionWasCalledType*)&ptr;
+ *ptr_ptr = invalidFunctionWasCalled;
+ getAndSetMcontextEip(uc, ptr);
+ }
+
+ logStackTrace(eip, 1);
+
+ if (eip == info->si_addr) {
+ /* Restore old eip */
+ getAndSetMcontextEip(uc, eip);
+ }
logRegisters(uc);
#endif
@@ -1918,7 +1966,7 @@ void watchdogSignalHandler(int sig, siginfo_t *info, void *secret) {
serverLogFromHandler(LL_WARNING,"\n--- WATCHDOG TIMER EXPIRED ---");
#ifdef HAVE_BACKTRACE
- logStackTrace(getMcontextEip(uc), 1);
+ logStackTrace(getAndSetMcontextEip(uc, NULL), 1);
#else
serverLogFromHandler(LL_WARNING,"Sorry: no support for backtrace().");
#endif
--
2.37.4

View File

@ -1,14 +0,0 @@
diff -uNr redis-6.0.9/src/server.c redis-6.0.9.mod/src/server.c
--- redis-6.0.9/src/server.c 2020-10-27 07:12:01.000000000 +0000
+++ redis-6.0.9.mod/src/server.c 2020-11-22 17:03:52.033053867 +0000
@@ -2813,8 +2813,10 @@
* can work reliably (default cancelability type is PTHREAD_CANCEL_DEFERRED).
* Needed for pthread_cancel used by the fast memory test used by the crash report. */
void makeThreadKillable(void) {
+#ifndef __ANDROID__
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+#endif
}
void initServer(void) {

View File

@ -1,12 +1,11 @@
diff -uNr redis-6.0.1/src/server.h redis-6.0.1.mod/src/server.h
--- redis-6.0.1/src/server.h 2020-05-02 01:10:20.000000000 +0300
+++ redis-6.0.1.mod/src/server.h 2020-05-13 12:31:16.199918079 +0300
@@ -106,7 +106,7 @@
--- a/src/server.h
+++ b/src/server.h
@@ -118,7 +118,7 @@
#define RDB_EOF_MARK_SIZE 40
#define CONFIG_REPL_BACKLOG_MIN_SIZE (1024*16) /* 16k */
#define CONFIG_BGSAVE_RETRY_DELAY 5 /* Wait a few secs before trying again. */
-#define CONFIG_DEFAULT_PID_FILE "/var/run/redis.pid"
+#define CONFIG_DEFAULT_PID_FILE "@TERMUX_PREFIX@/var/run/redis.pid"
#define CONFIG_DEFAULT_CLUSTER_CONFIG_FILE "nodes.conf"
#define CONFIG_DEFAULT_UNIX_SOCKET_PERM 0
#define CONFIG_DEFAULT_LOGFILE ""
#define CONFIG_DEFAULT_BINDADDR_COUNT 2
#define CONFIG_DEFAULT_BINDADDR { "*", "-::*" }
#define NET_HOST_STR_LEN 256 /* Longest valid hostname */