Skip to content

Commit

Permalink
synced with antirez/5.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
tporadowski committed Mar 31, 2020
1 parent 8aa3416 commit 560152f
Show file tree
Hide file tree
Showing 22 changed files with 333 additions and 91 deletions.
98 changes: 98 additions & 0 deletions 00-RELEASENOTES
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,104 @@ CRITICAL: There is a critical bug affecting MOST USERS. Upgrade ASAP.
SECURITY: There are security fixes in the release.
--------------------------------------------------------------------------------

================================================================================
Redis 5.0.8 Released Thu Mar 12 16:05:41 CET 2020
================================================================================

Upgrade urgency HIGH: This release fixes security issues.

This is a list of fixes in this release:

Salvatore Sanfilippo in commit 2bea502d:
Merge pull request #6975 from dustinmm80/add-arm-latomic-linking
Dustin Collins in commit b5931405:
Fix Pi building needing -latomic, backport
1 file changed, 9 insertions(+)

srzhao in commit fd441300:
fix impl of aof-child whitelist SIGUSR1 feature.
1 file changed, 5 insertions(+), 4 deletions(-)

Ariel in commit 77ff332b:
fix ThreadSafeContext lock/unlock function names
1 file changed, 2 insertions(+), 2 deletions(-)

Guy Benoish in commit 4f0f799c:
XREADGROUP should propagate XCALIM/SETID in MULTI/EXEC
1 file changed, 2 insertions(+), 2 deletions(-)

Oran Agra in commit 0c1273c3:
Fix client flags to be int64 in module.c
1 file changed, 3 insertions(+), 3 deletions(-)

Guy Benoish in commit 708a4e8a:
Fix small bugs related to replica and monitor ambiguity
2 files changed, 8 insertions(+), 6 deletions(-)

WuYunlong in commit eac4115d:
Fix lua related memory leak.
1 file changed, 1 insertion(+)

antirez in commit d075df17:
Simplify #6379 changes.
2 files changed, 4 insertions(+), 9 deletions(-)

WuYunlong in commit 80a49c37:
Free allocated sds in pfdebugCommand() to avoid memory leak.
1 file changed, 1 insertion(+)

antirez in commit 60870d3a:
Jump to right label on AOF parsing error.
1 file changed, 6 insertions(+), 4 deletions(-)

antirez in commit d90f599b:
Free fakeclient argv on AOF error.
1 file changed, 11 insertions(+), 3 deletions(-)

WuYunlong in commit 8ee3bddf:
Fix potential memory leak of rioWriteBulkStreamID().
1 file changed, 4 insertions(+), 1 deletion(-)

WuYunlong in commit 4780fe78:
Fix potential memory leak of clusterLoadConfig().
1 file changed, 20 insertions(+), 5 deletions(-)

Leo Murillo in commit f3b77510:
Fix bug on KEYS command where pattern starts with * followed by \x00 (null char).
1 file changed, 1 insertion(+), 1 deletion(-)

Guy Benoish in commit 7f3fcedb:
Blocking XREAD[GROUP] should always reply with valid data (or timeout)
3 files changed, 44 insertions(+), 10 deletions(-)

antirez in commit f93b2fa5:
XCLAIM: Create the consumer only on successful claims.
1 file changed, 4 insertions(+), 2 deletions(-)

Guy Benoish in commit 89682d96:
Stream: Handle streamID-related edge cases
4 files changed, 54 insertions(+), 4 deletions(-)

antirez in commit 920e108f:
Fix ip and missing mode in RM_GetClusterNodeInfo().
1 file changed, 5 insertions(+), 2 deletions(-)

antirez in commit 7569b210:
Inline protocol: handle empty strings well.
1 file changed, 2 insertions(+), 6 deletions(-)

Khem Raj in commit 3c610b4e:
Mark extern definition of SDS_NOINIT in sds.h
1 file changed, 1 insertion(+), 1 deletion(-)

Seunghoon Woo in commit 16b2d07f:
[FIX] revisit CVE-2015-8080 vulnerability
1 file changed, 6 insertions(+), 4 deletions(-)

yz1509 in commit 19f33585:
avoid sentinel changes promoted_slave to be its own replica.
1 file changed, 1 insertion(+), 1 deletion(-)

================================================================================
Redis 5.0.7 Released Tue Nov 19 17:52:44 CET 2019
================================================================================
Expand Down
9 changes: 1 addition & 8 deletions deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ distclean:
-(cd hiredis && $(MAKE) clean) > /dev/null || true
-(cd linenoise && $(MAKE) clean) > /dev/null || true
-(cd lua && $(MAKE) clean) > /dev/null || true
-(cd geohash-int && $(MAKE) clean) > /dev/null || true
-(cd jemalloc && [ -f Makefile ] && $(MAKE) distclean) > /dev/null || true
-(rm -f .make-*)

Expand Down Expand Up @@ -78,13 +77,7 @@ JEMALLOC_LDFLAGS= $(LDFLAGS)

jemalloc: .make-prerequisites
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
cd jemalloc && ./configure --with-lg-quantum=3 --with-jemalloc-prefix=je_ --enable-cc-silence CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)"
cd jemalloc && ./configure --with-version=5.1.0-0-g0 --with-lg-quantum=3 --with-jemalloc-prefix=je_ --enable-cc-silence CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)"
cd jemalloc && $(MAKE) CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)" lib/libjemalloc.a

.PHONY: jemalloc

geohash-int: .make-prerequisites
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
cd geohash-int && $(MAKE)

.PHONY: geohash-int
32 changes: 27 additions & 5 deletions deps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,34 @@ How to upgrade the above dependencies
Jemalloc
---

Jemalloc is unmodified. We only change settings via the `configure` script of Jemalloc using the `--with-lg-quantum` option, setting it to the value of 3 instead of 4. This provides us with more size classes that better suit the Redis data structures, in order to gain memory efficiency.

So in order to upgrade jemalloc:
Jemalloc is modified with changes that allow us to implement the Redis
active defragmentation logic. However this feature of Redis is not mandatory
and Redis is able to understand if the Jemalloc version it is compiled
against supports such Redis-specific modifications. So in theory, if you
are not interested in the active defragmentation, you can replace Jemalloc
just following tose steps:

1. Remove the jemalloc directory.
2. Substitute it with the new jemalloc source tree.
3. Edit the Makefile localted in the same directory as the README you are
reading, and change the --with-version in the Jemalloc configure script
options with the version you are using. This is required because otherwise
Jemalloc configuration script is broken and will not work nested in another
git repository.

However note that we change Jemalloc settings via the `configure` script of Jemalloc using the `--with-lg-quantum` option, setting it to the value of 3 instead of 4. This provides us with more size classes that better suit the Redis data structures, in order to gain memory efficiency.

If you want to upgrade Jemalloc while also providing support for
active defragmentation, in addition to the above steps you need to perform
the following additional steps:

5. In Jemalloc three, file `include/jemalloc/jemalloc_macros.h.in`, make sure
to add `#define JEMALLOC_FRAG_HINT`.
6. Implement the function `je_get_defrag_hint()` inside `src/jemalloc.c`. You
can see how it is implemented in the current Jemalloc source tree shipped
with Redis, and rewrite it according to the new Jemalloc internals, if they
changed, otherwise you could just copy the old implementation if you are
upgrading just to a similar version of Jemalloc.

Geohash
---
Expand All @@ -28,7 +50,7 @@ This is never upgraded since it's part of the Redis project. If there are change
Hiredis
---

Hiredis uses the SDS string library, that must be the same version used inside Redis itself. Hiredis is also very critical for Sentinel. Historically Redis often used forked versions of hiredis in a way or the other. In order to upgrade it is adviced to take a lot of care:
Hiredis uses the SDS string library, that must be the same version used inside Redis itself. Hiredis is also very critical for Sentinel. Historically Redis often used forked versions of hiredis in a way or the other. In order to upgrade it is advised to take a lot of care:

1. Check with diff if hiredis API changed and what impact it could have in Redis.
2. Make sure thet the SDS library inside Hiredis and inside Redis are compatible.
Expand Down Expand Up @@ -61,6 +83,6 @@ and our version:

1. Makefile is modified to allow a different compiler than GCC.
2. We have the implementation source code, and directly link to the following external libraries: `lua_cjson.o`, `lua_struct.o`, `lua_cmsgpack.o` and `lua_bit.o`.
3. There is a security fix in `ldo.c`, line 498: The check for `LUA_SIGNATURE[0]` is removed in order toa void direct bytecode exectuion.
3. There is a security fix in `ldo.c`, line 498: The check for `LUA_SIGNATURE[0]` is removed in order toa void direct bytecode execution.


16 changes: 13 additions & 3 deletions deps/lua/src/lua_cmsgpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ void mp_encode_bytes(lua_State *L, mp_buf *buf, const unsigned char *s, size_t l
} else {
hdr[0] = 0xdb;
hdr[1] = (unsigned char)((len&0xff000000)>>24);
hdr[2] = (unsigned char)((len & 0xff0000) >> 16);
hdr[3] = (unsigned char)((len & 0xff00) >> 8);
hdr[4] = (unsigned char)(len & 0xff);
hdr[2] = (unsigned char)((len&0xff0000)>>16);
hdr[3] = (unsigned char)((len&0xff00)>>8);
hdr[4] = (unsigned char)(len&0xff);
hdrlen = 5;
}
mp_buf_append(L,buf,hdr,hdrlen);
Expand Down Expand Up @@ -385,6 +385,7 @@ void mp_encode_lua_table_as_array(lua_State *L, mp_buf *buf, int level) {
#endif

mp_encode_array(L,buf,len);
luaL_checkstack(L, 1, "in function mp_encode_lua_table_as_array");
for (j = 1; j <= len; j++) {
lua_pushnumber(L,j);
lua_gettable(L,-2);
Expand All @@ -400,6 +401,7 @@ void mp_encode_lua_table_as_map(lua_State *L, mp_buf *buf, int level) {
* Lua API, we need to iterate a first time. Note that an alternative
* would be to do a single run, and then hack the buffer to insert the
* map opcodes for message pack. Too hackish for this lib. */
luaL_checkstack(L, 3, "in function mp_encode_lua_table_as_map");
lua_pushnil(L);
while(lua_next(L,-2)) {
lua_pop(L,1); /* remove value, keep key for next iteration. */
Expand Down Expand Up @@ -515,10 +517,14 @@ int mp_pack(lua_State *L) {
if (nargs == 0)
return luaL_argerror(L, 0, "MessagePack pack needs input.");

if (!lua_checkstack(L, nargs))
return luaL_argerror(L, 0, "Too many arguments for MessagePack pack.");

buf = mp_buf_new(L);
for(i = 1; i <= nargs; i++) {
/* Copy argument i to top of stack for _encode processing;
* the encode function pops it from the stack when complete. */
luaL_checkstack(L, 1, "in function mp_check");
lua_pushvalue(L, i);

mp_encode_lua_type(L,buf,0);
Expand Down Expand Up @@ -547,6 +553,7 @@ void mp_decode_to_lua_array(lua_State *L, mp_cur *c, size_t len) {
int index = 1;

lua_newtable(L);
luaL_checkstack(L, 1, "in function mp_decode_to_lua_array");
while(len--) {
lua_pushnumber(L,index++);
mp_decode_to_lua_type(L,c);
Expand Down Expand Up @@ -821,6 +828,9 @@ int mp_unpack_full(lua_State *L, int limit, int offset) {
* subtract the entire buffer size from the unprocessed size
* to get our next start offset */
int offset = (int)(len - c.left); /* WIN_PORT_FIX cast (int) */

luaL_checkstack(L, 1, "in function mp_unpack_full");

/* Return offset -1 when we have have processed the entire buffer. */
lua_pushinteger(L, c.left == 0 ? -1 : offset);
/* Results are returned with the arg elements still
Expand Down
44 changes: 25 additions & 19 deletions deps/lua/src/lua_struct.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
** {======================================================
** Library for packing/unpacking structures.
** $Id: struct.c,v 1.4 2012/07/04 18:54:29 roberto Exp $
** $Id: struct.c,v 1.7 2018/05/11 22:04:31 roberto Exp $
** See Copyright Notice at the end of this file
** =======================================================
*/
Expand All @@ -15,8 +15,8 @@
** h/H - signed/unsigned short
** l/L - signed/unsigned long
** T - size_t
** i/In - signed/unsigned integer with size `n' (default is size of int)
** cn - sequence of `n' chars (from/to a string); when packing, n==0 means
** i/In - signed/unsigned integer with size 'n' (default is size of int)
** cn - sequence of 'n' chars (from/to a string); when packing, n==0 means
the whole string; when unpacking, n==0 means use the previous
read number as the string length
** s - zero-terminated string
Expand Down Expand Up @@ -295,21 +295,26 @@ static int b_unpack (lua_State *L) {
const char *fmt = luaL_checkstring(L, 1);
size_t ld;
const char *data = luaL_checklstring(L, 2, &ld);
size_t pos = luaL_optinteger(L, 3, 1) - 1;
size_t pos = luaL_optinteger(L, 3, 1);
luaL_argcheck(L, pos > 0, 3, "offset must be 1 or greater");
pos--; /* Lua indexes are 1-based, but here we want 0-based for C
* pointer math. */
int n = 0; /* number of results */
defaultoptions(&h);
lua_settop(L, 2);
while (*fmt) {
int opt = *fmt++;
size_t size = optsize(L, opt, &fmt);
pos += gettoalign(pos, &h, opt, size);
luaL_argcheck(L, pos+size <= ld, 2, "data string too short");
luaL_checkstack(L, 1, "too many results");
luaL_argcheck(L, size <= ld && pos <= ld - size,
2, "data string too short");
/* stack space for item + next position */
luaL_checkstack(L, 2, "too many results");
switch (opt) {
case 'b': case 'B': case 'h': case 'H':
case 'l': case 'L': case 'T': case 'i': case 'I': { /* integer types */
int issigned = islower(opt);
lua_Number res = getinteger(data+pos, h.endian, issigned, (int)size);
lua_pushnumber(L, res);
lua_pushnumber(L, res); n++;
break;
}
case 'x': {
Expand All @@ -319,41 +324,42 @@ static int b_unpack (lua_State *L) {
float f;
memcpy(&f, data+pos, size);
correctbytes((char *)&f, sizeof(f), h.endian);
lua_pushnumber(L, f);
lua_pushnumber(L, f); n++;
break;
}
case 'd': {
double d;
memcpy(&d, data+pos, size);
correctbytes((char *)&d, sizeof(d), h.endian);
lua_pushnumber(L, d);
lua_pushnumber(L, d); n++;
break;
}
case 'c': {
if (size == 0) {
if (!lua_isnumber(L, -1))
luaL_error(L, "format `c0' needs a previous size");
if (n == 0 || !lua_isnumber(L, -1))
luaL_error(L, "format 'c0' needs a previous size");
size = lua_tonumber(L, -1);
lua_pop(L, 1);
luaL_argcheck(L, pos+size <= ld, 2, "data string too short");
lua_pop(L, 1); n--;
luaL_argcheck(L, size <= ld && pos <= ld - size,
2, "data string too short");
}
lua_pushlstring(L, data+pos, size);
lua_pushlstring(L, data+pos, size); n++;
break;
}
case 's': {
const char *e = (const char *)memchr(data+pos, '\0', ld - pos);
if (e == NULL)
luaL_error(L, "unfinished string in data");
size = (e - (data+pos)) + 1;
lua_pushlstring(L, data+pos, size - 1);
lua_pushlstring(L, data+pos, size - 1); n++;
break;
}
default: controloptions(L, opt, &fmt, &h);
}
pos += size;
}
lua_pushinteger(L, pos + 1);
return lua_gettop(L) - 2;
lua_pushinteger(L, pos + 1); /* next position */
return n + 1;
}


Expand Down Expand Up @@ -399,7 +405,7 @@ LUALIB_API int luaopen_struct (lua_State *L) {


/******************************************************************************
* Copyright (C) 2010-2012 Lua.org, PUC-Rio. All rights reserved.
* Copyright (C) 2010-2018 Lua.org, PUC-Rio. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
Expand Down
2 changes: 1 addition & 1 deletion deps/lua/src/luaconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ union luai_Cast { double l_d; long l_l; };
@* in 'string.format'.
@@ LUA_INTFRM_T is the integer type correspoding to the previous length
@* modifier.
** CHANGE them if your system supports PORT_LONGLONG or does not support long.
** CHANGE them if your system supports long long or does not support long.
*/

#if defined(LUA_USELONGLONG)
Expand Down
Loading

0 comments on commit 560152f

Please sign in to comment.