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 a segmentation fault issue in logging worker #2295

Merged
merged 3 commits into from
Jun 25, 2020

Conversation

fujimotos
Copy link
Member

The current logic assumes that read(2) never does a partial read
on a certain condition. This is really not guaranteed by POSIX,
and indeed not the case on Windows.

Use flb_pipe_write_all() and flb_pipe_write_all() to avoid partial
I/O in a portable manner.

Note: This patch is a joint efffort with @gitfool. It is verified to fix
random memory crash issue #2251 on WIndows.

Sean Fausett reported an out-of-bounds read in log_push() on Windows.
Evidently `log_message` struct can be corrupted in some cases, and
it confuses the subsequent write() to overrun the buffer.

This fixes up the crash issue with a safety check: ensure that
msg->size does not exceeds the message buffer size.

Signed-off-by: Fujimoto Seiji <[email protected]>
The current logic assumes that read(2) never does a partial read
on a certain condition. This is really not guaranteed by POSIX,
and indeed not the case on Windows.

Use flb_pipe_write_all() and flb_pipe_write_all() to avoid partial
I/O in a portable manner.

Signed-off-by: Fujimoto Seiji <[email protected]>
This adds missing return paths to these functions, so that they
can exit immdeidately if any IO operation fails with -1.

Without this, these function can enter into a bogus infnite loop,
repeatedly adding -1 to the total byte count.

Signed-off-by: Fujimoto Seiji <[email protected]>
@fujimotos fujimotos changed the title log: use flb_pipe_read_all() and flb_pipe_write_all() for messages fix a segmentation fault issue in logging worker Jun 25, 2020
@edsiper edsiper merged commit 960a091 into fluent:master Jun 25, 2020
@edsiper
Copy link
Member

edsiper commented Jun 25, 2020

thanks

@fujimotos fujimotos deleted the sf/win32-logcrash branch June 26, 2020 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants