1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3# 4# An x86 alternative with an empty replacement still gets a relocation for its 5# replacement offset, but the label it points at is the end of the previous 6# replacement -- which is also the start of the next one. The value is 7# meaningless, and get_alt_entry() already ignores it. 8# 9# Cloning it drags in an unrelated neighboring replacement and everything that 10# replacement references. In the reported case an empty alternative in 11# meminfo_proc_show() pulled in one from proc_kcore_init(), emitting a klp 12# relocation against init text which is long freed by the time the patch is 13# applied. 14 15. "$(dirname "$0")/../lib.sh" 16 17setup 18build_pair empty_alternative.c 19 20assert_input_section .altinstructions 21assert_input_section .altinstr_replacement 22 23run_diff 24 25# target's own replacement comes along ... 26assert_symbol target_repl 27# ... neighbor's does not, nor what it references. 28assert_no_symbol neighbor_repl 29assert_no_symbol neighbor_only 30 31pass "empty alternative's replacement offset ignored when cloning" 32