-
Notifications
You must be signed in to change notification settings - Fork 240
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
Build ebpfcore as a DLL for testing #2744
Conversation
a5b09d9
to
d6601c2
Compare
e6028cc
to
0cd0d78
Compare
Blocked on iovisor/ubpf#335 |
Codecov Report
@@ Coverage Diff @@
## main #2744 +/- ##
==========================================
- Coverage 87.23% 86.02% -1.21%
==========================================
Files 129 137 +8
Lines 25314 25845 +531
==========================================
+ Hits 22082 22234 +152
- Misses 3232 3611 +379
|
@@ -15,7 +15,7 @@ bpf_link__pin(struct bpf_link* link, const char* path) | |||
return libbpf_err(-EBUSY); | |||
} | |||
|
|||
link->pin_path = strdup(path); | |||
link->pin_path = ebpf_strdup(path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strdup()
internally calls malloc()
. Before the usersim changes, the user mode implementation of ebpf_free()
called free()
, which was correct, as it matched with the corresponding malloc()
in strdup().
Now it looks like there is only one implementation of ebpf_free()
, both for user mode and kernel mode, and it calls ExFreePool()
. So, for user mode code also, we are invoking user sim implementation of ExFreePool()
. So 2 levels of indirection.
Is this expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until #2677 is done, yes this is expected.
ebpfsvc/rpc_api.cpp
Outdated
if (ebpf_logs) { | ||
// The ebpf_logs buffer was allocated by the ebpf allocator whereas we | ||
// must return a string allocated by the MIDL allocator. | ||
*logs = (char*)MIDL_user_allocate(ebpf_logs_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there are 2 versions of MIDL_user_allocate()
currently in the repo. The client version is calling ebpf_allocate()
, whereas the server version is calling malloc()
.
If we change the implementation of the server version to also call ebpf_allocate()
, then do we still need this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -390,7 +399,12 @@ bpf_object__pin_programs(struct bpf_object* obj, const char* path) | |||
char buf[PATH_MAX]; | |||
int len; | |||
|
|||
len = snprintf(buf, PATH_MAX, "%s/%s", path, __bpf_program__pin_name(prog)); | |||
char* pin_name = __bpf_program__pin_name(prog); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated to changes in this PR: we are allocating memory in failure path. Instead should we instead save the pin paths generated when pinning the programs, and use the same in the failure case?
Signed-off-by: Dave Thaler <[email protected]>
Signed-off-by: Dave Thaler <[email protected]>
Signed-off-by: Dave Thaler <[email protected]>
Signed-off-by: Dave Thaler <[email protected]>
Signed-off-by: Dave Thaler <[email protected]>
Signed-off-by: Dave Thaler <[email protected]>
Found my latest usersim code Signed-off-by: Dave Thaler <[email protected]>
Signed-off-by: Dave Thaler <[email protected]>
Signed-off-by: Dave Thaler <[email protected]>
The verifier_fuzzer used ebpf_allocate() but then called free() Signed-off-by: Dave Thaler <[email protected]>
Signed-off-by: Dave Thaler <[email protected]>
Signed-off-by: Dave Thaler <[email protected]>
Signed-off-by: Dave Thaler <[email protected]>
Description
ebpf_free()
was being used to free memory allocated bystrdup()
rather than an ebpf allocatorstrdup()
was used to allocate memory that was never freedebpf_free()
was being used to free memory allocated bynew
.ebpf_free()
to free memory allocated by ubpf_user.c usingcalloc()
. ubpf_kernel.c already redefined it to use ebpf_alloc but ubpf_user.c didn't match.ebpf_allocate()
but verifier_fuzzer then calledfree()
Testing
Tests will be expanded in the future once IOCTL support is added to usersim.
Documentation
No impact.
Installation
Installer files are updated in this PR.