classifier: Fix race condition leading to NULL dereference.
authorJarno Rajahalme <jarno@ovn.org>
Sun, 17 Apr 2016 15:51:21 +0000 (08:51 -0700)
committerJarno Rajahalme <jarno@ovn.org>
Sun, 17 Apr 2016 15:51:21 +0000 (08:51 -0700)
commit5e27fe9781132d50cc5af88b1d98e15c3c033b91
treeaca7487d0185265466eaaeee2a6f475d93450f0d
parent8ff5a966b8a59f61928fba9e7d3a3d227609949f
classifier: Fix race condition leading to NULL dereference.

Addition of table versioning exposed struct cls_rule member
'cls_match' to RCU readers and made it possible for 'cls_match' become
NULL while being accessed by an RCU reader, but we failed to check for
this condition.  This may have resulted in NULL pointer dereference
and ovs-vswitchd crash.

Fix this by making the 'cls_match' member an RCU pointer and checking
the value whenever it potentially read by an RCU reader.  In these
instances we use ovsrcu_get(), whereas functions accessible only by
the exclusive writers use ovsrcu_get_protected() and do not need to
check the result.

VMware-BZ: 1643642
Fixes: 2b7b1427 ("classifier: Support table versioning")
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
lib/classifier-private.h
lib/classifier.c
lib/classifier.h
tests/test-classifier.c