-
Notifications
You must be signed in to change notification settings - Fork 50
Initial implementation for user space uprobe for Open SSL #819
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
Open
msherif1234
wants to merge
7
commits into
main
Choose a base branch
from
dev_ssl
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c85f977
fix(deps): update module github.com/netobserv/flowlogs-pipeline to v1…
red-hat-konflux[bot] d279a16
fix(deps): update module github.com/vmware/go-ipfix to v0.13.0 (#592)
red-hat-konflux[bot] 76c869d
Initial PR to implement openSSL userspace tracker
msherif1234 9eb6cb0
Add promo metrics for openSSL tracker
msherif1234 41dbbe6
improved tests for openshift
jpinsonneau 3e47174
revert docker file changes
msherif1234 dc723f4
remove additonal 32 bytes of name in pkt info and use percpu map as
msherif1234 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /* | ||
| * OpenSSL monitoring uprobe/uretprobe eBPF hook. | ||
| */ | ||
|
|
||
| #ifndef __OPENSSL_TRACKER_H__ | ||
| #define __OPENSSL_TRACKER_H__ | ||
|
|
||
| #include "utils.h" | ||
|
|
||
| static inline void generate_SSL_data_event(struct pt_regs *ctx, u64 pid_tgid, u8 ssl_type, | ||
| const char *buf, uint32_t len) { | ||
| if (len <= 0) { | ||
| return; | ||
| } | ||
|
|
||
| struct ssl_data_event_t *event; | ||
| event = bpf_ringbuf_reserve(&ssl_data_event_map, sizeof(*event), 0); | ||
| if (!event) { | ||
| return; | ||
| } | ||
| event->timestamp_ns = bpf_ktime_get_ns(); | ||
| event->pid_tgid = pid_tgid; | ||
| event->ssl_type = ssl_type; | ||
| event->data_len = len < MAX_DATA_SIZE_OPENSSL ? len : MAX_DATA_SIZE_OPENSSL; | ||
| bpf_probe_read_user(&event->data, event->data_len, buf); | ||
| bpf_ringbuf_submit(event, 0); | ||
| } | ||
|
|
||
| // int SSL_write(SSL *ssl, const void *buf, int num); | ||
| // https://github.com/openssl/openssl/blob/master/ssl/ssl_lib.c#L2666 | ||
| SEC("uprobe/SSL_write") | ||
| int probe_entry_SSL_write(struct pt_regs *ctx) { | ||
| if (enable_openssl_tracking == 0) { | ||
| return 0; | ||
| } | ||
|
|
||
| u64 pid_tgid = bpf_get_current_pid_tgid(); | ||
|
|
||
| BPF_PRINTK("openssl uprobe/SSL_write pid: %d\n", pid_tgid); | ||
| // https://github.com/openssl/openssl/blob/master/ssl/ssl_local.h#L1233 | ||
| void *ssl = (void *)PT_REGS_PARM1(ctx); | ||
|
|
||
| u32 ssl_type; | ||
| int ret; | ||
|
|
||
| ret = bpf_probe_read_user(&ssl_type, sizeof(ssl_type), (u32 *)ssl); | ||
| if (ret) { | ||
| BPF_PRINTK("(OPENSSL) bpf_probe_read ssl_type_ptr failed, ret: %d\n", ret); | ||
| return 0; | ||
| } | ||
| const char *buf = (const char *)PT_REGS_PARM2(ctx); | ||
| uint32_t num = (uint32_t)PT_REGS_PARM3(ctx); // Third parameter: number of bytes to write | ||
|
|
||
| BPF_PRINTK("openssl uprobe/SSL_write type: %d, buf: %p, num: %d\n", ssl_type, buf, num); | ||
|
|
||
| // Read the data immediately in the uprobe (before SSL_write processes it) | ||
| // This captures the plaintext before encryption | ||
| if (num > 0) { | ||
| generate_SSL_data_event(ctx, pid_tgid, ssl_type, buf, num); | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| #endif /* __OPENSSL_TRACKER_H__ */ |
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
this must not be removed, it's used in the line below:
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.
hmm that I don't remember why will revert as well and if needed I will keep it locally
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.
maybe when running from mac you need to pass explicitly
MULTIARCH_TARGETS=arm64There 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.
perhaps that's also what make you have different bytecode than the CI (and hence get it rejected)
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.
I don't think that option is there for
make docker-generate