pkg/cover/backend: adjust module base address by .text offset

Modules' .text sections are not necessarily loaded at the address shown
in /proc/modules. If there are other non-init code sections preceding them
in the ELF binary, .text is loaded at non-zero address.

For example, for a module with the following sections:

Idx Name          Size      VMA               LMA               File off  Algn
...
  5 .plt          00000001  0000000000000000  0000000000000000  00000500  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  6 .init.ddplt     00000001  0000000000000000  0000000000000000  00000501  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  7 .text.ftrace_trampoline 00000001  0000000000000000  0000000000000000  00000502  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  8 .hyp.text     00002000  0000000000000000  0000000000000000  00001000  2**12
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
...
 13 .text         00001aac  0000000000000000  0000000000000000  00005048  2**2
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE

the base address displayed in /proc/modules points to the beginning of
.plt, and other sections have the following offsets:
 .init.plt - ignored
 .text.ftrace_trampoline - 0x1
 .hyp.text - 0x1000
 .text - 0x3000

This patch calculates the offset of the .text section and uses it to
adjust the address obtained from /proc/modules.
3 files changed
tree: e491e17ea77a46e1016eb44e9ee1e2a3e45485e5
  1. .github/
  2. dashboard/
  3. docs/
  4. executor/
  5. pkg/
  6. prog/
  7. sys/
  8. syz-ci/
  9. syz-fuzzer/
  10. syz-hub/
  11. syz-manager/
  12. syz-runner/
  13. syz-verifier/
  14. tools/
  15. vendor/
  16. vm/
  17. .clang-format
  18. .gitattributes
  19. .gitignore
  20. .golangci.yml
  21. AUTHORS
  22. CODE_OF_CONDUCT.md
  23. codecov.yml
  24. CONTRIBUTORS
  25. go.mod
  26. go.sum
  27. LICENSE
  28. Makefile
  29. README.md
README.md

syzkaller - kernel fuzzer

CI Status OSS-Fuzz Go Report Card Coverage Status GoDoc License

syzkaller ([siːzˈkɔːlə]) is an unsupervised coverage-guided kernel fuzzer.
Supported OSes: Akaros, FreeBSD, Fuchsia, gVisor, Linux, NetBSD, OpenBSD, Windows.

Mailing list: syzkaller@googlegroups.com (join on web or by email).

Found bugs: Akaros, Darwin/XNU, FreeBSD, Linux, NetBSD, OpenBSD, Windows.

Documentation

Initially, syzkaller was developed with Linux kernel fuzzing in mind, but now it's being extended to support other OS kernels as well. Most of the documentation at this moment is related to the Linux kernel. For other OS kernels check: Akaros, Darwin/XNU, FreeBSD, Fuchsia, NetBSD, OpenBSD, Starnix, Windows, gVisor.

Disclaimer

This is not an official Google product.