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