]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
rcu: Do a single rhp->func read in rcu_head_after_call_rcu()
authorNeeraj Upadhyay <neeraju@codeaurora.org>
Mon, 11 Mar 2019 11:58:03 +0000 (17:28 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 31 May 2019 13:45:16 +0000 (06:45 -0700)
commit65137246ffc3a1989997061b4d8d7d99e059859e
tree7c203f89dac14e0b3b7ebb6e98f7751455f7dd31
parentd2872983d8a19205d76842035a472e086ca17e56
rcu: Do a single rhp->func read in rcu_head_after_call_rcu()

[ Upstream commit b699cce1604e828f19c39845252626eb78cdf38a ]

The rcu_head_after_call_rcu() function reads the rhp->func pointer twice,
which can result in a false-positive WARN_ON_ONCE() if the callback
were passed to call_rcu() between the two reads.  Although racing
rcu_head_after_call_rcu() with call_rcu() is to be a dubious use case
(the return value is not reliable in that case), intermittent and
irreproducible warnings are also quite dubious.  This commit therefore
uses a single READ_ONCE() to pick up the value of rhp->func once, then
tests that value twice, thus guaranteeing consistent processing within
rcu_head_after_call_rcu()().

Neverthless, racing rcu_head_after_call_rcu() with call_rcu() is still
a dubious use case.

Signed-off-by: Neeraj Upadhyay <neeraju@codeaurora.org>
[ paulmck: Add blank line after declaration per checkpatch.pl. ]
Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/rcupdate.h