https://sourceware.org/bugzilla/show_bug.cgi?id=34030

            Bug ID: 34030
           Summary: dwfl_linux_kernel_module_section_address fails on
                    __versions section due to missing sysfs entry
           Product: elfutils
           Version: unspecified
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: libdw
          Assignee: unassigned at sourceware dot org
          Reporter: marekpazur1 at seznam dot cz
                CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

Hello,

On Linux kernel 6.8.0 (tested on Ubuntu and Fedora), the __versions ELF section
of loaded kernel modules is not exported to sysfs under
/sys/module/<name>/sections/.

This appears to be intentional kernel behavior. In rewrite_section_headers()
(kernel/module/main.c), the kernel explicitly clears SHF_ALLOC for __versions
and .modinfo after they are processed during module loading, as they are not
needed at runtime:

/* Track but don't keep modinfo and version sections. */
info->sechdrs[info->index.vers].sh_flags &= ~(unsigned long)SHF_ALLOC;
info->sechdrs[info->index.vers_ext_crc].sh_flags &=
~(unsigned long)SHF_ALLOC;
info->sechdrs[info->index.vers_ext_name].sh_flags &=
~(unsigned long)SHF_ALLOC;
info->sechdrs[info->index.info].sh_flags &= ~(unsigned long)SHF_ALLOC;

As a result, dwfl_linux_kernel_module_section_address() returns DWARF_CB_ABORT
when DWARF relocations reference __versions, since the section cannot be
resolved via sysfs. This causes online kernel module DWARF inspection (via
dwfl_linux_kernel_report_kernel() and dwfl_linux_kernel_report_modules()) to
fail.

In libdwfl/linux-kernel-modules.c, some sections that are known to be absent
from sysfs are already handled explicitly by returning (Dwarf_Addr) -1l with
DWARF_CB_OK:

if (!strcmp (secname, ".modinfo")
    || !strcmp (secname, ".data.percpu")
    || startswith (secname, ".exit"))
{
    *addr = (Dwarf_Addr) -1l;
    return DWARF_CB_OK;
}

The __versions section is not in this list despite being subject to the same
kernel behavior as .modinfo. Since it is stripped of SHF_ALLOC after load and
never appears in sysfs, it seems appropriate to handle it in the same way.

Would it make sense to add __versions to this list?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to