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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20221227195659.2876-1-sj@kernel.org>
Date:   Tue, 27 Dec 2022 19:56:59 +0000
From:   SeongJae Park <sj@...nel.org>
To:     Matthew Wilcox <willy@...radead.org>
Cc:     SeongJae Park <sj@...nel.org>, akpm@...ux-foundation.org,
        alexander.h.duyck@...ux.intel.com, paulmck@...nel.org,
        linux-mm@...ck.org, rcu@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/page_reporting: replace rcu_access_pointer() with rcu_dereference_protected()

On Tue, 27 Dec 2022 19:55:09 +0000 Matthew Wilcox <willy@...radead.org> wrote:

> On Tue, Dec 27, 2022 at 07:21:58PM +0000, SeongJae Park wrote:
> > +++ b/mm/page_reporting.c
> > @@ -356,7 +356,7 @@ int page_reporting_register(struct page_reporting_dev_info *prdev)
> >  	mutex_lock(&page_reporting_mutex);
> >  
> >  	/* nothing to do if already in use */
> > -	if (rcu_access_pointer(pr_dev_info)) {
> > +	if (rcu_dereference_protected(pr_dev_info, true)) {
> 
> Pretty sure that passing a bare 'true' is an antipattern.
> Instead, document _what_ lock protects us, ie:
> 
> 	if (rcu_dereference_protected(pr_dev_info,
> 				      lockdep_is_held(&page_reporting_mutex))) {
> 
> Obviously, we took it just one line up, but if code moves around, it
> may save us.

Good point, agreed.  Will do so in the next version.


Thanks,
SJ

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ