create-diff-object: Fix function pointer rela on s390 #1445
+24
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Typically, symbols within the same object file can be referenced directly for better performance. However, when the patched code stores a function pointer (R_390_GOTENT and rela symbol type is STT_FUNC), using a dynrela is a safer approach. This ensures that if the function is used as a asynchronous callback, the kernel does not attempt to execute an invalid pointer after the module is unloaded. Instead, with a dynrela, the kernel will invoke the original function, preventing potential crashes.
Test program: Test if the original function ptr address is printed during patch load / unload.
iii-i/linux@0f400db
Patched code (function ptr rela):void *patchme(void) { printk(KERN_NOTICE "patched\n"); return patchme; }0: c0 04 00 00 00 00 jgnop 0 <patchme>6: eb ef f0 88 00 24 stmg %r14,%r15,136(%r15)c: c4 28 00 00 00 00 lgrl %r2,c <patchme+0xc>e: R_390_GOTENT .LC0+0x212: b9 04 00 ef lgr %r14,%r1516: e3 f0 ff e8 ff 71 lay %r15,-24(%r15)1c: e3 e0 f0 98 00 24 stg %r14,152(%r15)22: c0 e5 00 00 00 00 brasl %r14,22 <patchme+0x22>24: R_390_PLT32DBL _printk+0x228: c4 28 00 00 00 00 lgrl %r2,28 <patchme+0x28>2a: R_390_GOTENT patchme+0x2 <- func ptr2e: eb ef f0 a0 00 04 lmg %r14,%r15,160(%r15)34: c0 f4 00 00 00 00 jg 34 <patchme+0x34>36: R_390_PC32DBL __s390_indirect_jump_r14+0x23a: 07 07 nopr %r73c: 07 07 nopr %r73e: 07 07 nopr %r7Reference: