Re: [PATCH 1/3] module: Fix missing taint flags for unloaded modules

From: Aaron Tomlin

Date: Tue Oct 20 2026 - 11:24:52 EST


On Tue, Oct 20, 2026 at 04:05:19PM +0200, Petr Pavlu wrote:
> When recording taint flags for an unloaded module, try_add_tainted_module()
> can fail to record some of the module's flags if a record for a module with
> the same name already exists and the two have at least one flag in common.
> This happens because the function uses 'mod_taint->taints & mod->taints' to
> determine whether to merge the new module with the existing record. As
> a result, the final report may not provide accurate information about the
> taint flags of unloaded modules.
>
> Fix the duplicate check by using the stricter equality comparison.
>
> Fixes: 99bd9956551b ("module: Introduce module unload taint tracking")
> Signed-off-by: Petr Pavlu <petr.pavlu@xxxxxxxx>
> ---
> kernel/module/tracking.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/module/tracking.c b/kernel/module/tracking.c
> index 9033ff54c4e2..5bcd1c2701f0 100644
> --- a/kernel/module/tracking.c
> +++ b/kernel/module/tracking.c
> @@ -27,7 +27,7 @@ int try_add_tainted_module(struct module *mod)
> list_for_each_entry_rcu(mod_taint, &unloaded_tainted_modules, list,
> lockdep_is_held(&module_mutex)) {
> if (!strcmp(mod_taint->name, mod->name) &&
> - mod_taint->taints & mod->taints) {
> + mod_taint->taints == mod->taints) {
> mod_taint->count++;
> goto out;
> }
>
> --
> 2.55.0

Reviewed-by: Aaron Tomlin <atomlin@xxxxxxxxxxx>

--
Aaron Tomlin