Re: [RFC PATCH] kernel/module: add a safer implementation of try_module_get()

2024-02-01 Thread Marco Pagani
On 2024-01-30 21:47, Luis Chamberlain wrote: > On Tue, Jan 30, 2024 at 08:36:14PM +0100, Marco Pagani wrote: >> The current implementation of try_module_get() requires the module to >> exist and be live as a precondition. While this may seem intuitive at >> first

[RFC PATCH] kernel/module: add a safer implementation of try_module_get()

2024-01-30 Thread Marco Pagani
efore attempting to take it. The tree lookup and refcount increment are executed after taking the module_mutex to prevent the module from being unloaded after looking up the tree. Signed-off-by: Marco Pagani --- include/linux/module.h | 15 +++ kernel/module/main.c

[PATCH] kernel/module: improve documentation for try_module_get()

2023-12-21 Thread Marco Pagani
The sentence "this call will fail if the module is already being removed" is potentially confusing and may contradict the rest of the documentation. If one tries to get a module that has already been removed using a stale pointer, the kernel will crash. Signed-off-by: Marco Pagani --