1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3# 4# objtool's static call handling must accept a livepatch module which cannot 5# see a static call's key symbol. 6# 7# __SCK__* keys are not exported; modules get read-only access at load time 8# instead. Livepatch modules built by klp-build do have full access to their 9# keys, and a check was added on the strength of that -- but a livepatch module 10# can also be written by hand, and samples/livepatch is full of them. One of 11# those needs a key it cannot see as soon as it does anything that expands to a 12# static call, which with CONFIG_MEM_ALLOC_PROFILING_DEBUG includes allocating 13# memory: 14# 15# samples/livepatch/livepatch-shadow-fix1.o: error: objtool: static_call: 16# can't find static_call_key symbol: __SCK__WARN_trap 17# 18# The module built without the livepatch tag is the control: it takes the same 19# path and has always been accepted, so a test which only built the livepatch 20# one could not tell this fix from the check being removed altogether. 21# 22# Fixed by f495054bd12e ("objtool/klp: Fix unexported static call key access 23# for manually built livepatch modules"). 24 25. "$(dirname "$0")/../lib.sh" 26 27setup 28 29# Not a klp subcommand: this is objtool's ordinary check pass, which is what 30# runs over a hand-built livepatch module during a normal kernel build. 31for tag in "" -DLIVEPATCH; do 32 build_one static_call_no_key.c mod.o $tag 33 34 "$OBJTOOL" --module --static-call "$workdir/mod.o" \ 35 > "$workdir/objtool.log" 2>&1 || 36 fail "objtool rejected a ${tag:+livepatch }module which cannot" \ 37 "see its static call key: $(tail -1 "$workdir/objtool.log")" 38done 39 40pass "livepatch module accepted without access to its static call key" 41