[Bug 288000] [PATCH] dtrace: fix symbol address resolving

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 04 Jul 2025 12:50:34 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=288000

            Bug ID: 288000
           Summary: [PATCH] dtrace: fix symbol address resolving
           Product: Base System
           Version: CURRENT
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: zldrobit@gmail.com

Created attachment 261862
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=261862&action=edit
file of the patch

Dtrace assumes only ELF sections of type SHT_PROGBITS or SHT_NOBITS occupy
memory space. However, sections with SHF_ALLOC flag also consume memory space.
Moreover, the symbol address initialization skips symbols at the very beginning
of a section.

Fix: Check section flag for calculating section offset, and disable the
skipping at the beginning of a section.

Reproduction (requires `zfs.ko` and `ksyms.ko`):
1. readelf -s /dev/ksyms | grep -b '\<zfs_dirty_data_max\>' 
2. dtrace -n 'BEGIN {printf("%p", &`zfs_dirty_data_max);}' 
3. The symbol addresses are different.

Reproduction of the 2nd problem (requires `ossl.ko` and `ksyms.ko`):
1. readelf -s /dev/ksyms | grep -b '\<OPENSSL_ia32cap_P\>' 
2. dtrace -n 'BEGIN {printf("%p", &`OPENSSL_ia32cap_P);}' 
3. The symbol address of step 2 is zero while that of step 1 is not.

The patch is uploaded as an attachment.

-- 
You are receiving this mail because:
You are the assignee for the bug.