@@ -817,11 +817,30 @@ static notrace void p_debug_off_flag_dump_ring_buffer(struct p_ed_process *p_sou
817
817
}
818
818
#endif
819
819
820
+ static inline int p_off_depth (long * p_val ) {
821
+
822
+ int p_depth = 0 ;
823
+
824
+ while (* p_val > p_global_cnt_cookie ) {
825
+ * p_val -= p_global_cnt_cookie ;
826
+ p_depth ++ ;
827
+ if (unlikely (* p_val > (p_global_cnt_cookie << 3 )))
828
+ break ;
829
+ }
830
+
831
+ return p_depth ;
832
+ }
833
+
820
834
static inline void p_ed_is_off_off (struct p_ed_process * p_source , long p_val , int * p_ret ) {
821
835
822
836
if (unlikely (p_val != p_global_cnt_cookie )) {
823
- p_print_log (P_LOG_ALERT , "DETECT: Task: unexpected 'off' flag for pid %u, name %s" ,
824
- p_source -> p_ed_task .p_pid , p_source -> p_ed_task .p_comm );
837
+ long p_val_remainder = p_val ;
838
+ int p_depth = p_off_depth (& p_val_remainder );
839
+ if (p_val_remainder != p_global_cnt_cookie )
840
+ p_depth = p_val ? 0 : -1 ;
841
+ /* Depths -1 or 1+ are exact, 0 means non-multiple or out of range */
842
+ p_print_log (P_LOG_ALERT , "DETECT: Task: unexpected 'off' flag depth %d for pid %u, name %s" ,
843
+ p_depth , p_source -> p_ed_task .p_pid , p_source -> p_ed_task .p_comm );
825
844
#ifdef P_LKRG_TASK_OFF_DEBUG
826
845
p_print_log (P_LOG_WATCH , "'off' flag[0x%lx] (normalization via 0x%lx)" ,
827
846
p_val , p_global_cnt_cookie );
@@ -844,11 +863,7 @@ static inline void p_validate_off_flag(struct p_ed_process *p_source, long p_val
844
863
if (likely (p_val == p_global_cnt_cookie ))
845
864
return ;
846
865
847
- while (p_val > p_global_cnt_cookie ) {
848
- p_val -= p_global_cnt_cookie ;
849
- if (unlikely (p_val > (p_global_cnt_cookie << 3 )))
850
- break ;
851
- }
866
+ p_off_depth (& p_val );
852
867
853
868
p_ed_is_off_off (p_source , p_val , p_ret );
854
869
}
0 commit comments