Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ZRANGESTORE arity -4 crash the server #1593

Merged
merged 1 commit into from
Jul 14, 2023

Conversation

enjoy-binbin
Copy link
Member

ZRANGESTORE arity should be -5, the code wrongtly sets it to -4,
when passing 4 arguments, server will trigger a Segmentation fault
and result a crash:

127.0.0.1:6666> zrangestore dstzset srczset 0
Error: Server closed the connection
not connected>

server logs:

E20230714 12:12:07.295455 20224 main.cc:84] ======= Ooops! kvrocks unstable (commit https://github.com/apache/kvrocks/commit/46862ea559976d50ba6996942f2c962774dfc5e9) got signal: Segmentation fault (11) =======
E20230714 12:12:07.303087 20224 main.cc:101] /lib64/libpthread.so.0(+0xf5d0) [0x7f2359e1c5d0]
E20230714 12:12:07.306125 20224 main.cc:99] ./build/kvrocks() [0x56d0c5]                      redis::CommandZRangeStore::Parse()
E20230714 12:12:07.306392 20224 main.cc:99] ./build/kvrocks() [0x501a27]                      redis::Commander::Parse()
E20230714 12:12:07.306795 20224 main.cc:99] ./build/kvrocks() [0x591c27]                      redis::Connection::ExecuteCommands()
E20230714 12:12:07.307207 20224 main.cc:99] ./build/kvrocks() [0x593720]                      redis::Connection::OnRead()
E20230714 12:12:07.307349 20224 main.cc:99] ./build/kvrocks() [0xb9220e]                      bufferevent_run_deferred_callbacks_unlocked
E20230714 12:12:07.307488 20224 main.cc:99] ./build/kvrocks() [0xb994cc]                      event_process_active_single_queue.isra.0
E20230714 12:12:07.308138 20224 main.cc:99] ./build/kvrocks() [0xb99bbf]                      event_base_loop
E20230714 12:12:07.308470 20224 main.cc:99] ./build/kvrocks() [0x5bc769]                      Worker::Run()
E20230714 12:12:07.308689 20224 main.cc:99] ./build/kvrocks() [0xd95da0]                      execute_native_thread_routine
E20230714 12:12:07.308856 20224 main.cc:99] /lib64/libpthread.so.0(+0x7dd5) [0x7f2359e14dd5]  start_thread
E20230714 12:12:07.314087 20224 main.cc:99] /lib64/libc.so.6(clone+0x6d) [0x7f235983bead]     __clone
Segmentation fault

ZRANGESTORE arity should be -5, the code wrongtly sets it to -4,
when passing 4 arguments, server will trigger a Segmentation fault
and result a crash:
```
127.0.0.1:6666> zrangestore dstzset srczset 0
Error: Server closed the connection
not connected>
```

server logs:
```
E20230714 12:12:07.295455 20224 main.cc:84] ======= Ooops! kvrocks unstable (commit 46862ea) got signal: Segmentation fault (11) =======
E20230714 12:12:07.303087 20224 main.cc:101] /lib64/libpthread.so.0(+0xf5d0) [0x7f2359e1c5d0]
E20230714 12:12:07.306125 20224 main.cc:99] ./build/kvrocks() [0x56d0c5]                      redis::CommandZRangeStore::Parse()
E20230714 12:12:07.306392 20224 main.cc:99] ./build/kvrocks() [0x501a27]                      redis::Commander::Parse()
E20230714 12:12:07.306795 20224 main.cc:99] ./build/kvrocks() [0x591c27]                      redis::Connection::ExecuteCommands()
E20230714 12:12:07.307207 20224 main.cc:99] ./build/kvrocks() [0x593720]                      redis::Connection::OnRead()
E20230714 12:12:07.307349 20224 main.cc:99] ./build/kvrocks() [0xb9220e]                      bufferevent_run_deferred_callbacks_unlocked
E20230714 12:12:07.307488 20224 main.cc:99] ./build/kvrocks() [0xb994cc]                      event_process_active_single_queue.isra.0
E20230714 12:12:07.308138 20224 main.cc:99] ./build/kvrocks() [0xb99bbf]                      event_base_loop
E20230714 12:12:07.308470 20224 main.cc:99] ./build/kvrocks() [0x5bc769]                      Worker::Run()
E20230714 12:12:07.308689 20224 main.cc:99] ./build/kvrocks() [0xd95da0]                      execute_native_thread_routine
E20230714 12:12:07.308856 20224 main.cc:99] /lib64/libpthread.so.0(+0x7dd5) [0x7f2359e14dd5]  start_thread
E20230714 12:12:07.314087 20224 main.cc:99] /lib64/libc.so.6(clone+0x6d) [0x7f235983bead]     __clone
Segmentation fault
```
@enjoy-binbin
Copy link
Member Author

ping @git-hulk @PragmaTwice

@PragmaTwice PragmaTwice added A-security area security fix labels Jul 14, 2023
@PragmaTwice
Copy link
Member

Thanks for your catch!

@PragmaTwice PragmaTwice merged commit 31bcd8a into apache:unstable Jul 14, 2023
24 checks passed
@enjoy-binbin enjoy-binbin deleted the fix_zrangestore_crash branch July 14, 2023 08:31
git-hulk pushed a commit to git-hulk/kvrocks that referenced this pull request Jul 30, 2023
ZRANGESTORE arity should be -5, the code wrongtly sets it to -4,
when passing 4 arguments, server will trigger a Segmentation fault
and result a crash:
```
127.0.0.1:6666> zrangestore dstzset srczset 0
Error: Server closed the connection
not connected>
```
@git-hulk git-hulk mentioned this pull request Jul 31, 2023
git-hulk pushed a commit that referenced this pull request Aug 1, 2023
ZRANGESTORE arity should be -5, the code wrongtly sets it to -4,
when passing 4 arguments, server will trigger a Segmentation fault
and result a crash:
```
127.0.0.1:6666> zrangestore dstzset srczset 0
Error: Server closed the connection
not connected>
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-security area security
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants