Skip to content
Snippets Groups Projects
Commit ea4c2567 authored by Ilya Verbin's avatar Ilya Verbin Committed by Aleksandr Lyapunov
Browse files

box: do not close xlog file descriptors in the atfork handler

Use O_CLOEXEC flag instead.

If Tarantool is forked before executing box.cfg{}, e.g. using io.popen(),
the child process could start with stdin linked to /dev/urandom.
This happens because wal_writer_singleton and vy_log_writer are not yet
initialized, i.e. `fd' fields are 0, then atfork child handler wal_atfork()
is called. It checks that xlog is opened (the check succeeded as 0 != -1)
and closes its fd 0, in fact closing stdin (twice). Next, Tarantool opens
the file /dev/urandom during initialization, and it receives the lowest
unused file descriptor, which is 0. Then luaL_loadfile() loads stdin as a
Lua chunk, in effect reading random numbers.

This happens on glibc 2.28 and older, as newer versions do not invoke
atfork handlers during io.popen():
https://sourceware.org/bugzilla/show_bug.cgi?id=17490

Closes #7886

NO_DOC=bugfix
NO_TEST=Tested by test/app-luatest/gh_5747_crash_multiple_args_test.lua

(cherry picked from commit ec1af129)
parent 3f229cff
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment