Commit Graph

8891 Commits

Author SHA1 Message Date
Madelyn Olson
d12b0cf438 Fix LUA garbage collector (CVE-2024-46981) (#1513)
Reset GC state before closing the lua VM to prevent user data to be
wrongly freed while still might be used on destructor callbacks.

Created and publish by Redis in their OSS branch.

Pulled from Valkey for Redict.

Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Signed-off-by: Drew DeVault <sir@cmpwn.com>
Co-authored-by: YaacovHazan <yaacov.hazan@redis.com>
2025-01-07 18:27:38 +01:00
Drew DeVault
ba5dcb3b16 Fix Read/Write key pattern selector (CVE-2024-51741)
The explanation on the original commit was wrong. Key based access must
have a `~` in order to correctly configure whey key prefixes to apply
the selector to. If this is missing, a server assert will be triggered
later.

Cherry-picked and squashed from relevant Valkey changes.

Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
Signed-off-by: Drew DeVault <sir@cmpwn.com>
Co-authored-by: YaacovHazan <yaacov.hazan@redis.com>
2025-01-07 18:27:01 +01:00
Drew DeVault
a8edd3f6ac Prevent unbounded recursive pattern matching
Fix for CVE-2024-31228

This patch was provided to us by Valkey, who received it from Redis Ltd.

> Authenticated users can trigger a denial-of-service by using specially
> crafted, long string match patterns on supported commands such as
> KEYS, SCAN, PSUBSCRIBE, FUNCTION LIST, COMMAND LIST and ACL
> definitions. Matching of extremely long patterns may result in
> unbounded recursion, leading to stack overflow and process crash.

Fixes https://codeberg.org/redict/redict/issues/56

Signed-off-by: Drew DeVault <sir@cmpwn.com>
2024-09-16 09:08:35 +02:00
Drew DeVault
e035e7b763 ACL: Fix parsing issue leading to denail of service
Fix for CVE-2024-31227

This patch was provided to us by Valkey, who received it from Redis Ltd.

> An authenticated user with sufficient privileges may create a
> malformed ACL selector which, when accessed, triggers a server panic
> and subsequent denial of service.

Fixes: https://codeberg.org/redict/redict/issues/54

Signed-off-by: Drew DeVault <sir@cmpwn.com>
2024-09-16 09:07:54 +02:00
Anna (navi) Figueiredo Gomes
52c3e46637 deps/hiredict: update to restructured version
this allows for redict to use the same include paths for both system and
vendored hiredict, allowing use of system hiredict without patches.

Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-04-19 12:44:44 +02:00
Maytham Alsudany
d2e5e96559 Use $(PKG_CONFIG) to call pkgconf rather than invoking directly in finding jemalloc
Signed-off-by: Maytham Alsudany <maytha8thedev@gail.com>
2024-04-15 07:48:37 +00:00
Maytham Alsudany
ffb9f03106
Add ability to use system hiredict
Co-authored-by: Chris Lamb <lamby@debian.org>
Signed-off-by: Maytham Alsudany <maytha8thedev@gmail.com>
2024-04-14 11:54:08 +03:00
Maytham Alsudany
a7654a251b
Use pkgconf to determine system jemalloc's cflags and libs
Signed-off-by: Maytham Alsudany <maytha8thedev@gmail.com>
2024-04-14 05:48:07 +03:00
Maytham Alsudany
5defea5b98
Add ability to use system jemalloc
This time, this shouldn't cause CI tests to fail.

Co-authored-by: Chris Lamb <lamby@debian.org>
Signed-off-by: Maytham Alsudany <maytha8thedev@gmail.com>
2024-04-10 01:10:49 +03:00
Drew DeVault
c68ef593e5 Revert broken jemalloc changes
As I suspected this breaks the default build configuration.

This reverts commit 8794d03e2b.

Signed-off-by: Drew DeVault <sir@cmpwn.com>
2024-04-03 10:30:50 +02:00
Drew DeVault
654fe4ce00 Update references to redis.io throughout code
Now that most of the docs have been migrated over, we can update the references
in the codebase to point to redict.io.

Signed-off-by: Drew DeVault <sir@cmpwn.com>
2024-04-03 10:26:56 +02:00
Chris Lamb
8794d03e2b Add ability to use system jemalloc
Signed-off-by: Maytham Alsudany <maytha8thedev@gmail.com>
2024-04-02 13:55:02 +00:00
Chris Lamb
5f400152aa Fix FTBFS on kFreeBSD
Signed-off-by: Maytham Alsudany <maytha8thedev@gmail.com>
2024-04-02 13:55:02 +00:00
Norm
1502824239 Report redis_version:7.2.4 in INFO command
Fixes: #37
Signed-off-by: Norm <normandy@biribiri.dev>
2024-04-01 15:59:39 -04:00
Drew DeVault
466411d783 Hard code redis.REDIS_VERSION to 7.2.4
Fixes: https://codeberg.org/redict/redict/issues/37
Signed-off-by: Drew DeVault <sir@cmpwn.com>
2024-04-01 11:57:54 +02:00
Drew DeVault
1fb435754f Makefile: add sample configs
Signed-off-by: Drew DeVault <sir@cmpwn.com>
2024-03-28 10:56:12 +01:00
Drew DeVault
a91d1148cf src/modules: s/redis/redict/g
Final pass on these

Signed-off-by: Drew DeVault <sir@cmpwn.com>
2024-03-26 10:59:57 +01:00
Drew DeVault
04992aead7 Freshen up sds.c from hiredict
For ABI compatibility, etc.

Signed-off-by: Drew DeVault <sir@cmpwn.com>
2024-03-25 17:31:07 +01:00
Anna (navi) Figueiredo Gomes
4a6558258e Makefile: add support to DESTDIR
Closes: #22

Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-03-25 11:24:24 +00:00
Drew DeVault
b27a9862d1 all: another pass on Redis references in src/*
This is *nearly* all of them in src/*.

Signed-off-by: Drew DeVault <sir@cmpwn.com>
2024-03-23 16:04:30 +01:00
Drew DeVault
a589ae5f76 all: replace hiredis with hiredict
Signed-off-by: Drew DeVault <sir@cmpwn.com>
2024-03-23 15:19:52 +01:00
Drew DeVault
2ab9de5307 Update ASCII art logo
Signed-off-by: Drew DeVault <sir@cmpwn.com>
2024-03-23 11:06:32 +01:00
Drew DeVault
c8b1c0badc Add ABI compatibility with Redis Modules
Signed-off-by: Drew DeVault <sir@cmpwn.com>
2024-03-22 18:53:37 +01:00
Drew DeVault
bfa6bb93b9 src/debug.c: fix GitHub reference
Signed-off-by: Drew DeVault <sir@cmpwn.com>
2024-03-22 18:13:49 +01:00
Drew DeVault
357df99abb Rename module-related macros
Signed-off-by: Drew DeVault <sir@cmpwn.com>
2024-03-22 17:29:44 +01:00
Drew DeVault
bf48df17d2 all: s/RedisModule/RedictModule/g
This is a fairly naive change, but it seems to be correct. Will review
more carefully later, as well as adding a shim for source-level Redis
Modules compatibility.

Signed-off-by: Drew DeVault <sir@cmpwn.com>
2024-03-22 17:18:07 +01:00
Drew DeVault
50ee0f5be8 all: let's go LGPL over GPL
Based on feedback from interested parties
2024-03-21 20:11:44 +01:00
Drew DeVault
c3d36a8bcb all: fix up remaining lua references to redis
The test suite still needs to be updated, though.
2024-03-21 20:08:32 +01:00
Drew DeVault
d47ce2f240 Relicense module-related code BSD-3-Clause only 2024-03-21 19:46:47 +01:00
Drew DeVault
508e0b0eec Rename Lua API global to redict
And add "redis" as a compatibility shim
2024-03-21 18:56:38 +01:00
Drew DeVault
b56d35ade6 Rename symbols, part six
This should be everything but the hiredis symbols
2024-03-21 17:28:11 +01:00
Drew DeVault
6908cc3629 Rename symbols, part five 2024-03-21 17:21:51 +01:00
Drew DeVault
32618409c6 Rename symbols, part four 2024-03-21 17:06:18 +01:00
Drew DeVault
6e1f6f5288 Rename symbols, part three 2024-03-21 16:48:18 +01:00
Drew DeVault
2caf78c649 Rename symbols, part two 2024-03-21 16:44:03 +01:00
Drew DeVault
4680b58962 Rename symbols, part one 2024-03-21 16:34:08 +01:00
Drew DeVault
3fe17f47ba all: rename defines 2024-03-21 16:23:53 +01:00
Drew DeVault
04036567cc redict-cli: rename environment variables and paths 2024-03-21 15:48:41 +01:00
Drew DeVault
3837df16ef all: another batch of string rewrites 2024-03-21 15:47:49 +01:00
Drew DeVault
cc5efabf64 src/eval.c: use redict/redis as compatible debug commands 2024-03-21 15:40:10 +01:00
Drew DeVault
d60afd8f1a all: Redis => Redict in all strings, first pass
Also replaces it in some comments.
2024-03-21 15:20:58 +01:00
Drew DeVault
b846a9782c src/*: replace references to redis.conf 2024-03-21 15:01:34 +01:00
Drew DeVault
20bfac9a51 src/commands/*.json: Redis => Redict 2024-03-21 14:55:06 +01:00
Drew DeVault
5a20af0e76 all: use REUSE for license management 2024-03-21 14:30:47 +01:00
Drew DeVault
91e1a0c764 cli_common.c: accept redict:// URIs 2024-03-21 13:55:44 +01:00
Drew DeVault
e8abf37673 Working test suite under the Redict name 2024-03-21 13:55:33 +01:00
Drew DeVault
b818f44621 Rename source files and make targets 2024-03-21 10:49:18 +01:00
Yanqi Lv
e64d91c371
Fix dict use-after-free problem in kvs->rehashing (#13154)
In ASAN CI, we find server may crash because of NULL ptr in `kvstoreIncrementallyRehash`.
the reason is that we use two phase unlink in `dbGenericDelete`. After `kvstoreDictTwoPhaseUnlinkFind`,
the dict may be in rehashing and only have one element in ht[0] of `db->keys`.

When we delete the last element in `db->keys` meanwhile `db->keys` is in rehashing, we may free the
dict in `kvstoreDictTwoPhaseUnlinkFree` without deleting the node in `kvs->rehashing`. Then we may
use this freed ptr in `kvstoreIncrementallyRehash` in the `serverCron` and cause the crash.
This is indeed a use-after-free problem.

The fix is to call rehashingCompleted in dictRelease and dictEmpty, so that every call for
rehashingStarted is always matched with a rehashingCompleted.

Adding a test in the unit test to catch it consistently

---------

Co-authored-by: Oran Agra <oran@redislabs.com>
Co-authored-by: debing.sun <debing.sun@redis.com>
2024-03-20 22:44:28 +02:00
Yanqi Lv
bad33f8738
fix wrong data type conversion in zrangeResultBeginStore (#13148)
In `beginResultEmission`, -1 means the result length is not known in
advance. But after #12185, if we pass -1 to `zrangeResultBeginStore`, it
will convert to SIZE_MAX in `zsetTypeCreate` and try to `dictExpand`.
Although `dictExpand` won't succeed because the size overflows, I think
we'd better to avoid this wrong conversion.

This bug can be triggered when the source of `zrangestore` doesn't exist
or we use `zrangestore` command with `byscore` or `bylex`.
The impact is that dst keys will be converted to use skiplist instead of
listpack.
2024-03-19 08:52:55 +02:00
Binbin
e04d41d78d
Prevent lua error_reply abuse from causing errorstats to become larger (#13141)
Users who abuse lua error_reply will generate a new error object on each
error call, which can make server.errors get bigger and bigger. This
will
cause the server to block when calling INFO (we also return errorstats
by
default).

To prevent the damage it can cause, when a misuse is detected, we will
print a warning log and disable the errorstats to avoid adding more new
errors. It can be re-enabled via CONFIG RESETSTAT.

Because server.errors may be very large (it may be better now since we
have the limit), config resetstat may block for a while. So in
resetErrorTableStats, we will try to lazyfree server.errors.

See the related discussion at the end of #8217.
2024-03-19 08:18:22 +02:00