datapath: Avoid accesses past the end of skbuff data in actions.
authorBen Pfaff <blp@nicira.com>
Fri, 13 Aug 2010 17:46:12 +0000 (10:46 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 27 Aug 2010 19:42:39 +0000 (12:42 -0700)
commitca78c6b69c01508713b8a8e50065843fcaf53936
tree9bce578df5251bd94b3eb625dc89e03d35bda9bb
parent59a18f80dd0732dbe09231ff9001c54b3a5fca16
datapath: Avoid accesses past the end of skbuff data in actions.

Some of the flow actions that modify skbuff data did not check that the
skbuff was long enough before doing so.  This commit fixes that problem.

Previously, the strategy for avoiding this was to only indicate the layer-3
nw_proto field in the flow if the corresponding layer-4 header was fully
present, so that if, for example, nw_proto was IPPROTO_TCP, this meant
that a TCP header was present.  The original motivation for this patch was
to add corresponding code to only indicate a layer-2 dl_type if the
corresponding layer-3 header was fully present.  But I'm now convinced that
this approach is conceptually wrong, because the meaning of a layer-N
header should not be affected by the meaning of a layer-(N+1) header.

This commit switches to a new approach.  Now, when a header is missing, its
fields in the flow are simply zeroed and have no effect on the "type" field
for the outer header.  Responsibility for ensuring that a header is fully
present is now shifted to the actions that wish to modify that header.

Signed-off-by: Ben Pfaff <blp@nicira.com>
datapath/actions.c
datapath/flow.c
lib/dpif-netdev.c
lib/flow.c