Re: [PATCH v2] kallsyms: strip LTO-only suffixes from promoted global functions

From: Yonghong Song
Date: Thu Jul 13 2023 - 02:15:00 EST




On 7/12/23 3:40 PM, Kees Cook wrote:

On Wed, 28 Jun 2023 11:19:26 -0700, Yonghong Song wrote:
Commit 6eb4bd92c1ce ("kallsyms: strip LTO suffixes from static functions")
stripped all function/variable suffixes started with '.' regardless
of whether those suffixes are generated at LTO mode or not. In fact,
as far as I know, in LTO mode, when a static function/variable is
promoted to the global scope, '.llvm.<...>' suffix is added.

The existing mechanism breaks live patch for a LTO kernel even if
no <symbol>.llvm.<...> symbols are involved. For example, for the following
kernel symbols:
$ grep bpf_verifier_vlog /proc/kallsyms
ffffffff81549f60 t bpf_verifier_vlog
ffffffff8268b430 d bpf_verifier_vlog._entry
ffffffff8282a958 d bpf_verifier_vlog._entry_ptr
ffffffff82e12a1f d bpf_verifier_vlog.__already_done
'bpf_verifier_vlog' is a static function. '_entry', '_entry_ptr' and
'__already_done' are static variables used inside 'bpf_verifier_vlog',
so llvm promotes them to file-level static with prefix 'bpf_verifier_vlog.'.
Note that the func-level to file-level static function promotion also
happens without LTO.

[...]

Applied, thanks!

[1/1] kallsyms: strip LTO-only suffixes from promoted global functions
https://git.kernel.org/kees/c/8cc32a9bbf29

Thanks Kees!


Best regards,