Re: [PATCH] objtool/klp: Fix missed changes to same-named symbol references

From: Josh Poimboeuf

Date: Sun Sep 13 2026 - 20:27:36 EST


On Thu, Sep 10, 2026 at 04:52:18PM +0800, Longjun Luo wrote:
> Hashing symbol references by demangled_name alone can miss target
> changes while the instruction or data bytes and normalized relocation
> offsets remain unchanged. This occurs when:
>
> - A global function moves between files and calls a same-named static
> function with a different implementation.
> - A function's call target changes from a global function to a
> same-named static function, without moving the caller.
> - A data object, such as an ops structure, changes its function pointer
> from a global function to a same-named static function.

These seem like unusual edge cases, is this problem theoretical or was
it a real-world bug?

> +/* Include FILE identity to distinguish same-named local targets. */
> +static inline void __checksum_update_symbol_identity(struct symbol *sym,
> + struct symbol *target)
> +{
> + const char *file_name = target->file ? target->file->name : "";
> +
> + __checksum_update(sym, file_name, strlen(file_name) + 1);
> + __checksum_update(sym, target->demangled_name, strlen(target->demangled_name) + 1);
> +}

If the .patch upgrades a function from static to global then the
function no longer has a FILE associated with it. Then with the above,
all callers to that function would be marked as changed. And note that
LTO does a lot of that, so static-to-global and global-to-static changes
are common between orig and patched objects.

Note that function change detection isn't intended to be 100% perfect
for all edge cases. The patch author needs to verify the changed
function list matches what they expect.

--
Josh