Re: [PATCH v3 1/2] module: pull out add_taint_module() to be public

2026-09-04 Thread Petr Pavlu
On 9/4/26 2:19 PM, Greg Kroah-Hartman wrote:
> On Fri, Sep 04, 2026 at 11:25:01AM +0200, Petr Pavlu wrote:
>> On 9/4/26 7:10 AM, Greg Kroah-Hartman wrote:
>>> diff --git a/kernel/module/main.c b/kernel/module/main.c
>>> index d0e1e0bd2ad0..444d990c9983 100644
>>> --- a/kernel/module/main.c
>>> +++ b/kernel/module/main.c
>>> @@ -191,11 +191,21 @@ static inline int strong_try_module_get(struct module 
>>> *mod)
>>> return -ENOENT;
>>>  }
>>>  
>>> -static inline void add_taint_module(struct module *mod, unsigned flag,
>>> -   enum lockdep_ok lockdep_ok)
>>> +/**
>>> + * add_taint_module: add a taint flag if not already set for a specific 
>>> module
>>> + * @mod: pointer to the module that caused the problem
>>> + * @flag: one of the TAINT_* constants.
>>> + * @lockdep_ok: whether lock debugging is still OK.
>>> + *
>>> + * If something bad has gone wrong, you'll want @lockdebug_ok = false, but 
>>> for
>>> + * some noteworthy-but-not-corrupting cases, it can be set to true.
>>
>> Nit: The final paragraph is mostly copied from the description of
>> add_taint() but I don't think it is quite right. The parameter name
>> should be lockdep_ok, not lockdebug_ok and the values are
>> LOCKDEP_STILL_OK / LOCKDEP_NOW_UNRELIABLE, not true / false.
>>
>> I suggest updating this part for both add_taint() and add_taint_module()
>> to something like:
>>
>>  * Use @lockdep_ok = LOCKDEP_NOW_UNRELIABLE if something serious has gone 
>> wrong.
>>  * For noteworthy but non-corrupting cases, use LOCKDEP_STILL_OK instead.
> 
> How about I add another patch to the series that fixes up the
> documentation for both functions?  They both should be fixed up and I
> might as well get them in sync properly.

Makes sense to me.

-- 
Thanks,
Petr



Re: [PATCH v3 1/2] module: pull out add_taint_module() to be public

2026-09-04 Thread Greg Kroah-Hartman
On Fri, Sep 04, 2026 at 11:25:01AM +0200, Petr Pavlu wrote:
> On 9/4/26 7:10 AM, Greg Kroah-Hartman wrote:
> > Other kernel code might want to call add_taint_module() so pull it out
> > and make it global.  If modules are not enabled, this defaults to a call
> > to add_taint(), so all is fine.
> > 
> > Reviewed-by: Johan Hovold 
> > Tested-by: Johan Hovold 
> > Reviewed-by: Bradley Morgan 
> > Signed-off-by: Greg Kroah-Hartman 
> > ---
> >  include/linux/module.h | 10 ++
> >  kernel/module/main.c   | 16 +---
> >  2 files changed, 23 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/linux/module.h b/include/linux/module.h
> > index 96cc98568eea..f6f90cd88f15 100644
> > --- a/include/linux/module.h
> > +++ b/include/linux/module.h
> > @@ -29,6 +29,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> 
> Note that I'm working on cleaning up linux/module.h to reduce its
> preprocessed size. The main motivation is to shorten the compilation
> time of all the small *.mod.c files. Since linux/module.h already
> includes linux/panic.h indirectly, adding this include explicitly seems
> fine to me for now. In the future, I think we should introduce something
> like kernel/module/stubs.c where the CONFIG_MODULES=n variants of
> add_taint_module() and other similar functions can live without bloating
> linux/module.h.
> 
> >  
> >  #include 
> >  #include 
> > @@ -770,6 +771,9 @@ static inline bool is_livepatch_module(struct module 
> > *mod)
> >  
> >  void module_for_each_mod(int(*func)(struct module *mod, void *data), void 
> > *data);
> >  
> > +void add_taint_module(struct module *mod, unsigned flag,
> > + enum lockdep_ok lockdep_ok);
> > +
> >  #else /* !CONFIG_MODULES... */
> >  
> >  static inline struct module *__module_address(unsigned long addr)
> > @@ -877,6 +881,12 @@ static inline bool module_is_coming(struct module *mod)
> >  static inline void module_for_each_mod(int(*func)(struct module *mod, void 
> > *data), void *data)
> >  {
> >  }
> > +
> > +static inline void add_taint_module(struct module *mod, unsigned flag,
> > +   enum lockdep_ok lockdep_ok)
> > +{
> > +   add_taint(flag, lockdep_ok);
> > +}
> >  #endif /* CONFIG_MODULES */
> >  
> >  #ifdef CONFIG_SYSFS
> > diff --git a/kernel/module/main.c b/kernel/module/main.c
> > index d0e1e0bd2ad0..444d990c9983 100644
> > --- a/kernel/module/main.c
> > +++ b/kernel/module/main.c
> > @@ -191,11 +191,21 @@ static inline int strong_try_module_get(struct module 
> > *mod)
> > return -ENOENT;
> >  }
> >  
> > -static inline void add_taint_module(struct module *mod, unsigned flag,
> > -   enum lockdep_ok lockdep_ok)
> > +/**
> > + * add_taint_module: add a taint flag if not already set for a specific 
> > module
> > + * @mod: pointer to the module that caused the problem
> > + * @flag: one of the TAINT_* constants.
> > + * @lockdep_ok: whether lock debugging is still OK.
> > + *
> > + * If something bad has gone wrong, you'll want @lockdebug_ok = false, but 
> > for
> > + * some noteworthy-but-not-corrupting cases, it can be set to true.
> 
> Nit: The final paragraph is mostly copied from the description of
> add_taint() but I don't think it is quite right. The parameter name
> should be lockdep_ok, not lockdebug_ok and the values are
> LOCKDEP_STILL_OK / LOCKDEP_NOW_UNRELIABLE, not true / false.
> 
> I suggest updating this part for both add_taint() and add_taint_module()
> to something like:
> 
>  * Use @lockdep_ok = LOCKDEP_NOW_UNRELIABLE if something serious has gone 
> wrong.
>  * For noteworthy but non-corrupting cases, use LOCKDEP_STILL_OK instead.

How about I add another patch to the series that fixes up the
documentation for both functions?  They both should be fixed up and I
might as well get them in sync properly.

> > + */
> > +void add_taint_module(struct module *mod, unsigned flag,
> > + enum lockdep_ok lockdep_ok)
> >  {
> > add_taint(flag, lockdep_ok);
> > -   set_bit(flag, &mod->taints);
> > +   if (mod)
> > +   set_bit(flag, &mod->taints);
> >  }
> >  
> >  /*
> > 
> 
> Otherwise, this looks ok to me. Feel free to add:
> 
> Reviewed-by: Petr Pavlu 

Great, will do, and I'll do a v4 early next week with the documentation
fixes.

thanks,

greg k-h



Re: [PATCH v3 1/2] module: pull out add_taint_module() to be public

2026-09-04 Thread Petr Pavlu
On 9/4/26 7:10 AM, Greg Kroah-Hartman wrote:
> Other kernel code might want to call add_taint_module() so pull it out
> and make it global.  If modules are not enabled, this defaults to a call
> to add_taint(), so all is fine.
> 
> Reviewed-by: Johan Hovold 
> Tested-by: Johan Hovold 
> Reviewed-by: Bradley Morgan 
> Signed-off-by: Greg Kroah-Hartman 
> ---
>  include/linux/module.h | 10 ++
>  kernel/module/main.c   | 16 +---
>  2 files changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/module.h b/include/linux/module.h
> index 96cc98568eea..f6f90cd88f15 100644
> --- a/include/linux/module.h
> +++ b/include/linux/module.h
> @@ -29,6 +29,7 @@
>  #include 
>  #include 
>  #include 
> +#include 

Note that I'm working on cleaning up linux/module.h to reduce its
preprocessed size. The main motivation is to shorten the compilation
time of all the small *.mod.c files. Since linux/module.h already
includes linux/panic.h indirectly, adding this include explicitly seems
fine to me for now. In the future, I think we should introduce something
like kernel/module/stubs.c where the CONFIG_MODULES=n variants of
add_taint_module() and other similar functions can live without bloating
linux/module.h.

>  
>  #include 
>  #include 
> @@ -770,6 +771,9 @@ static inline bool is_livepatch_module(struct module *mod)
>  
>  void module_for_each_mod(int(*func)(struct module *mod, void *data), void 
> *data);
>  
> +void add_taint_module(struct module *mod, unsigned flag,
> +   enum lockdep_ok lockdep_ok);
> +
>  #else /* !CONFIG_MODULES... */
>  
>  static inline struct module *__module_address(unsigned long addr)
> @@ -877,6 +881,12 @@ static inline bool module_is_coming(struct module *mod)
>  static inline void module_for_each_mod(int(*func)(struct module *mod, void 
> *data), void *data)
>  {
>  }
> +
> +static inline void add_taint_module(struct module *mod, unsigned flag,
> + enum lockdep_ok lockdep_ok)
> +{
> + add_taint(flag, lockdep_ok);
> +}
>  #endif /* CONFIG_MODULES */
>  
>  #ifdef CONFIG_SYSFS
> diff --git a/kernel/module/main.c b/kernel/module/main.c
> index d0e1e0bd2ad0..444d990c9983 100644
> --- a/kernel/module/main.c
> +++ b/kernel/module/main.c
> @@ -191,11 +191,21 @@ static inline int strong_try_module_get(struct module 
> *mod)
>   return -ENOENT;
>  }
>  
> -static inline void add_taint_module(struct module *mod, unsigned flag,
> - enum lockdep_ok lockdep_ok)
> +/**
> + * add_taint_module: add a taint flag if not already set for a specific 
> module
> + * @mod: pointer to the module that caused the problem
> + * @flag: one of the TAINT_* constants.
> + * @lockdep_ok: whether lock debugging is still OK.
> + *
> + * If something bad has gone wrong, you'll want @lockdebug_ok = false, but 
> for
> + * some noteworthy-but-not-corrupting cases, it can be set to true.

Nit: The final paragraph is mostly copied from the description of
add_taint() but I don't think it is quite right. The parameter name
should be lockdep_ok, not lockdebug_ok and the values are
LOCKDEP_STILL_OK / LOCKDEP_NOW_UNRELIABLE, not true / false.

I suggest updating this part for both add_taint() and add_taint_module()
to something like:

 * Use @lockdep_ok = LOCKDEP_NOW_UNRELIABLE if something serious has gone wrong.
 * For noteworthy but non-corrupting cases, use LOCKDEP_STILL_OK instead.

> + */
> +void add_taint_module(struct module *mod, unsigned flag,
> +   enum lockdep_ok lockdep_ok)
>  {
>   add_taint(flag, lockdep_ok);
> - set_bit(flag, &mod->taints);
> + if (mod)
> + set_bit(flag, &mod->taints);
>  }
>  
>  /*
> 

Otherwise, this looks ok to me. Feel free to add:

Reviewed-by: Petr Pavlu 

-- 
Thanks,
Petr