On Mon, Oct 23, 2017 at 9:28 PM, Bhargava Shastry <
bsh...@gmail.com> wrote:
> Hi all,
>
> Have any of you gotten around to compiling external kernel modules (in-tree
> build) with KCOV and KASAN instrumentation. I have enabled CONFIG_KCOV/KASAN
> and verified that the kernel image has been properly instrumented. It's just
> that external kernel modules have not been instrumented.
Hi,
It should work. Makefile uses the same CFLAGS when compiling core
kernel and modules.
I've just enabled CONFIG_TEST_KASAN=m on:
commit 36ef71cae353f88fd6e095e2aaa3e5953af1685d (HEAD, tag:
next-20171018, linux-next/master)
Date: Thu Oct 19 01:15:23 2017 +0100
Add linux-next specific files for 20171018
and objdump -d ./lib/test_kasan.ko shows me:
./lib/test_kasan.ko: file format elf64-x86-64
Disassembly of section .init.text:
0000000000000000 <kasan_stack_oob>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: 41 55 push %r13
6: 41 54 push %r12
8: 53 push %rbx
9: 48 8d 9d 48 ff ff ff lea -0xb8(%rbp),%rbx
10: 49 bd 00 00 00 00 00 movabs $0xdffffc0000000000,%r13
17: fc ff df
1a: 48 c1 eb 03 shr $0x3,%rbx
1e: 48 81 ec a0 00 00 00 sub $0xa0,%rsp
25: 48 c7 85 48 ff ff ff movq $0x41b58ab3,-0xb8(%rbp)
That 0xdffffc0000000000 is inline KASAN instrumentation.
> I am guessing once the ext modules are instrumented, syzkaller will work
> off-the-shelf?
Yes. It should not matter if code is in module or not.
One note is syzkaller/KCOV can misbehave if a modules are unloaded and
loaded again at different addresses, because we will see new PCs
covered all the time. But if modules are loaded once it should work
fine.