Commit fb6a421
kallsyms: Match symbols exactly with CONFIG_LTO_CLANG
With CONFIG_LTO_CLANG=y, the compiler may add .llvm.<hash> suffix to
function names to avoid duplication. APIs like kallsyms_lookup_name()
and kallsyms_on_each_match_symbol() tries to match these symbol names
without the .llvm.<hash> suffix, e.g., match "c_stop" with symbol
c_stop.llvm.17132674095431275852. This turned out to be problematic
for use cases that require exact match, for example, livepatch.
Fix this by making the APIs to match symbols exactly.
Also cleanup kallsyms_selftests accordingly.
Signed-off-by: Song Liu <song@kernel.org>
Fixes: 8cc32a9 ("kallsyms: strip LTO-only suffixes from promoted global functions")
Tested-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Acked-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20240807220513.3100483-3-song@kernel.org
Signed-off-by: Kees Cook <kees@kernel.org>1 parent 020925c commit fb6a421
2 files changed
Lines changed: 7 additions & 70 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | 163 | | |
196 | 164 | | |
197 | 165 | | |
| |||
219 | 187 | | |
220 | 188 | | |
221 | 189 | | |
222 | | - | |
| 190 | + | |
223 | 191 | | |
224 | 192 | | |
225 | 193 | | |
| |||
236 | 204 | | |
237 | 205 | | |
238 | 206 | | |
239 | | - | |
| 207 | + | |
240 | 208 | | |
241 | 209 | | |
242 | 210 | | |
| |||
248 | 216 | | |
249 | 217 | | |
250 | 218 | | |
251 | | - | |
| 219 | + | |
252 | 220 | | |
253 | 221 | | |
254 | 222 | | |
| |||
407 | 375 | | |
408 | 376 | | |
409 | 377 | | |
410 | | - | |
411 | | - | |
| 378 | + | |
412 | 379 | | |
413 | 380 | | |
414 | 381 | | |
| |||
422 | 389 | | |
423 | 390 | | |
424 | 391 | | |
425 | | - | |
426 | | - | |
427 | 392 | | |
428 | 393 | | |
429 | 394 | | |
| |||
450 | 415 | | |
451 | 416 | | |
452 | 417 | | |
453 | | - | |
454 | | - | |
455 | 418 | | |
456 | 419 | | |
457 | 420 | | |
| |||
462 | 425 | | |
463 | 426 | | |
464 | 427 | | |
465 | | - | |
| 428 | + | |
466 | 429 | | |
467 | 430 | | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
| 431 | + | |
475 | 432 | | |
476 | 433 | | |
477 | 434 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | 190 | | |
210 | 191 | | |
211 | 192 | | |
212 | 193 | | |
213 | | - | |
214 | | - | |
| 194 | + | |
215 | 195 | | |
216 | 196 | | |
217 | 197 | | |
| |||
0 commit comments