File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -3168,6 +3168,22 @@ u64 __weak arch_bpf_timed_may_goto(void)
3168
3168
return 0 ;
3169
3169
}
3170
3170
3171
+ static noinline void bpf_prog_report_may_goto_violation (void )
3172
+ {
3173
+ #ifdef CONFIG_BPF_SYSCALL
3174
+ struct bpf_stream_stage ss ;
3175
+ struct bpf_prog * prog ;
3176
+
3177
+ prog = bpf_prog_find_from_stack ();
3178
+ if (!prog )
3179
+ return ;
3180
+ bpf_stream_stage (ss , prog , BPF_STDERR , ({
3181
+ bpf_stream_printk (ss , "ERROR : Timeout detected for may_goto instruction \n ");
3182
+ bpf_stream_dump_stack (ss );
3183
+ }));
3184
+ #endif
3185
+ }
3186
+
3171
3187
u64 bpf_check_timed_may_goto (struct bpf_timed_may_goto * p )
3172
3188
{
3173
3189
u64 time = ktime_get_mono_fast_ns ();
@@ -3178,8 +3194,10 @@ u64 bpf_check_timed_may_goto(struct bpf_timed_may_goto *p)
3178
3194
return BPF_MAX_TIMED_LOOPS ;
3179
3195
}
3180
3196
/* Check if we've exhausted our time slice, and zero count. */
3181
- if (time - p -> timestamp >= (NSEC_PER_SEC / 4 ))
3197
+ if (unlikely (time - p -> timestamp >= (NSEC_PER_SEC / 4 ))) {
3198
+ bpf_prog_report_may_goto_violation ();
3182
3199
return 0 ;
3200
+ }
3183
3201
/* Refresh the count for the stack frame. */
3184
3202
return BPF_MAX_TIMED_LOOPS ;
3185
3203
}
You can’t perform that action at this time.
0 commit comments