# Re: \[PATCH 04/13\] module: use RCU to synchronize find\_module

- List: live-patching
- 1 message, 1 author
- Page: https://ratatoskr.run/live-patching/2021/02/6253567/t

## Re: \[PATCH 04/13\] module: use RCU to synchronize find\_module

- From: Christoph Hellwig \<hch@lst.de\>
- Date: 2021-02-01 11:47:52 
- Message: https://ratatoskr.run/live-patching/2021/02/6253567.md

```text
On Fri, Jan 29, 2021 at 04:29:02PM +0100, Miroslav Benes wrote:
> >  
> > -	mutex_lock(&module_mutex);
> > +	rcu_read_lock_sched();
> >  	/*
> >  	 * We do not want to block removal of patched modules and therefore
> >  	 * we do not take a reference here. The patches are removed by
> > @@ -74,7 +75,7 @@ static void klp_find_object_module(struct klp_object *obj)
> >  	if (mod && mod->klp_alive)
> 
> RCU always baffles me a bit, so I'll ask. Don't we need 
> rcu_dereference_sched() here? "mod" comes from a RCU-protected list, so I 
> wonder.

rcu_dereference* is only used for dereferencing points where that
reference itself is RCU protected, that is the lookup of mod itself down
in find_module_all in this case.
```
