mbox series

[v4,0/2] module: Introduce module unload taint tracking

Message ID 20220425090841.3958494-1-atomlin@redhat.com (mailing list archive)
Headers show
Series module: Introduce module unload taint tracking | expand

Message

Aaron Tomlin April 25, 2022, 9:08 a.m. UTC
Hi Luis,

This iteration is still based on the latest mcgrof/modules-next branch.

I have decided still to use RCU even though no entry is ever removed from
the unloaded tainted modules list. That being said, if I understand
correctly, it is not safe in some instances to use 'module_mutex' in
print_modules().  So instead we disable preemption to ensure list traversal
with concurrent list manipulation e.g. list_add_rcu(), is safe too.

Changes since v3 [1]
 - Fixed kernel build error reported by kernel test robot i.e. moved
   '#endif' outside 'if (!list_empty(&unloaded_tainted_modules))'
   statement in the context of print_modules()
 - Used strncmp() instead of memcmp()
   (Oleksandr Natalenko)
 - Removed the additional strlen()
   (Christoph Lameter)

Changes since v2 [2]
 - Dropped RFC from subject
 - Removed the newline i.e. "\n" in printk()
 - Always include the tainted module's unload count
 - Unconditionally display each unloaded tainted module

Please let me know your thoughts.

[1]: https://lore.kernel.org/all/20220420115257.3498300-1-atomlin@redhat.com/
[2]: https://lore.kernel.org/all/20220419150334.3395019-1-atomlin@redhat.com/


Aaron Tomlin (2):
  module: Make module_flags_taint() accept a module's taints bitmap
    directly
  module: Introduce module unload taint tracking

 init/Kconfig         | 11 +++++++
 kernel/module/main.c | 73 +++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 80 insertions(+), 4 deletions(-)


base-commit: eeaec7801c421e17edda6e45a32d4a5596b633da

Comments

Luis Chamberlain April 25, 2022, 11:31 p.m. UTC | #1
On Mon, Apr 25, 2022 at 10:08:39AM +0100, Aaron Tomlin wrote:
> Hi Luis,
> 
> This iteration is still based on the latest mcgrof/modules-next branch.
> 
> I have decided still to use RCU even though no entry is ever removed from
> the unloaded tainted modules list. That being said, if I understand
> correctly, it is not safe in some instances to use 'module_mutex' in
> print_modules().  So instead we disable preemption to ensure list traversal
> with concurrent list manipulation e.g. list_add_rcu(), is safe too.
> 
> Changes since v3 [1]
>  - Fixed kernel build error reported by kernel test robot i.e. moved
>    '#endif' outside 'if (!list_empty(&unloaded_tainted_modules))'
>    statement in the context of print_modules()
>  - Used strncmp() instead of memcmp()
>    (Oleksandr Natalenko)
>  - Removed the additional strlen()
>    (Christoph Lameter)
> 
> Changes since v2 [2]
>  - Dropped RFC from subject
>  - Removed the newline i.e. "\n" in printk()
>  - Always include the tainted module's unload count
>  - Unconditionally display each unloaded tainted module
> 
> Please let me know your thoughts.

This all looks good except with all the work you did to remove
#ifdef hell, it gets me wondering why not just use a new file for this?

What does that look like?

  Luis
Aaron Tomlin April 26, 2022, 8:39 a.m. UTC | #2
On Mon 2022-04-25 16:31 -0700, Luis Chamberlain wrote:
> This all looks good except with all the work you did to remove
> #ifdef hell, it gets me wondering why not just use a new file for this?
> 
> What does that look like?

Hi Luis,

I thought about it. It is indeed possible. Yet, I do not think it is worth
it, for such a small change; albeit, what do you prefer?


Kind regards,
Luis Chamberlain April 26, 2022, 4:22 p.m. UTC | #3
On Tue, Apr 26, 2022 at 09:39:30AM +0100, Aaron Tomlin wrote:
> On Mon 2022-04-25 16:31 -0700, Luis Chamberlain wrote:
> > This all looks good except with all the work you did to remove
> > #ifdef hell, it gets me wondering why not just use a new file for this?
> > 
> > What does that look like?
> 
> Hi Luis,
> 
> I thought about it. It is indeed possible. Yet, I do not think it is worth
> it, for such a small change; albeit, what do you prefer?

I'd rather see the effort than not, given all the effort to already split things.
I think it keeps things pretty tidy and it can scale / and its easier to review.

  Luis
Aaron Tomlin April 27, 2022, 9:07 a.m. UTC | #4
On Tue 2022-04-26 09:22 -0700, Luis Chamberlain wrote:
> I'd rather see the effort than not, given all the effort to already split things.
> I think it keeps things pretty tidy and it can scale / and its easier to review.

Fair enough. I'll create another iteration of the series.