lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 13 Jun 2022 12:55:14 +1000
From:   Imran Khan <imran.f.khan@...cle.com>
To:     Tejun Heo <tj@...nel.org>
Cc:     viro@...iv.linux.org.uk, gregkh@...uxfoundation.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH RESEND v4 1/4] kernfs: make ->attr.open RCU protected.

Hello Tejun,

On 13/6/22 12:46 pm, Tejun Heo wrote:
> 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?
> 
I took below phrases as reference:

If the access might be within an RCU read-side critical section on the one hand,
or protected by (say) my_lock on the other, use rcu_dereference_check(), for
example:

p1 = rcu_dereference_check(p->rcu_protected_pointer,
                           lockdep_is_held(&my_lock));


and


If the access might be within an RCU read-side critical section on the one hand,
or protected by either my_lock or your_lock on the other, again use
rcu_dereference_check(), for example:

p1 = rcu_dereference_check(p->rcu_protected_pointer,
                           lockdep_is_held(&my_lock) ||
                           lockdep_is_held(&your_lock));


Thanks,
 -- Imran

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ