libct/nsenter: fix logging race in nsexec (regression in rc94)#3120
Merged
mrunalp merged 1 commit intoopencontainers:masterfrom Aug 11, 2021
Merged
libct/nsenter: fix logging race in nsexec (regression in rc94)#3120mrunalp merged 1 commit intoopencontainers:masterfrom
mrunalp merged 1 commit intoopencontainers:masterfrom
Conversation
Contributor
Author
|
I think this is a candidate for backporting to 1.0 -- while the race is rare, the consequences are fatal. |
AkihiroSuda
reviewed
Aug 11, 2021
As reported in issue 3119, there is a race in nsexec logging that can lead to garbled json received by log forwarder, which complains about it with a "failed to decode" error. This happens because dprintf (used since the very beginning of nsexec logging introduced in commit ba3cabf) relies on multiple write(2) calls, and with additional logging added by 64bb59f a race is possible between runc init parent and its children. The fix is to prepare a string and write it using a single call to write(2). [v2: NULLify json on error from asprintf] Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
fb6ba04 to
2bab4a5
Compare
AkihiroSuda
approved these changes
Aug 11, 2021
Closed
mrunalp
approved these changes
Aug 11, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As reported in issue #3119, there is a race in nsexec logging
that can lead to garbled json received by log forwarder, which
complains about it with a "failed to decode" error.
This happens because dprintf (used since the very beginning of nsexec
logging introduced in commit ba3cabf) relies on multiple write(2)
calls, and with additional logging added by 64bb59f (appeared in rc94)
a race is possible between runc init parent and its children.
The fix is to prepare a string and write it using a single call to
write(2).
Fixes: #3119
Practically, though, debug logging is not needed in 99.9% of all cases,
and so PR #3114 (commit b1bc762) eliminates the possibility
of it having this race in the first place. Yet I think this fix makes sense.
1.0 backport: #3130