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]
Message-ID: <E9D67C85-37FD-4BA7-990D-2BA2ED7E5963@nvidia.com>
Date: Wed, 26 Mar 2025 22:50:13 +0000
From: Joel Fernandes <joelagnelf@...dia.com>
To: "paulmck@...nel.org" <paulmck@...nel.org>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, Frederic
 Weisbecker <frederic@...nel.org>, Neeraj Upadhyay
	<neeraj.upadhyay@...nel.org>, Joel Fernandes <joel@...lfernandes.org>, Josh
 Triplett <josh@...htriplett.org>, Boqun Feng <boqun.feng@...il.com>,
	Uladzislau Rezki <urezki@...il.com>, Steven Rostedt <rostedt@...dmis.org>,
	Mathieu Desnoyers <mathieu.desnoyers@...icios.com>, Lai Jiangshan
	<jiangshanlai@...il.com>, Zqiang <qiang.zhang1211@...il.com>,
	"rcu@...r.kernel.org" <rcu@...r.kernel.org>
Subject: Re: [PATCH 2/3] rcu: Add warning to ensure rcu_seq_done_exact() is
 working



> On Mar 26, 2025, at 6:36 PM, Paul E. McKenney <paulmck@...nel.org> wrote:
> 
> On Mon, Mar 24, 2025 at 01:01:54PM -0400, Joel Fernandes wrote:
>> The previous patch improved the rcu_seq_done_exact() function by adding
>> a meaningful constant for the guardband.
>> 
>> Ensure that this is working for the future by a quick check during
>> rcu_gp_init().
>> 
>> Signed-off-by: Joel Fernandes <joelagnelf@...dia.com>
> 
> This is a good test for the guardband being way too short.

Thanks. Let me know if I could add your review tag!

> 
> Are there other tests the should be run, possibly on a separate gp_seq
> used only for testing?  Should the test below be under CONFIG_PROVE_RCU?

Yes, I could move it to PROVE RCU and it should be sufficient for testing.

The other test I was working on is to force the counter wrapping and hence gpwrap which is related. 

Maybe we could also some testing around false negatives not happening too often (for examples with the rcu_seq_done()).

I will add more tests if I come across usecases.

Thanks!

Joel

> 
>                            Thanx, Paul
> 
>> ---
>> kernel/rcu/tree.c | 5 +++++
>> 1 file changed, 5 insertions(+)
>> 
>> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
>> index 659f83e71048..29ddbcbea25e 100644
>> --- a/kernel/rcu/tree.c
>> +++ b/kernel/rcu/tree.c
>> @@ -1798,6 +1798,7 @@ static noinline_for_stack bool rcu_gp_init(void)
>>    struct rcu_data *rdp;
>>    struct rcu_node *rnp = rcu_get_root();
>>    bool start_new_poll;
>> +    unsigned long old_gp_seq;
>> 
>>    WRITE_ONCE(rcu_state.gp_activity, jiffies);
>>    raw_spin_lock_irq_rcu_node(rnp);
>> @@ -1825,7 +1826,11 @@ static noinline_for_stack bool rcu_gp_init(void)
>>     */
>>    start_new_poll = rcu_sr_normal_gp_init();
>>    /* Record GP times before starting GP, hence rcu_seq_start(). */
>> +    old_gp_seq = rcu_state.gp_seq;
>>    rcu_seq_start(&rcu_state.gp_seq);
>> +    /* Ensure that rcu_seq_done_exact() guardband doesn't give false positives. */
>> +    WARN_ON_ONCE(rcu_seq_done_exact(&old_gp_seq, rcu_seq_snap(&rcu_state.gp_seq)));
>> +
>>    ASSERT_EXCLUSIVE_WRITER(rcu_state.gp_seq);
>>    trace_rcu_grace_period(rcu_state.name, rcu_state.gp_seq, TPS("start"));
>>    rcu_poll_gp_seq_start(&rcu_state.gp_seq_polled_snap);
>> --
>> 2.43.0
>> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ