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 33
44#include <vmlinux.h>
55#include <bpf/bpf_tracing.h>
6+ #include "bpf_misc.h"
67
78char _license [] SEC ("license" ) = "GPL" ;
89
@@ -17,16 +18,14 @@ int BPF_PROG(test_raw_tp_null, struct sk_buff *skb)
1718 if (task -> pid != tid )
1819 return 0 ;
1920
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.
2325 */
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" );
3130 return 0 ;
3231}
You can’t perform that action at this time.
0 commit comments