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

[receiver/windowseventlog] Fix panic when rendering excessively long offset #36179

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

djaglowski
Copy link
Member

A user observed a panic in the receiver after updating to v0.112.0, where rendering info is expanded by default:

goroutine 69 [running]:
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/windows.(*Buffer).ReadBytes(0x37?, 0x19?)
    C:/Users/runneradmin/go/pkg/mod/github.com/open-telemetry/opentelemetry-collector-contrib/pkg/[email protected]/operator/input/windows/buffer.go:26 +0x165
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/windows.(*Buffer).ReadWideChars(...)
    C:/Users/runneradmin/go/pkg/mod/github.com/open-telemetry/opentelemetry-collector-contrib/pkg/[email protected]/operator/input/windows/buffer.go:37
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/windows.(*Event).RenderDeep(0xc002aaf998, {{0xc003120000, 0x4000, 0x4000}}, {0x8c1b918?})
    C:/Users/runneradmin/go/pkg/mod/github.com/open-telemetry/opentelemetry-collector-contrib/pkg/[email protected]/operator/input/windows/event.go:117 +0x155
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/windows.(*Input).renderDeepAndSend(0xc001ee3dc0, {0x9977160, 0xc00312c460}, {0x19}, {0x13b480ccd58?})

@pjanotti This is a quick fix to avoid the panic by reading the full buffer, but not trying to read more. There may be a better behavior than this but I am not familiar with how the buffer size is established so am proposing to just read the full content for now.

@djaglowski djaglowski added the Run Windows Enable running windows test on a PR label Nov 4, 2024
@djaglowski djaglowski marked this pull request as ready for review November 4, 2024 22:27
@djaglowski djaglowski requested a review from a team as a code owner November 4, 2024 22:27
@codeboten codeboten merged commit 0e1b1d3 into open-telemetry:main Nov 5, 2024
186 checks passed
@github-actions github-actions bot added this to the next release milestone Nov 5, 2024
@djaglowski djaglowski deleted the fix-panic-wel branch November 5, 2024 16:01
@pjanotti
Copy link
Contributor

pjanotti commented Nov 5, 2024

@djaglowski - sorry, didn't see this one in time. Let me know if you have steps for a repro so I can take a deeper look. The change itself is fine for me.

@pjanotti
Copy link
Contributor

pjanotti commented Nov 5, 2024

IIRC the in memory events themselves are limited to 64KiB but of course the XML representation can be much bigger.

michael-burt pushed a commit to michael-burt/opentelemetry-collector-contrib that referenced this pull request Nov 7, 2024
…offset (open-telemetry#36179)

A user observed a panic in the receiver after updating to v0.112.0,
where rendering info is expanded by default:
```
goroutine 69 [running]:
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/windows.(*Buffer).ReadBytes(0x37?, 0x19?)
    C:/Users/runneradmin/go/pkg/mod/github.com/open-telemetry/opentelemetry-collector-contrib/pkg/[email protected]/operator/input/windows/buffer.go:26 +0x165
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/windows.(*Buffer).ReadWideChars(...)
    C:/Users/runneradmin/go/pkg/mod/github.com/open-telemetry/opentelemetry-collector-contrib/pkg/[email protected]/operator/input/windows/buffer.go:37
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/windows.(*Event).RenderDeep(0xc002aaf998, {{0xc003120000, 0x4000, 0x4000}}, {0x8c1b918?})
    C:/Users/runneradmin/go/pkg/mod/github.com/open-telemetry/opentelemetry-collector-contrib/pkg/[email protected]/operator/input/windows/event.go:117 +0x155
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/windows.(*Input).renderDeepAndSend(0xc001ee3dc0, {0x9977160, 0xc00312c460}, {0x19}, {0x13b480ccd58?})
```

@pjanotti This is a quick fix to avoid the panic by reading the full
buffer, but not trying to read more. There may be a better behavior than
this but I am not familiar with how the buffer size is established so am
proposing to just read the full content for now.
dmitryax pushed a commit that referenced this pull request Nov 8, 2024
…36252)

The root of the crash reported in #36179 was the fact that the `Buffer`
struct being passed by value in recursive calls made it allocate the
needed amount, but, after the return of the recursive call it attempted
to read a buffer that was larger than the allocated buffer on the
recursive call.

The crash was going to be hit whenever an XML was larger than the
default size of the buffer (16KiB).

The code is a bit hard to test because its fully usage actually happens
on the receiver where the buffer and its components are not visible.
I'll look to add a test in a follow-up.

cc @djaglowski 

Skipping changelog since #36179 covers it.

---------

Co-authored-by: Daniel Jaglowski <[email protected]>
pull bot pushed a commit to abaguas/opentelemetry-collector-contrib that referenced this pull request Nov 9, 2024
…pen-telemetry#36252)

The root of the crash reported in open-telemetry#36179 was the fact that the `Buffer`
struct being passed by value in recursive calls made it allocate the
needed amount, but, after the return of the recursive call it attempted
to read a buffer that was larger than the allocated buffer on the
recursive call.

The crash was going to be hit whenever an XML was larger than the
default size of the buffer (16KiB).

The code is a bit hard to test because its fully usage actually happens
on the receiver where the buffer and its components are not visible.
I'll look to add a test in a follow-up.

cc @djaglowski 

Skipping changelog since open-telemetry#36179 covers it.

---------

Co-authored-by: Daniel Jaglowski <[email protected]>
sbylica-splunk pushed a commit to sbylica-splunk/opentelemetry-collector-contrib that referenced this pull request Dec 17, 2024
…offset (open-telemetry#36179)

A user observed a panic in the receiver after updating to v0.112.0,
where rendering info is expanded by default:
```
goroutine 69 [running]:
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/windows.(*Buffer).ReadBytes(0x37?, 0x19?)
    C:/Users/runneradmin/go/pkg/mod/github.com/open-telemetry/opentelemetry-collector-contrib/pkg/[email protected]/operator/input/windows/buffer.go:26 +0x165
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/windows.(*Buffer).ReadWideChars(...)
    C:/Users/runneradmin/go/pkg/mod/github.com/open-telemetry/opentelemetry-collector-contrib/pkg/[email protected]/operator/input/windows/buffer.go:37
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/windows.(*Event).RenderDeep(0xc002aaf998, {{0xc003120000, 0x4000, 0x4000}}, {0x8c1b918?})
    C:/Users/runneradmin/go/pkg/mod/github.com/open-telemetry/opentelemetry-collector-contrib/pkg/[email protected]/operator/input/windows/event.go:117 +0x155
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/windows.(*Input).renderDeepAndSend(0xc001ee3dc0, {0x9977160, 0xc00312c460}, {0x19}, {0x13b480ccd58?})
```

@pjanotti This is a quick fix to avoid the panic by reading the full
buffer, but not trying to read more. There may be a better behavior than
this but I am not familiar with how the buffer size is established so am
proposing to just read the full content for now.
sbylica-splunk pushed a commit to sbylica-splunk/opentelemetry-collector-contrib that referenced this pull request Dec 17, 2024
…pen-telemetry#36252)

The root of the crash reported in open-telemetry#36179 was the fact that the `Buffer`
struct being passed by value in recursive calls made it allocate the
needed amount, but, after the return of the recursive call it attempted
to read a buffer that was larger than the allocated buffer on the
recursive call.

The crash was going to be hit whenever an XML was larger than the
default size of the buffer (16KiB).

The code is a bit hard to test because its fully usage actually happens
on the receiver where the buffer and its components are not visible.
I'll look to add a test in a follow-up.

cc @djaglowski 

Skipping changelog since open-telemetry#36179 covers it.

---------

Co-authored-by: Daniel Jaglowski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg/stanza Run Windows Enable running windows test on a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants