* [peterz-queue:x86/core 2/6] arch/x86/kernel/kprobes/core.c:326:7: error: call to undeclared function 'is_cfi_trap'; ISO C99 and later do not support implicit function declarations
@ 2023-07-26 15:11 kernel test robot
2023-07-27 0:57 ` Masami Hiramatsu
0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2023-07-26 15:11 UTC (permalink / raw)
To: Masami Hiramatsu; +Cc: llvm, oe-kbuild-all, Peter Zijlstra
tree: https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git x86/core
head: 1e68adb59894117251d942316d32514d45bd23ef
commit: 9289e7bef6851d3b50619eab6b28d4d9ff69a12a [2/6] x86/kprobes: Prohibit probing on compiler generated CFI checking code
config: x86_64-randconfig-x002-20230726 (https://download.01.org/0day-ci/archive/20230726/202307262307.LETETZsF-lkp@intel.com/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce: (https://download.01.org/0day-ci/archive/20230726/202307262307.LETETZsF-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202307262307.LETETZsF-lkp@intel.com/
All errors (new ones prefixed by >>):
>> arch/x86/kernel/kprobes/core.c:326:7: error: call to undeclared function 'is_cfi_trap'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
if (is_cfi_trap(addr + offset))
^
1 error generated.
vim +/is_cfi_trap +326 arch/x86/kernel/kprobes/core.c
254
255 /* Check if paddr is at an instruction boundary */
256 static int can_probe(unsigned long paddr)
257 {
258 unsigned long addr, __addr, offset = 0;
259 struct insn insn;
260 kprobe_opcode_t buf[MAX_INSN_SIZE];
261
262 if (!kallsyms_lookup_size_offset(paddr, NULL, &offset))
263 return 0;
264
265 /* Decode instructions */
266 addr = paddr - offset;
267 while (addr < paddr) {
268 int ret;
269
270 /*
271 * Check if the instruction has been modified by another
272 * kprobe, in which case we replace the breakpoint by the
273 * original instruction in our buffer.
274 * Also, jump optimization will change the breakpoint to
275 * relative-jump. Since the relative-jump itself is
276 * normally used, we just go through if there is no kprobe.
277 */
278 __addr = recover_probed_instruction(buf, addr);
279 if (!__addr)
280 return 0;
281
282 ret = insn_decode_kernel(&insn, (void *)__addr);
283 if (ret < 0)
284 return 0;
285
286 #ifdef CONFIG_KGDB
287 /*
288 * If there is a dynamically installed kgdb sw breakpoint,
289 * this function should not be probed.
290 */
291 if (insn.opcode.bytes[0] == INT3_INSN_OPCODE &&
292 kgdb_has_hit_break(addr))
293 return 0;
294 #endif
295 addr += insn.length;
296 }
297 if (IS_ENABLED(CONFIG_CFI_CLANG)) {
298 /*
299 * The compiler generates the following instruction sequence
300 * for indirect call checks and cfi.c decodes this;
301 *
302 * movl -<id>, %r10d ; 6 bytes
303 * addl -4(%reg), %r10d ; 4 bytes
304 * je .Ltmp1 ; 2 bytes
305 * ud2 ; <- regs->ip
306 * .Ltmp1:
307 *
308 * Also, these movl and addl are used for showing expected
309 * type. So those must not be touched.
310 */
311 __addr = recover_probed_instruction(buf, addr);
312 if (!__addr)
313 return 0;
314
315 if (insn_decode_kernel(&insn, (void *)__addr) < 0)
316 return 0;
317
318 if (insn.opcode.value == 0xBA)
319 offset = 12;
320 else if (insn.opcode.value == 0x3)
321 offset = 6;
322 else
323 goto out;
324
325 /* This movl/addl is used for decoding CFI. */
> 326 if (is_cfi_trap(addr + offset))
327 return 0;
328 }
329
330 out:
331 return (addr == paddr);
332 }
333
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [peterz-queue:x86/core 2/6] arch/x86/kernel/kprobes/core.c:326:7: error: call to undeclared function 'is_cfi_trap'; ISO C99 and later do not support implicit function declarations
2023-07-26 15:11 [peterz-queue:x86/core 2/6] arch/x86/kernel/kprobes/core.c:326:7: error: call to undeclared function 'is_cfi_trap'; ISO C99 and later do not support implicit function declarations kernel test robot
@ 2023-07-27 0:57 ` Masami Hiramatsu
0 siblings, 0 replies; 2+ messages in thread
From: Masami Hiramatsu @ 2023-07-27 0:57 UTC (permalink / raw)
To: kernel test robot; +Cc: llvm, oe-kbuild-all, Peter Zijlstra
On Wed, 26 Jul 2023 23:11:12 +0800
kernel test robot <lkp@intel.com> wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git x86/core
> head: 1e68adb59894117251d942316d32514d45bd23ef
> commit: 9289e7bef6851d3b50619eab6b28d4d9ff69a12a [2/6] x86/kprobes: Prohibit probing on compiler generated CFI checking code
> config: x86_64-randconfig-x002-20230726 (https://download.01.org/0day-ci/archive/20230726/202307262307.LETETZsF-lkp@intel.com/config)
> compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
> reproduce: (https://download.01.org/0day-ci/archive/20230726/202307262307.LETETZsF-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202307262307.LETETZsF-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
> >> arch/x86/kernel/kprobes/core.c:326:7: error: call to undeclared function 'is_cfi_trap'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
> if (is_cfi_trap(addr + offset))
> ^
> 1 error generated.
Oops, this is because kprobes/core.c includes <asm/cfi.h> instead of <linux/cfi.h>.
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index fa8c2b41cbaf..e8babebad7b8 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -45,6 +45,7 @@
#include <linux/vmalloc.h>
#include <linux/pgtable.h>
#include <linux/set_memory.h>
+#include <linux/cfi.h>
#include <asm/text-patching.h>
#include <asm/cacheflush.h>
@@ -54,7 +55,6 @@
#include <asm/insn.h>
#include <asm/debugreg.h>
#include <asm/ibt.h>
-#include <asm/cfi.h>
#include "common.h"
Thanks,
>
>
> vim +/is_cfi_trap +326 arch/x86/kernel/kprobes/core.c
>
> 254
> 255 /* Check if paddr is at an instruction boundary */
> 256 static int can_probe(unsigned long paddr)
> 257 {
> 258 unsigned long addr, __addr, offset = 0;
> 259 struct insn insn;
> 260 kprobe_opcode_t buf[MAX_INSN_SIZE];
> 261
> 262 if (!kallsyms_lookup_size_offset(paddr, NULL, &offset))
> 263 return 0;
> 264
> 265 /* Decode instructions */
> 266 addr = paddr - offset;
> 267 while (addr < paddr) {
> 268 int ret;
> 269
> 270 /*
> 271 * Check if the instruction has been modified by another
> 272 * kprobe, in which case we replace the breakpoint by the
> 273 * original instruction in our buffer.
> 274 * Also, jump optimization will change the breakpoint to
> 275 * relative-jump. Since the relative-jump itself is
> 276 * normally used, we just go through if there is no kprobe.
> 277 */
> 278 __addr = recover_probed_instruction(buf, addr);
> 279 if (!__addr)
> 280 return 0;
> 281
> 282 ret = insn_decode_kernel(&insn, (void *)__addr);
> 283 if (ret < 0)
> 284 return 0;
> 285
> 286 #ifdef CONFIG_KGDB
> 287 /*
> 288 * If there is a dynamically installed kgdb sw breakpoint,
> 289 * this function should not be probed.
> 290 */
> 291 if (insn.opcode.bytes[0] == INT3_INSN_OPCODE &&
> 292 kgdb_has_hit_break(addr))
> 293 return 0;
> 294 #endif
> 295 addr += insn.length;
> 296 }
> 297 if (IS_ENABLED(CONFIG_CFI_CLANG)) {
> 298 /*
> 299 * The compiler generates the following instruction sequence
> 300 * for indirect call checks and cfi.c decodes this;
> 301 *
> 302 * movl -<id>, %r10d ; 6 bytes
> 303 * addl -4(%reg), %r10d ; 4 bytes
> 304 * je .Ltmp1 ; 2 bytes
> 305 * ud2 ; <- regs->ip
> 306 * .Ltmp1:
> 307 *
> 308 * Also, these movl and addl are used for showing expected
> 309 * type. So those must not be touched.
> 310 */
> 311 __addr = recover_probed_instruction(buf, addr);
> 312 if (!__addr)
> 313 return 0;
> 314
> 315 if (insn_decode_kernel(&insn, (void *)__addr) < 0)
> 316 return 0;
> 317
> 318 if (insn.opcode.value == 0xBA)
> 319 offset = 12;
> 320 else if (insn.opcode.value == 0x3)
> 321 offset = 6;
> 322 else
> 323 goto out;
> 324
> 325 /* This movl/addl is used for decoding CFI. */
> > 326 if (is_cfi_trap(addr + offset))
> 327 return 0;
> 328 }
> 329
> 330 out:
> 331 return (addr == paddr);
> 332 }
> 333
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-27 0:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-26 15:11 [peterz-queue:x86/core 2/6] arch/x86/kernel/kprobes/core.c:326:7: error: call to undeclared function 'is_cfi_trap'; ISO C99 and later do not support implicit function declarations kernel test robot
2023-07-27 0:57 ` Masami Hiramatsu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox