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

kern: fix wrong uid #334

Merged
merged 1 commit into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions kern/bash_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ int uretprobe_bash_readline(struct pt_regs *ctx) {
u64 pid_tgid = bpf_get_current_pid_tgid();
u32 pid = pid_tgid >> 32;
u64 current_uid_gid = bpf_get_current_uid_gid();
u32 uid = current_uid_gid >> 32;
u32 uid = current_uid_gid;

#ifndef KERNEL_LESS_5_2
// if target_ppid is 0 then we target all pids
Expand Down Expand Up @@ -68,7 +68,7 @@ int uretprobe_bash_retval(struct pt_regs *ctx) {
u64 pid_tgid = bpf_get_current_pid_tgid();
u32 pid = pid_tgid >> 32;
u64 current_uid_gid = bpf_get_current_uid_gid();
u32 uid = current_uid_gid >> 32;
u32 uid = current_uid_gid;
int retval = (int)PT_REGS_RC(ctx);

#ifndef KERNEL_LESS_5_2
Expand Down
4 changes: 2 additions & 2 deletions kern/boringssl_masterkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ int probe_ssl_master_key(struct pt_regs *ctx) {
u64 current_pid_tgid = bpf_get_current_pid_tgid();
u32 pid = current_pid_tgid >> 32;
u64 current_uid_gid = bpf_get_current_uid_gid();
u32 uid = current_uid_gid >> 32;
u32 uid = current_uid_gid;

#ifndef KERNEL_LESS_5_2
// if target_ppid is 0 then we target all pids
Expand Down Expand Up @@ -413,4 +413,4 @@ int probe_ssl_master_key(struct pt_regs *ctx) {
bpf_perf_event_output(ctx, &mastersecret_events, BPF_F_CURRENT_CPU,
mastersecret, sizeof(struct mastersecret_bssl_t));
return 0;
}
}
10 changes: 5 additions & 5 deletions kern/gnutls_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ int probe_entry_SSL_write(struct pt_regs* ctx) {
u64 current_pid_tgid = bpf_get_current_pid_tgid();
u32 pid = current_pid_tgid >> 32;
u64 current_uid_gid = bpf_get_current_uid_gid();
u32 uid = current_uid_gid >> 32;
u32 uid = current_uid_gid;
debug_bpf_printk("gnutls uprobe/gnutls_record_send pid :%d\n", pid);

#ifndef KERNEL_LESS_5_2
Expand All @@ -146,7 +146,7 @@ int probe_ret_SSL_write(struct pt_regs* ctx) {
u64 current_pid_tgid = bpf_get_current_pid_tgid();
u32 pid = current_pid_tgid >> 32;
u64 current_uid_gid = bpf_get_current_uid_gid();
u32 uid = current_uid_gid >> 32;
u32 uid = current_uid_gid;
debug_bpf_printk("gnutls uretprobe/gnutls_record_send pid :%d\n", pid);

#ifndef KERNEL_LESS_5_2
Expand Down Expand Up @@ -178,7 +178,7 @@ int probe_entry_SSL_read(struct pt_regs* ctx) {
u64 current_pid_tgid = bpf_get_current_pid_tgid();
u32 pid = current_pid_tgid >> 32;
u64 current_uid_gid = bpf_get_current_uid_gid();
u32 uid = current_uid_gid >> 32;
u32 uid = current_uid_gid;
debug_bpf_printk("gnutls uprobe/gnutls_record_recv pid :%d\n", pid);

#ifndef KERNEL_LESS_5_2
Expand All @@ -202,7 +202,7 @@ int probe_ret_SSL_read(struct pt_regs* ctx) {
u64 current_pid_tgid = bpf_get_current_pid_tgid();
u32 pid = current_pid_tgid >> 32;
u64 current_uid_gid = bpf_get_current_uid_gid();
u32 uid = current_uid_gid >> 32;
u32 uid = current_uid_gid;
debug_bpf_printk("gnutls uretprobe/gnutls_record_recv pid :%d\n", pid);

#ifndef KERNEL_LESS_5_2
Expand All @@ -223,4 +223,4 @@ int probe_ret_SSL_read(struct pt_regs* ctx) {

bpf_map_delete_elem(&active_ssl_read_args_map, &current_pid_tgid);
return 0;
}
}
10 changes: 5 additions & 5 deletions kern/nspr_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ int probe_entry_SSL_write(struct pt_regs* ctx) {
u64 current_pid_tgid = bpf_get_current_pid_tgid();
u32 pid = current_pid_tgid >> 32;
u64 current_uid_gid = bpf_get_current_uid_gid();
u32 uid = current_uid_gid >> 32;
u32 uid = current_uid_gid;
debug_bpf_printk("nspr uprobe/PR_Write pid :%d\n", pid);

#ifndef KERNEL_LESS_5_2
Expand All @@ -143,7 +143,7 @@ int probe_ret_SSL_write(struct pt_regs* ctx) {
u64 current_pid_tgid = bpf_get_current_pid_tgid();
u32 pid = current_pid_tgid >> 32;
u64 current_uid_gid = bpf_get_current_uid_gid();
u32 uid = current_uid_gid >> 32;
u32 uid = current_uid_gid;
debug_bpf_printk("nspr uretprobe/PR_Write pid :%d\n", pid);

#ifndef KERNEL_LESS_5_2
Expand Down Expand Up @@ -176,7 +176,7 @@ int probe_entry_SSL_read(struct pt_regs* ctx) {
u64 current_pid_tgid = bpf_get_current_pid_tgid();
u32 pid = current_pid_tgid >> 32;
u64 current_uid_gid = bpf_get_current_uid_gid();
u32 uid = current_uid_gid >> 32;
u32 uid = current_uid_gid;
debug_bpf_printk("nspr uprobe/PR_Read pid :%d\n", pid);

#ifndef KERNEL_LESS_5_2
Expand All @@ -200,7 +200,7 @@ int probe_ret_SSL_read(struct pt_regs* ctx) {
u64 current_pid_tgid = bpf_get_current_pid_tgid();
u32 pid = current_pid_tgid >> 32;
u64 current_uid_gid = bpf_get_current_uid_gid();
u32 uid = current_uid_gid >> 32;
u32 uid = current_uid_gid;
debug_bpf_printk("nspr uretprobe/PR_Read pid :%d\n", pid);

#ifndef KERNEL_LESS_5_2
Expand All @@ -221,4 +221,4 @@ int probe_ret_SSL_read(struct pt_regs* ctx) {

bpf_map_delete_elem(&active_ssl_read_args_map, &current_pid_tgid);
return 0;
}
}
12 changes: 6 additions & 6 deletions kern/openssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ int probe_entry_SSL_write(struct pt_regs* ctx) {
u64 current_pid_tgid = bpf_get_current_pid_tgid();
u32 pid = current_pid_tgid >> 32;
u64 current_uid_gid = bpf_get_current_uid_gid();
u32 uid = current_uid_gid >> 32;
u32 uid = current_uid_gid;

#ifndef KERNEL_LESS_5_2
// if target_ppid is 0 then we target all pids
Expand Down Expand Up @@ -218,7 +218,7 @@ int probe_ret_SSL_write(struct pt_regs* ctx) {
u64 current_pid_tgid = bpf_get_current_pid_tgid();
u32 pid = current_pid_tgid >> 32;
u64 current_uid_gid = bpf_get_current_uid_gid();
u32 uid = current_uid_gid >> 32;
u32 uid = current_uid_gid;

#ifndef KERNEL_LESS_5_2
// if target_ppid is 0 then we target all pids
Expand Down Expand Up @@ -250,7 +250,7 @@ int probe_entry_SSL_read(struct pt_regs* ctx) {
u64 current_pid_tgid = bpf_get_current_pid_tgid();
u32 pid = current_pid_tgid >> 32;
u64 current_uid_gid = bpf_get_current_uid_gid();
u32 uid = current_uid_gid >> 32;
u32 uid = current_uid_gid;
debug_bpf_printk("openssl uprobe/SSL_read pid :%d\n", pid);

#ifndef KERNEL_LESS_5_2
Expand Down Expand Up @@ -291,7 +291,7 @@ int probe_ret_SSL_read(struct pt_regs* ctx) {
u64 current_pid_tgid = bpf_get_current_pid_tgid();
u32 pid = current_pid_tgid >> 32;
u64 current_uid_gid = bpf_get_current_uid_gid();
u32 uid = current_uid_gid >> 32;
u32 uid = current_uid_gid;
debug_bpf_printk("openssl uretprobe/SSL_read pid :%d\n", pid);

#ifndef KERNEL_LESS_5_2
Expand Down Expand Up @@ -324,7 +324,7 @@ int probe_connect(struct pt_regs* ctx) {
u64 current_pid_tgid = bpf_get_current_pid_tgid();
u32 pid = current_pid_tgid >> 32;
u64 current_uid_gid = bpf_get_current_uid_gid();
u32 uid = current_uid_gid >> 32;
u32 uid = current_uid_gid;

#ifndef KERNEL_LESS_5_2
// if target_ppid is 0 then we target all pids
Expand Down Expand Up @@ -363,4 +363,4 @@ int probe_connect(struct pt_regs* ctx) {
bpf_perf_event_output(ctx, &connect_events, BPF_F_CURRENT_CPU, &conn,
sizeof(struct connect_event_t));
return 0;
}
}
4 changes: 2 additions & 2 deletions kern/openssl_masterkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ int probe_ssl_master_key(struct pt_regs *ctx) {
u64 current_pid_tgid = bpf_get_current_pid_tgid();
u32 pid = current_pid_tgid >> 32;
u64 current_uid_gid = bpf_get_current_uid_gid();
u32 uid = current_uid_gid >> 32;
u32 uid = current_uid_gid;

#ifndef KERNEL_LESS_5_2
// if target_ppid is 0 then we target all pids
Expand Down Expand Up @@ -298,4 +298,4 @@ int probe_ssl_master_key(struct pt_regs *ctx) {
bpf_perf_event_output(ctx, &mastersecret_events, BPF_F_CURRENT_CPU,
mastersecret, sizeof(struct mastersecret_t));
return 0;
}
}
4 changes: 2 additions & 2 deletions kern/openssl_masterkey_3.0.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int probe_ssl_master_key(struct pt_regs *ctx) {
u64 current_pid_tgid = bpf_get_current_pid_tgid();
u32 pid = current_pid_tgid >> 32;
u64 current_uid_gid = bpf_get_current_uid_gid();
u32 uid = current_uid_gid >> 32;
u32 uid = current_uid_gid;

#ifndef KERNEL_LESS_5_2
// if target_ppid is 0 then we target all pids
Expand Down Expand Up @@ -280,4 +280,4 @@ int probe_ssl_master_key(struct pt_regs *ctx) {
bpf_perf_event_output(ctx, &mastersecret_events, BPF_F_CURRENT_CPU,
mastersecret, sizeof(struct mastersecret_t));
return 0;
}
}