File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed
tools/testing/selftests/bpf/progs Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change 3
3
4
4
#include <vmlinux.h>
5
5
#include <bpf/bpf_tracing.h>
6
+ #include "bpf_misc.h"
6
7
7
8
char _license [] SEC ("license" ) = "GPL" ;
8
9
@@ -17,16 +18,14 @@ int BPF_PROG(test_raw_tp_null, struct sk_buff *skb)
17
18
if (task -> pid != tid )
18
19
return 0 ;
19
20
20
- i = i + skb -> mark + 1 ;
21
- /* The compiler may move the NULL check before this deref, which causes
22
- * the load to fail as deref of scalar. Prevent that by using a barrier.
21
+ /* If dead code elimination kicks in, the increment +=2 will be
22
+ * removed. For raw_tp programs attaching to tracepoints in kernel
23
+ * modules, we mark input arguments as PTR_MAYBE_NULL, so branch
24
+ * prediction should never kick in.
23
25
*/
24
- barrier ();
25
- /* If dead code elimination kicks in, the increment below will
26
- * be removed. For raw_tp programs, we mark input arguments as
27
- * PTR_MAYBE_NULL, so branch prediction should never kick in.
28
- */
29
- if (!skb )
30
- i += 2 ;
26
+ asm volatile ("%[i] += 1; if %[ctx] != 0 goto +1; %[i] += 2;"
27
+ : [i ]"+r" (i )
28
+ : [ctx ]"r" (skb )
29
+ : "memory" );
31
30
return 0 ;
32
31
}
You can’t perform that action at this time.
0 commit comments