Skip to content

Commit d26e69d

Browse files
create-diff-object: Handle __stack_protector_loc section
kpatch fails to build modules when s390 stack protector is enabled: ERROR: changed section .rela__stack_protector_loc not selected for inclusion ERROR: fs/proc/meminfo.o: 1 unsupported section change(s) Recent gcc versions introduce new s390 stack protector options: -mstack-protector-guard=global -mstack-protector-guard-record These generate __stack_protector_loc section that records canary reference locations. The kernel later patches these at runtime to use pertask canaries. kpatch currently does not handle this section, leading to kpatch build failures. Add __stack_protector_loc to the special_sections list with an appropriate group handler, so kpatch can correctly regenerate the section and update relocations for patched functions. Details: * Disassembly of section __stack_protector_loc: 0000000000000000 <__stack_protector_loc>: ... 0: R_390_64 meminfo_proc_show+0x20 8: R_390_64 meminfo_proc_show+0xb6e * Load canary value and store it in the stack (prologue) 0000000000000510 <meminfo_proc_show>: static int meminfo_proc_show(struct seq_file *m, void *v) { 510: c0 04 00 00 00 00 jgnop 510 <meminfo_proc_show> 516: eb 6f f0 48 00 24 stmg %r6,%r15,72(%r15) 51c: b9 04 00 ef lgr %r14,%r15 520: b9 04 00 b2 lgr %r11,%r2 524: e3 f0 fe f8 ff 71 lay %r15,-264(%r15) 52a: e3 e0 f0 98 00 24 stg %r14,152(%r15) 530: c4 18 00 00 00 00 lgrl %r1,530 <meminfo_proc_show+0x20> 532: R_390_GOTENT __stack_chk_guard+0x2 536: d2 07 f1 48 10 00 mvc 328(8,%r15),0(%r1) * Compare canary value (epilogue): 107e: c4 b8 00 00 00 00 lgrl %r11,107e <meminfo_proc_show+0xb6e> 1080: R_390_GOTENT __stack_chk_guard+0x2 1084: d5 07 f1 48 b0 00 clc 328(8,%r15),0(%r11) 108a: a7 74 00 0a jne 109e <meminfo_proc_show+0xb8e> ... 109e: c0 e5 00 00 00 00 brasl %r14,109e <meminfo_proc_show+0xb8e> 10a0: R_390_PLT32DBL __stack_chk_fail+0x2 References: - gcc commit 0cd1f03939d5 ("s390: Support global stack protector") - kernel commit f5730d44e05e ("s390: Add stackprotector support") Signed-off-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
1 parent 6e58fed commit d26e69d

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

kpatch-build/create-diff-object.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,6 +2412,11 @@ static int s390_expolines_group_size(struct kpatch_elf *kelf, int offset)
24122412
return 4;
24132413
}
24142414

2415+
static int s390_stack_protector_loc_group_size(struct kpatch_elf *kelf, int offset)
2416+
{
2417+
return 8;
2418+
}
2419+
24152420
/*
24162421
* The rela groups in the .fixup section vary in size. The beginning of each
24172422
* .fixup rela group is referenced by the __ex_table section. To find the size
@@ -2738,6 +2743,11 @@ static struct special_section special_sections[] = {
27382743
.arch = S390,
27392744
.group_size = s390_expolines_group_size,
27402745
},
2746+
{
2747+
.name = "__stack_protector_loc",
2748+
.arch = S390,
2749+
.group_size = s390_stack_protector_loc_group_size,
2750+
},
27412751
{},
27422752
};
27432753

0 commit comments

Comments
 (0)