From 70534846d1941819e6cbc7fcadd416f9ae0f43b2 Mon Sep 17 00:00:00 2001 From: John Sully Date: Fri, 19 Jul 2019 01:37:34 -0400 Subject: [PATCH 1/2] Modules must have execute permissions to load --- src/module.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/module.c b/src/module.c index f4f753c0..eb7e1f07 100644 --- a/src/module.c +++ b/src/module.c @@ -30,6 +30,7 @@ #include "server.h" #include "cluster.h" #include +#include #define REDISMODULE_CORE 1 #include "redismodule.h" @@ -5159,6 +5160,15 @@ int moduleLoad(const char *path, void **module_argv, int module_argc) { int (*onload)(void *, void **, int); void *handle; RedisModuleCtx ctx = REDISMODULE_CTX_INIT; + + struct stat st; + if (stat(path, &st) == 0) + { // this check is best effort + if (!(st.st_mode & S_IEXEC)) { + serverLog(LL_WARNING, "Module %s failed to load: It does not have execute permissions.", path); + return C_ERR; + } + } handle = dlopen(path,RTLD_NOW|RTLD_LOCAL); if (handle == NULL) { From ff682d790249741c6b0f387c1407b40b6f26b05f Mon Sep 17 00:00:00 2001 From: John Sully Date: Fri, 19 Jul 2019 15:28:31 -0400 Subject: [PATCH 2/2] Modules must have execute permissions to load --- src/module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module.c b/src/module.c index eb7e1f07..316ed47f 100644 --- a/src/module.c +++ b/src/module.c @@ -5164,7 +5164,7 @@ int moduleLoad(const char *path, void **module_argv, int module_argc) { struct stat st; if (stat(path, &st) == 0) { // this check is best effort - if (!(st.st_mode & S_IEXEC)) { + if (!(st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) { serverLog(LL_WARNING, "Module %s failed to load: It does not have execute permissions.", path); return C_ERR; }