Fix: annotate bytecode interpreter for kernel stack validator
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 15 Jun 2016 18:39:41 +0000 (14:39 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 15 Jun 2016 18:43:34 +0000 (14:43 -0400)
With gcc 6.1.1, kernel 4.6, with
CONFIG_STACK_VALIDATION=y, building lttng-modules master
at commit 6c09dd94 gives this warning:

lttng-modules/lttng-filter-interpreter.o: warning: objtool:
lttng_filter_interpret_bytecode()+0x58: sibling call from
callable instruction with changed frame pointer

This object implements a bytecode interpreter using an explicit
jump table.

If we define "INTERPRETER_USE_SWITCH" at the top of the file,
thus using the switch-case fallback implementation, the
warning vanishes.

We use an explicit jump table rather than a switch case whenever
possible for performance reasons.

Unfortunately objtool doesn't know how to validate this type of jump
table. So to avoid the warning we need to add an annotation to tell
objtool to ignore it.

Kernel developers has to annotate __bpf_prog_run() in the kernel for the
same reason.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lttng-filter-interpreter.c
wrapper/frame.h [new file with mode: 0644]

index c7e9f1f1f1777577cc16baf7bda9f9d5ab5f92fa..d9605cb2a068f4e3a187f27e56882e6d5256ada4 100644 (file)
  */
 
 #include <linux/uaccess.h>
+#include <wrapper/frame.h>
 
 #include <lttng-filter.h>
 
+LTTNG_STACK_FRAME_NON_STANDARD(lttng_filter_interpret_bytecode);
+
 /*
  * get_char should be called with page fault handler disabled if it is expected
  * to handle user-space read.
diff --git a/wrapper/frame.h b/wrapper/frame.h
new file mode 100644 (file)
index 0000000..ac8f496
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef _LTTNG_WRAPPER_FRAME_H
+#define _LTTNG_WRAPPER_FRAME_H
+
+/*
+ * wrapper/frame.h
+ *
+ * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/version.h>
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
+
+#include <linux/frame.h>
+
+#define LTTNG_STACK_FRAME_NON_STANDARD(func) \
+       STACK_FRAME_NON_STANDARD(func)
+
+#else
+
+#define LTTNG_STACK_FRAME_NON_STANDARD(func)
+
+#endif
+
+#endif /* _LTTNG_WRAPPER_FRAME_H */
This page took 0.026917 seconds and 4 git commands to generate.