Skip to contentSkip to conversation

module: correctly exit module_kallsyms_on_each_symbol when fn() != 0

PATCH Petr Mladek 3 participants 3 messages May 20, 2021 – May 26, 2021 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Petr Mladek

author Reviewed-by
#1 lore raw
Quoted 8 lines · Jon Mediero

Commit 013c1667cf78 ("kallsyms: refactor {,module_}kallsyms_on_each_symbol") replaced the return inside the nested loop with a break, changing the semantics of the function: the break only exits the innermost loop, so the code continues iterating the symbols of the next module instead of exiting.

Fixes 013c1667cf78 ("kallsyms: refactor {,module_}kallsyms_on_each_symbol")

Great catch!

Quoted 5 lines

---
As far as I can tell the incorrect behaviour is not causing problems at the moment: module_kallsyms_on_each_symbol is no longer exported and the only existing caller (klp_find_object_symbol) does not care about the return value nor the extra iterations.

It would actually break livepatching a very subtle way.

klp_find_callback() must not longer get called when there are more symbols of the same name and args->count matches the requested args->pos. The buggy version will always find only the last occurence of such a symbol name.

Best Regards,
Petr

Reviewed-by
#2 lore raw
In reply to a message not in the archive
Quoted 8 lines · Jon Mediero

Commit 013c1667cf78 ("kallsyms: refactor {,module_}kallsyms_on_each_symbol") replaced the return inside the nested loop with a break, changing the semantics of the function: the break only exits the innermost loop, so the code continues iterating the symbols of the next module instead of exiting.

Fixes 013c1667cf78 ("kallsyms: refactor {,module_}kallsyms_on_each_symbol")

M

#3 lore raw
In reply to a message not in the archive

+++ Jon Mediero [20/05/21 14:23 +0200]:

Quoted 8 lines

Commit 013c1667cf78 ("kallsyms: refactor {,module_}kallsyms_on_each_symbol") replaced the return inside the nested loop with a break, changing the semantics of the function: the break only exits the innermost loop, so the code continues iterating the symbols of the next module instead of exiting.

Fixes 013c1667cf78 ("kallsyms: refactor {,module_}kallsyms_on_each_symbol")

Good catch, thanks a lot for the fix! Applied to modules-next.

Jessica