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

Proc_image:修改syscall_image #788

Merged
merged 7 commits into from
May 13, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ char LICENSE[] SEC("license") = "Dual BSD/GPL";

const volatile pid_t ignore_tgid = -1;
const int key = 0;
pid_t pre_target_pid = -1;//上一个监测的进程;
int pre_target_tgid = -1;//上一个监测的进程组;

struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
Expand Down Expand Up @@ -80,14 +82,14 @@ int sys_enter(struct trace_event_raw_sys_enter *args)
if((sc_ctrl->target_tgid==-1 && (sc_ctrl->target_pid==-1 || pid==sc_ctrl->target_pid)) || (sc_ctrl->target_tgid!=-1 && tgid == sc_ctrl->target_tgid)){
syscall_seq->record_syscall[syscall_seq->count] = (int)args->id;
}
syscall_seq->count ++;
syscall_seq->count++;
}else if (syscall_seq->count <= MAX_SYSCALL_COUNT-1 && syscall_seq->count > 0 &&
syscall_seq->record_syscall+syscall_seq->count <= syscall_seq->record_syscall+(MAX_SYSCALL_COUNT-1)){
if((sc_ctrl->target_tgid==-1 && (sc_ctrl->target_pid==-1 || pid==sc_ctrl->target_pid)) ||
(sc_ctrl->target_tgid!=-1 && tgid == sc_ctrl->target_tgid)){
syscall_seq->record_syscall[syscall_seq->count] = (int)args->id;
}
syscall_seq->count ++;
syscall_seq->count++;
}
}
}
Expand Down Expand Up @@ -132,6 +134,20 @@ int sys_exit(struct trace_event_raw_sys_exit *args)
syscall_seq->max_delay = this_delay;
if(syscall_seq->min_delay==0 || this_delay<syscall_seq->min_delay)
syscall_seq->min_delay = this_delay;
//策略切换,首次数据不记录;
if(sc_ctrl->target_tgid ==-1 && sc_ctrl->target_pid ==pid && sc_ctrl->target_pid != pre_target_pid){
syscall_seq->sum_delay = 0;
syscall_seq->count = 0;
pre_target_pid = sc_ctrl->target_pid;//更改pre_target_pid;
return 0;
}
if(sc_ctrl->target_tgid !=-1 && sc_ctrl->target_tgid ==tgid && sc_ctrl->target_tgid != pre_target_tgid){
syscall_seq->sum_delay = 0;
syscall_seq->count = 0;
pre_target_tgid = sc_ctrl->target_tgid;//更改pre_target_pid;
return 0;
}

if((sc_ctrl->target_tgid==-1 && (sc_ctrl->target_pid==-1 || pid==sc_ctrl->target_pid)) ||
(sc_ctrl->target_tgid!=-1 && tgid == sc_ctrl->target_tgid)){
syscall_seq->proc_count += syscall_seq->count;
Expand Down
Loading