Re: [PATCH RESEND v4 1/4] kernfs: make ->attr.open RCU protected.

From: Tejun Heo
Date: Sun Jun 12 2022 - 22:47:02 EST


Hello,

On Mon, Jun 13, 2022 at 12:36:12PM +1000, Imran Khan wrote:
> >> +static struct kernfs_open_node *
> >> +kernfs_check_open_node_protected(struct kernfs_node *kn)
> >> +{
> >> + return rcu_dereference_check(kn->attr.open,
> >> + lockdep_is_held(&kernfs_open_file_mutex));
> >> +}
> >
> > I don't understand why the above is necessary. Whether you're a reader or
> > writer, you can deref the pointer w/ _protected as long as you're holding
> > the lock, right?
>
> As per [1], we should use rcu_dereference_check() for the reader side when we
> are holding the lock.

Hmm.... can you quote the exact phrase that you took the above from?

Thanks.

--
tejun