ofproto-dpif-upcall: Fix additional use-after-free in revalidate().
authorBen Pfaff <blp@nicira.com>
Wed, 21 May 2014 23:26:55 +0000 (16:26 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 22 May 2014 04:04:14 +0000 (21:04 -0700)
commit11937351e0497c31c4fded153474d5ebcf3ff33e
treeb28a13926f6f26c9862c24ad2563c6ba756c0230
parentc943a3ea752ffe39cfbd34783bb123b1e860c356
ofproto-dpif-upcall: Fix additional use-after-free in revalidate().

Commit 1340ce0c175 (ofproto-dpif-upcall: Avoid use-after-free in
revalidate() corner cases.) fixed one use-after-free error in revalidate(),
but missed one more subtle case, in which dpif_linux_flow_dump_next()
attempts to retrieve actions for a flow that didn't have them in the main
dump result.  If retrieving those actions fails,
dpif_linux_flow_dump_next() goes on to the next flow, and as part of that
overwrites the old dumped flows in its buffer.  This is a problem because
dpif_linux_flow_dump_next_may_destroy_keys() would have indicated that
the old dumped flows would not have been destroyed, which means that the
data the caller relied on has gone away.  In the worst case, this causes
a segfault and core dump.

The best way to fix this problem is the refactoring that has already
happened on master in commit ac64794acb85 (dpif: Refactor flow dumping
interface to make better sense for batching.)  That is a fairly large
change, and not yet well-tested, so it doesn't yet seem suitable for a
stable branch.  For now, this commit refines the conditions that
dpif_linux_flow_dump_next_may_destroy_keys() uses, so that if the next
flow does not include actions it indicates that keys may be destroyed.

Thanks to Joe Stringer for suggesting this particular solution.

Bug #1249988.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Joe Stringer <joestringer@nicira.com>
lib/dpif-linux.c
lib/netlink-socket.c
lib/netlink-socket.h