1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3# 4# Two kinds of module-owned static branch key are disabled with a warning 5# instead of rejected. 6# 7# A module-local key is normally fatal: late module patching lets the livepatch 8# load before the module it depends on, so the unresolved __jump_table entry is 9# dereferenced by jump_label_add_module(). test-jump-label-module-key covers 10# that rejection. 11# 12# Tracepoints and pr_debug() generate such keys everywhere, though, and 13# refusing them outright would make any function containing a trace_*() call or 14# a pr_debug() unpatchable. So klp diff drops the entry, says so, and carries 15# on: the patched code keeps working with that one tracepoint or debug print 16# permanently off. 17# 18# Both halves matter. A build that fails is a function nobody can patch; an 19# entry left in place is the memory corruption the rejection exists to prevent. 20# 21# The two exemptions are isolated: remove either and this fails. That the 22# entry is then dropped is asserted but not isolated -- making the caller keep 23# it anyway produces no output difference here, so that assertion stands as a 24# check on the behaviour rather than on the line which produces it. 25# 26# Covers the same ground as corpus/x86_64/static-call-module-tracepoint and 27# pr-debug-unsupported in Joe Lawrence's klp-build unit test corpus. 28 29. "$(dirname "$0")/../lib.sh" 30 31setup 32 33# check <key name> <expected warning> 34check() 35{ 36 build_pair jump_label.c -DKEY_NAME="$1" -DMODNAME='"klp_testmod"' 37 require_input_section __jump_table 38 39 # Accepted, not rejected: this is the whole point. 40 run_diff 41 assert_diff_log "$2" 42 43 # And the entry is gone, not merely complained about. 44 assert_patched target 45 assert_no_section __jump_table 46} 47 48check __tracepoint_klp_test 'disabling unsupported tracepoint klp_test' 49check __UNIQUE_ID_ddebug_klp_test 'disabling unsupported pr_debug' 50 51pass "tracepoint and pr_debug keys disabled with a warning, not rejected" 52