5047 Commits

Author SHA1 Message Date
antirez
48e24d54b7 Ziplist: insertion bug under particular conditions fixed.
Ziplists had a bug that was discovered while investigating a different
issue, resulting in a corrupted ziplist representation, and a likely
segmentation foult and/or data corruption of the last element of the
ziplist, once the ziplist is accessed again.

The bug happens when a specific set of insertions / deletions is
performed so that an entry is encoded to have a "prevlen" field (the
length of the previous entry) of 5 bytes but with a count that could be
encoded in a "prevlen" field of a since byte. This could happen when the
"cascading update" process called by ziplistInsert()/ziplistDelete() in
certain contitious forces the prevlen to be bigger than necessary in
order to avoid too much data moving around.

Once such an entry is generated, inserting a very small entry
immediately before it will result in a resizing of the ziplist for a
count smaller than the current ziplist length (which is a violation,
inserting code expects the ziplist to get bigger actually). So an FF
byte is inserted in a misplaced position. Moreover a realloc() is
performed with a count smaller than the ziplist current length so the
final bytes could be trashed as well.

SECURITY IMPLICATIONS:

Currently it looks like an attacker can only crash a Redis server by
providing specifically choosen commands. However a FF byte is written
and there are other memory operations that depend on a wrong count, so
even if it is not immediately apparent how to mount an attack in order
to execute code remotely, it is not impossible at all that this could be
done. Attacks always get better... and we did not spent enough time in
order to think how to exploit this issue, but security researchers
or malicious attackers could.
2017-02-01 15:03:18 +01:00
antirez
4a64bc3e40 Cluster: handle zero bytes at the end of nodes.conf. 2016-12-06 09:06:20 +01:00
Salvatore Sanfilippo
61c5f4eccb Merge pull request #3300 from andyli029/patch-3
fix comment "b > a" to "a > b"
2016-06-10 09:14:30 +02:00
andyli
124d94cc6b fix comment "b>a" to "a > b" 2016-06-07 14:42:50 +08:00
Adam Baldwin
59e1357bff Removed dofile() from Lua 2016-05-08 18:05:07 +02:00
Jan-Erik Rediger
6d567d0c6f Fix nanosecond conversion
1 microsecond = 1000 nanoseconds
1e3 = 1000
10e3 = 10000
2016-05-05 16:21:43 +02:00
Oran Agra
d6864d2999 additional fix to issue #2948 2016-05-05 14:01:08 +02:00
antirez
d8679070b8 New masters with slots are now targets of migration if others are.
This fixes issue #3043.

Before this fix, after a complete resharding of a master slots
to other nodes, the master remains empty and the slaves migrate away
to other masters with non-zero nodes. However the old master now empty,
is no longer considered a target for migration, because the system has
no way to tell it had slaves in the past.

This fix leaves the algorithm used in the past untouched, but adds a
new rule. When a new or old master which is empty and without slaves,
are assigend with their first slot, if other masters in the cluster have
slaves, they are automatically considered to be targets for replicas
migration.
2016-05-05 14:00:23 +02:00
antirez
ca300f2d14 Minor redis-cli wording change in --help output. 2016-05-05 13:58:37 +02:00
antirez
33c8a59e97 redis-cli: don't free historyfile, is used later. 2016-05-05 13:58:11 +02:00
antirez
055958aa3b Cluster: make getNodeByQuery() responsible of -CLUSTERDOWN errors.
This fixes a bug introduced by d827dbf, and makes the code consistent
with the logic of always allowing, while the cluster is down, commands
that don't target any key.

As a side effect the code is also simpler now.
2016-05-05 11:47:01 +02:00
David Cavar
1d8078b7f1 Reverse redirect address parse
Fix issue in case the redirect address is in ipv6 format. Parse from behind to extract last part of the response which represents actual port.
2016-05-05 10:13:26 +02:00
antirez
c3d9da0062 Bind both IPv4 and IPv6 or exit with an error by default.
Thanks to @tushar2708 for the PR. I applied a slightly different fix.
Thanks to @cespare for reporting.

Close #3024
Close #3020
2016-05-05 10:05:14 +02:00
Salvatore Sanfilippo
7146221f38 Merge pull request #3133 from c2nes/check-slots-exec
Ensure slots are rechecked on EXEC.
2016-05-05 09:32:07 +02:00
Ryosuke Hasebe
bb5b8d3180 fix variable 2016-05-05 08:56:58 +02:00
Ryosuke Hasebe
90cd445535 fix check_open_slots 2016-05-05 08:56:58 +02:00
Chris Thunes
e0d0fb450c Ensure slots are rechecked on EXEC.
Fixes #2515.
2016-03-11 15:25:48 -05:00
antirez
401383f1da Remove Lua state reference from buffers in lua_cmsgpack. 2016-02-10 09:16:48 +01:00
yoav@monfort.co.il
1dabbd0a41 cmsgpack: pass correct osize values to lua allocator, update correct buf free space in cmsgpack 2016-02-10 09:16:48 +01:00
antirez
d695f3e899 Fix NOTIFY macro names after cherry pick of fix. 2016-02-05 15:57:42 +01:00
Itamar Haber
593cf5989e Adds keyspace notifications for lrem 2016-02-05 15:56:34 +01:00
antirez
92fd7dac35 Merge branch '3.0' of github.com:/antirez/redis into 3.0 2016-01-31 21:46:30 +01:00
antirez
3c46377ec5 Fix wrong macro name after merge of 3.2 code. (again). 2016-01-31 21:46:07 +01:00
Salvatore Sanfilippo
698cbf15a3 Merge pull request #3048 from itamarhaber/patch-4
Removes more spuriousness from 3.0.7
2016-01-31 08:57:14 +01:00
Itamar Haber
9969d7f787 Removes more spuriousness from 3.0.7 2016-01-30 23:23:19 +02:00
antirez
49b7f0ec45 Fix wrong macro name after merge of 3.2 code. 2016-01-29 22:22:12 +01:00
antirez
301ed84ec8 Typo ASII -> ASCII fixed in comment. 2016-01-29 12:08:37 +01:00
antirez
7d016e6f39 Cluster: include node IDs in SLOTS output.
CLUSTER SLOTS now includes IDs in the nodes description associated with
a given slot range. Certain client libraries implementations need a way
to reference a node in an unique way, so they were relying on CLUSTER
NODES, that is not a stable API and may change frequently depending on
Redis Cluster future requirements.
2016-01-29 12:02:27 +01:00
antirez
438942a540 Remove spurious entries in 3.0.7 changelog.
Certain things were only applicable to 3.2.0 RC2 and RC3.
2016-01-29 09:18:48 +01:00
antirez
6bf60cbf5e UPDATE: Redis 3.0.7.
We had to fix a few last minutes bugs.
2016-01-28 13:02:27 +01:00
antirez
1a7e68556f Use a smoother running average for avg_ttl in INFO.
Reported here:
https://www.reddit.com/r/redis/comments/42r0i0/avg_ttl_varies_a_lot/
2016-01-26 15:29:48 +01:00
antirez
13f48d8dbf Fix merge conflicts from 3.2. 2016-01-26 14:25:49 +01:00
antirez
4d62a82b4a Cluster: mismatch sender ID log put back at DEBUG level. 2016-01-26 14:24:24 +01:00
antirez
4685f253c3 Cluster: fix missing ntohs() call to access gossip section port. 2016-01-26 14:22:46 +01:00
antirez
025f936cc4 Better address udpate strategy when processing gossip sections.
The change covers the case where:

1. There is a node we can't reach (in fail or pfail state).
2. We see a different address for this node, in the gossip section sent
to us by a node that, instead, is able to talk with the node we cannot
talk to.

In this case it's a good bet to switch to the address reported by this
node, since there was an address switch and it is able to talk with the
node and we are not.

However previosuly this was done in a dangerous way, by initiating an
handshake. The handshake, using the MEET packet, forces the receiver to
join our cluster, and this is not a good idea. If the node in question
really just switched address, but is the same node, it already knows about
us, so we just need to perform an address update and a reconnection.

So with this commit instead we just update the address of the node,
release the node link if any, and attempt to reconnect in the next
clusterCron() cycle.

The commit also improves debugging messages printed by Cluster during
address or ID switches.
2016-01-26 14:22:32 +01:00
antirez
5d9a533591 Fix memory leak in masterauth config option loading. 2016-01-26 14:21:49 +01:00
antirez
72f5326076 Fix merge issues with 3.2 backports. 3.0.7 2016-01-25 15:57:52 +01:00
antirez
53c9c299df Redis 3.0.7. 2016-01-25 15:54:36 +01:00
antirez
d4090b169d Minor MIGRATE refactoring.
Centralize cleanup of newargv in a single place.
Add more comments to help a bit following a complex function.

Related to issue #3016.
2016-01-25 15:23:08 +01:00
antirez
29c89df46e More variadic MIGRATE fixes.
Another leak was fixed in the case of syntax error by restructuring the
allocation strategy for the two dynamic vectors.

We also make sure to always close the cached socket on I/O errors so that
all the I/O errors are handled the same, even if we had a previously
queued error of a different kind from the destination server.

Thanks to Kevin McGehee. Related to issue #3016.
2016-01-25 15:23:04 +01:00
antirez
14e1599660 Various fixes to MIGRATE with multiple keys.
In issue #3016 Kevin McGehee identified multiple very serious issues in
the new implementation of MIGRATE. This commit attempts to restructure
the code in oder to avoid mistakes, an analysis of the new
implementation is in progress in order to check for possible edge cases.
2016-01-25 15:22:58 +01:00
antirez
4300a973b8 Test: Handle LOADING in restart_instance. 2016-01-25 15:21:57 +01:00
antirez
5a402ce2d5 Detect and show crashes on Sentinel/Cluster tests. 2016-01-25 15:21:53 +01:00
antirez
515392c216 Cluster: fix setting nodes slaveof pointer to NULL on node release.
With this commit we preserve the list of nodes that have .slaveof set
to the node, even when the node is turned into a slave, and make sure to
fix the .slaveof pointers to NULL when a node is freed from memory,
regardless of the fact it's a slave or a master.

Basically we try to remember the logical master in the current
configuration even if the logical master advertised it as a slave
already. However we still remember the associations, so that when a node
is freed we can fix them.

This should fix issue #3002.
2016-01-25 15:21:49 +01:00
antirez
d5872e8e31 Cluster: clarify node->slave may be NULL. 2016-01-25 15:21:43 +01:00
antirez
8cae6e955b Cluster: fix rebalancing to always empty nodes.
Because of rounding error even with weight=0 sometimes a node was left
with an assigned slot.

Close #3001.
2016-01-25 15:21:40 +01:00
antirez
791a295636 Cluster: redis-trib move_to_slot: don't send SETSLOT to slaves. 2016-01-25 15:21:36 +01:00
antirez
f2879c25d1 Cluster: fix redis-trib reference of variable in warning. 2016-01-25 15:21:31 +01:00
antirez
49b1e78820 CLUSTER BUMPEPOCH initial implementation fixed. 2016-01-25 15:21:27 +01:00
antirez
7942e7090e Cluster: implement redis-trib fix when slot is open without owners.
Still work to do.
2016-01-25 15:21:24 +01:00