Commit e476bb27 authored by Josh Poimboeuf's avatar Josh Poimboeuf
Browse files

objtool/klp: Disable unsupported pr_debug() usage



Instead of erroring out on unsupported pr_debug() (e.g., when patching a
module), issue a warning and make it inert, similar to how unsupported
tracepoints are currently handled.

Reviewed-and-tested-by: default avatarSong Liu <song@kernel.org>
Link: https://patch.msgid.link/3a7db3a5b7d4abf9b2534803a74e2e7231322738.1770759954.git.jpoimboe@kernel.org


Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@kernel.org>
parent f9fb44b0
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -1334,18 +1334,18 @@ static bool should_keep_special_sym(struct elf *elf, struct symbol *sym)
 * be applied after static branch/call init, resulting in code corruption.
 *
 * Validate a special section entry to avoid that.  Note that an inert
 * tracepoint is harmless enough, in that case just skip the entry and print a
 * warning.  Otherwise, return an error.
 * tracepoint or pr_debug() is harmless enough, in that case just skip the
 * entry and print a warning.  Otherwise, return an error.
 *
 * This is only a temporary limitation which will be fixed when livepatch adds
 * support for submodules: fully self-contained modules which are embedded in
 * the top-level livepatch module's data and which can be loaded on demand when
 * their corresponding to-be-patched module gets loaded.  Then klp relocs can
 * be retired.
 * TODO: This is only a temporary limitation which will be fixed when livepatch
 * adds support for submodules: fully self-contained modules which are embedded
 * in the top-level livepatch module's data and which can be loaded on demand
 * when their corresponding to-be-patched module gets loaded.  Then klp relocs
 * can be retired.
 *
 * Return:
 *   -1: error: validation failed
 *    1: warning: tracepoint skipped
 *    1: warning: disabled tracepoint or pr_debug()
 *    0: success
 */
static int validate_special_section_klp_reloc(struct elfs *e, struct symbol *sym)
@@ -1403,6 +1403,13 @@ static int validate_special_section_klp_reloc(struct elfs *e, struct symbol *sym
				continue;
			}

			if (strstr(reloc->sym->name, "__UNIQUE_ID_ddebug_")) {
				WARN("%s: disabling unsupported pr_debug()",
				     code_sym->name);
				ret = 1;
				continue;
			}

			ERROR("%s+0x%lx: unsupported static branch key %s.  Use static_key_enabled() instead",
			      code_sym->name, code_offset, reloc->sym->name);
			return -1;