Commit eb033993 authored by Paul E. McKenney's avatar Paul E. McKenney

rcutorture: Avoid fake-writer use of undefined primitives

Currently the rcu_torture_fakewriter() function invokes cur_ops->sync()
and cur_ops->exp_sync() without first checking to see if they are in
fact non-NULL.  This results in kernel NULL pointer dereferences when
testing RCU implementations that choose not to provide the full set of
primitives.  Given that it is perfectly reasonable to have specialized
RCU implementations that provide only a subset of the RCU API, this is
a bug in rcutorture.

This commit therefore makes rcu_torture_fakewriter() check function
pointers before invoking them, thus allowing it to test subsetted
RCU implementations.
Reported-by: default avatarLihao Liang <lianglihao@huawei.com>
Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
parent e0d31a34
...@@ -1045,13 +1045,13 @@ rcu_torture_fakewriter(void *arg) ...@@ -1045,13 +1045,13 @@ rcu_torture_fakewriter(void *arg)
torture_random(&rand) % (nfakewriters * 8) == 0) { torture_random(&rand) % (nfakewriters * 8) == 0) {
cur_ops->cb_barrier(); cur_ops->cb_barrier();
} else if (gp_normal == gp_exp) { } else if (gp_normal == gp_exp) {
if (torture_random(&rand) & 0x80) if (cur_ops->sync && torture_random(&rand) & 0x80)
cur_ops->sync(); cur_ops->sync();
else else if (cur_ops->exp_sync)
cur_ops->exp_sync(); cur_ops->exp_sync();
} else if (gp_normal) { } else if (gp_normal && cur_ops->sync) {
cur_ops->sync(); cur_ops->sync();
} else { } else if (cur_ops->exp_sync) {
cur_ops->exp_sync(); cur_ops->exp_sync();
} }
stutter_wait("rcu_torture_fakewriter"); stutter_wait("rcu_torture_fakewriter");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment