diff mbox series

[meta-oe] syzkaller: Fix check-syzos with llvm-objdump on x86-64

Message ID 20261201015429.3533511-1-khem.raj@oss.qualcomm.com
State New
Headers show
Series [meta-oe] syzkaller: Fix check-syzos with llvm-objdump on x86-64 | expand

Commit Message

Khem Raj Dec. 1, 2026, 1:54 a.m. UTC
Since check-syzos.sh uses $OBJDUMP, x86-64 builds with the clang
toolchain run llvm-objdump instead of the host GNU objdump. llvm-objdump
prints RIP-relative targets as "# 0x2cf730 <sym>", which the script's
hex2dec() cannot parse, so check_syzos reports every RIP-relative
instruction in the guest section and do_compile fails:

  [FAIL] Found problematic data access instructions in 'guest'.
    In function <_ZL28guest_handle_set_irq_handlerP10api_call_2>:
      2d0018: 48 8d 15 11 f7 ff ff  leaq -0x8ef(%rip), %rdx  # 0x2cf730 <__start_guest>

All of these targets are inside the guest section. Add a patch that
strips the 0x prefix before the address is converted.

AI-Generated: Uses Claude Code
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
 ...Accept-0x-prefixed-targets-from-llvm.patch | 38 +++++++++++++++++++
 .../recipes-test/syzkaller/syzkaller_git.bb   |  1 +
 2 files changed, 39 insertions(+)
 create mode 100644 meta-oe/recipes-test/syzkaller/syzkaller/0002-tools-check-syzos.sh-Accept-0x-prefixed-targets-from-llvm.patch
diff mbox series

Patch

diff --git a/meta-oe/recipes-test/syzkaller/syzkaller/0002-tools-check-syzos.sh-Accept-0x-prefixed-targets-from-llvm.patch b/meta-oe/recipes-test/syzkaller/syzkaller/0002-tools-check-syzos.sh-Accept-0x-prefixed-targets-from-llvm.patch
new file mode 100644
index 0000000000..f3e89c20ed
--- /dev/null
+++ b/meta-oe/recipes-test/syzkaller/syzkaller/0002-tools-check-syzos.sh-Accept-0x-prefixed-targets-from-llvm.patch
@@ -0,0 +1,38 @@ 
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Khem Raj <khem.raj@oss.qualcomm.com>
+Date: Mon, 30 Nov 2026 15:09:08 -0800
+Subject: [PATCH] tools/check-syzos.sh: Accept 0x-prefixed targets from
+ llvm-objdump
+
+For amd64 the script takes the target address of each RIP-relative
+instruction from the objdump comment. GNU objdump prints it without a
+prefix ("# 2cf730 <__start_guest>"), llvm-objdump with one
+("# 0x2cf730 <__start_guest>"). hex2dec() rejects the "x", so with
+llvm-objdump every RIP-relative instruction in the guest section is
+reported, including references inside the section:
+
+  [FAIL] Found problematic data access instructions in 'guest'.
+    In function <_ZL28guest_handle_set_irq_handlerP10api_call_2>:
+      2d0018: 48 8d 15 11 f7 ff ff  leaq -0x8ef(%rip), %rdx  # 0x2cf730 <__start_guest>
+
+Strip an optional 0x prefix before converting the address.
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
+---
+ tools/check-syzos.sh | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/tools/check-syzos.sh b/tools/check-syzos.sh
+index 3f1b6a9..d66a068 100644
+--- a/tools/check-syzos.sh
++++ b/tools/check-syzos.sh
+@@ -181,6 +181,8 @@ amd64|arm64|loong64)
+         if (!sub(/^.*#[[:space:]]*/, "", target_hex))
+             next
+         sub(/[[:space:]].*$/, "", target_hex)
++        # llvm-objdump prints the target as 0x<hex>, GNU objdump as <hex>.
++        sub(/^0[xX]/, "", target_hex)
+         target = hex2dec(target_hex)
+         if (target < 0 || target < guest_start || target >= guest_end)
+             report(0)
diff --git a/meta-oe/recipes-test/syzkaller/syzkaller_git.bb b/meta-oe/recipes-test/syzkaller/syzkaller_git.bb
index 384eeb0bb7..59e8efb371 100644
--- a/meta-oe/recipes-test/syzkaller/syzkaller_git.bb
+++ b/meta-oe/recipes-test/syzkaller/syzkaller_git.bb
@@ -8,6 +8,7 @@  require ${BPN}-licenses.inc
 
 SRC_URI = "git://${GO_IMPORT};protocol=https;destsuffix=${GO_SRCURI_DESTSUFFIX};branch=master \
            file://0001-tools-check-syzos.sh-Use-OBJDUMP-when-it-is-set.patch;patchdir=src/${GO_IMPORT} \
+           file://0002-tools-check-syzos.sh-Accept-0x-prefixed-targets-from-llvm.patch;patchdir=src/${GO_IMPORT} \
 "
 SRCREV = "e1f06033b21b05580a0f70130bae79f56b54f31b"
 require ${BPN}-go-mods.inc