mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
Init code and data are freed once boot finishes, so a klp relocation against them can never resolve. Signed-off-by: Puranjay Mohan <[email protected]> Signed-off-by: Song Liu <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Assisted-by: Claude:claude-opus-5 Link: https://patch.msgid.link/[email protected]
30 lines
1.1 KiB
Bash
Executable File
30 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
#
|
|
# Init code and data are freed after boot, so a klp relocation against them can
|
|
# never resolve. Such a patch must be rejected.
|
|
|
|
. "$(dirname "$0")/../lib.sh"
|
|
|
|
setup
|
|
build_pair init_reference.c
|
|
|
|
# The rejection can only happen if the patched build really does reference the
|
|
# init symbol. The fixture makes init_only volatile so the read cannot be
|
|
# folded away, and this checks that it worked: without a relocation klp diff
|
|
# would succeed, and the failure below would read as a missing check rather
|
|
# than as a fixture which stopped posing the question.
|
|
# Either spelling will do. A file-local variable is reached through its
|
|
# section symbol -- .init.data -- and a global one by name; which of the two
|
|
# the compiler picks is its business, and the reference is what matters.
|
|
in_relocs "$patched_obj" |
|
|
awk '$5 == ".init.data" || $5 == "init_only"' | grep -q . ||
|
|
fail "patched object has no reference into .init.data; the fixture tests nothing"
|
|
|
|
run_diff 255
|
|
|
|
diff_log | grep -q "can't patch or reference init code/data" ||
|
|
fail "expected rejection, got: $(diff_log | tail -1)"
|
|
|
|
pass "reference to init data rejected"
|