find_sympos() calculates a sympos used by livepatch to disambiguate duplicately-named symbols. For function symbols, there's a hack which counts .text.unlikely symbols before other .text symbols, matching the linker script's section ordering. Not only is the hack fragile, data symbols can have the same problem. So for example, adding a reference to pwq_cache in ep_unregister_pollwait() can trigger a corrupt sympos and a relocation to the wrong pwq_cache symbol in the livepatch module, resulting in a crash or undefined behavior. Remove the existing hack in favor of a fully deterministic solution, using the new .klp.symid table to derive the symbol-to-id mapping from the original vmlinux.o and the id-to-address mapping from the corresponding vmlinux, which can then be used to determine the exact sympos associated with the original vmlinux. Modules don't need any special treatment: the .ko has the same section/symbol ordering as the original whole-archive symbol table.
Showing the changes to scripts (1 of 5 files). Show all
Unified · Split
| @@ -611,6 +611,8 @@ copy_orig_objects() { · 610 unmodified lines | ||
| 611 | 611 | done |
| 612 | 612 | xtrace_restore |
| 613 | 613 | |
| 614 | + cp -f "$PWD/vmlinux" "$ORIG_DIR" || die "missing vmlinux" | |
| 615 | + | |
| 614 | 616 | mv -f "$TMP_DIR/build.log" "$ORIG_DIR" |
| 615 | 617 | touch "$TIMESTAMP" |
| 616 | 618 | touch "$ORIG_DIR/.complete" |
| @@ -681,6 +683,8 @@ generate_checksums() { · 64 unmodified lines | ||
| 681 | 683 | "$OBJTOOL" klp checksum "$dest" |
| 682 | 684 | done |
| 683 | 685 | |
| 686 | + [[ -f "$src_dir/vmlinux" ]] && cp -f "$src_dir/vmlinux" "$dest_dir" | |
| 687 | + | |
| 684 | 688 | touch "$dest_dir/.complete" |
| 685 | 689 | } |
| 686 | 690 | |