feat(lib): use memfd on linux instead of dumping libddwaf.so in /tmp#106
Merged
Conversation
Signed-off-by: Eliott Bouhana <[email protected]>
eliottness
force-pushed
the
eliott.bouhana/memfd
branch
from
September 2, 2024 16:01
c840ba3 to
5048c4c
Compare
Julio-Guerra
requested changes
Sep 2, 2024
keisku
reviewed
Sep 3, 2024
Signed-off-by: Eliott Bouhana <[email protected]>
eliottness
enabled auto-merge (squash)
September 3, 2024 09:03
keisku
reviewed
Sep 4, 2024
keisku
left a comment
Contributor
There was a problem hiding this comment.
I don't have background context of errors that have been ignored.
Logging or returning an error should help support team in the future!
| file, err := lib.DumpEmbeddedWAF() | ||
| path, closer, err := lib.DumpEmbeddedWAF() | ||
| if err != nil { | ||
| return |
Contributor
There was a problem hiding this comment.
Should we not ignore this err?
Suggested change
| return | |
| return nil, fmt.Errorf("write an embedded WAF library: %w", err) |
Contributor
Author
There was a problem hiding this comment.
Ah sh*t. Should have disabled auto-merge when I saw your comments. Don't worry I will do it in another PR
| var handle uintptr | ||
| if handle, err = purego.Dlopen(file, purego.RTLD_GLOBAL|purego.RTLD_NOW); err != nil { | ||
| if handle, err = purego.Dlopen(path, purego.RTLD_GLOBAL|purego.RTLD_NOW); err != nil { | ||
| return |
Contributor
There was a problem hiding this comment.
Suggested change
| return | |
| return nil, fmt.Errorf("dlopen: %w", err) |
Julio-Guerra
approved these changes
Sep 4, 2024
eliottness
pushed a commit
that referenced
this pull request
Sep 4, 2024
Context: #106 (comment) I am doing this on behave of @eliottness.
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.
What
This PR refactors the code in
internal/libto accommodate two implementations of theDumpEmbeddedWAF()function. One for linux usingmemfd, ultimately callingdlopen("/proc/self/fd/{fd}"), and one for darwin still creating a temporary file and callingdlopen("/tmp/libddwaf-*.so").Side quest: some function comments were not starting by the name of the function, fixed it.
Motivation
Being able to use dd-trace-go on full read-only filesystems. On linux only for now but still