Skip to content

Does kpatch work on kernels built with KASAN instrumentation, or is this configuration unsupported? #1495

@sumanthkorikkar

Description

@sumanthkorikkar

Hi,

While testing kpatch on a KASAN‑enabled kernel (data-new.patch), I encountered errors related to KASAN generated sections:

  1. Error log:
    ERROR: changed section .data.rel.local..LASAN0 not selected for inclusion
    ERROR: changed section .rela.data.rel.local..LASAN0 not selected for inclusion
    ERROR: changed section .text.exit._sub_D_65535_0 not selected for inclusion
    ERROR: changed section .text.startup._sub_I_65535_1 not selected for inclusion
    ERROR: fs/proc/meminfo.o: 4 unsupported section change(s)

  2. Debug data:
    Relocation section '.rela.data.rel.local..LASAN0' at offset 0x2af90 contains 150 entries:

    Offset             Info             Type               Symbol's Value  Symbol's Name + Addend
0000000000000000  0000000500000016 R_390_64               0000000000000000 .rodata + 600			
0000000000000018  0000001000000016 R_390_64               0000000000000000 .rodata.str1.2 + 0			
0000000000000020  0000001000000016 R_390_64               0000000000000000 .rodata.str1.2 + 8		
0000000000000040  0000000500000016 R_390_64               0000000000000000 .rodata + 3c0
0000000000000058  0000001000000016 R_390_64               0000000000000000 .rodata.str1.2 + 1a
0000000000000060  0000001000000016 R_390_64               0000000000000000 .rodata.str1.2 + 8
0000000000000080  0000000500000016 R_390_64               0000000000000000 .rodata + 180
...

Disassembly of section .text.startup._sub_I_65535_1:

0000000000000000 <_sub_I_65535_1>:
   0:   a7 39 00 32             lghi    %r3,50
   4:   c0 20 00 00 00 00       larl    %r2,4 <_sub_I_65535_1+0x4>
                        6: R_390_PC32DBL        .data.rel.local..LASAN0+0x2
   a:   c0 f4 00 00 00 00       jg      a <_sub_I_65535_1+0xa>
                        c: R_390_PLT32DBL       __asan_register_globals+0x2

readelf -p .rodata meminfo.o | grep 600
[ 600] Shmem:

readelf -p .rodata.str1.2

String dump of section '.rodata.str1.2':
  [     0]  *.LC25
  [     8]  fs/proc/meminfo.c
  [    1a]  *.LC16
 ...
 

Question
Since every change to a const string modifies .data.rel.local..LASAN0, and patching data section is not valid, does this mean:

  1. Is KASAN incompatible with kpatch due to KASAN’s data‑section instrumentation?
  2. Given that KASAN kernels are not typically used in production,
    is it fine to exclude kpatch support for KASAN builds?

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions