summaryrefslogtreecommitdiffstats
path: root/kernel/rcu
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2017-12-08 13:48:41 -0500
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2018-02-20 19:21:56 -0500
commiteb0339934f1d468ff09d9be1c608c89cb1da850b (patch)
tree1ee5394b2d8046eccd2165a853ee1ff5a5338965 /kernel/rcu
parente0d31a34c6db6381bfc630a9ee93f05b9447dcc3 (diff)
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: Lihao Liang <lianglihao@huawei.com> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Diffstat (limited to 'kernel/rcu')
-rw-r--r--kernel/rcu/rcutorture.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 0f94025c672a..6c46cd1d8fd7 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -1045,13 +1045,13 @@ rcu_torture_fakewriter(void *arg)
1045 torture_random(&rand) % (nfakewriters * 8) == 0) { 1045 torture_random(&rand) % (nfakewriters * 8) == 0) {
1046 cur_ops->cb_barrier(); 1046 cur_ops->cb_barrier();
1047 } else if (gp_normal == gp_exp) { 1047 } else if (gp_normal == gp_exp) {
1048 if (torture_random(&rand) & 0x80) 1048 if (cur_ops->sync && torture_random(&rand) & 0x80)
1049 cur_ops->sync(); 1049 cur_ops->sync();
1050 else 1050 else if (cur_ops->exp_sync)
1051 cur_ops->exp_sync(); 1051 cur_ops->exp_sync();
1052 } else if (gp_normal) { 1052 } else if (gp_normal && cur_ops->sync) {
1053 cur_ops->sync(); 1053 cur_ops->sync();
1054 } else { 1054 } else if (cur_ops->exp_sync) {
1055 cur_ops->exp_sync(); 1055 cur_ops->exp_sync();
1056 } 1056 }
1057 stutter_wait("rcu_torture_fakewriter"); 1057 stutter_wait("rcu_torture_fakewriter");