diff options
author | Ben Pfaff <blp@ovn.org> | 2017-12-04 11:51:43 -0800 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2017-12-22 11:22:21 -0800 |
commit | 692086c5a2570b1ee2a5978969ee49ec38eb2e6a (patch) | |
tree | e7046e4d1d539defe517925ee35e8897d2bd5fbe | |
parent | 8523fe9e412dfe07bb0d365eab77042ff54e85b0 (diff) | |
download | openvswitch-692086c5a2570b1ee2a5978969ee49ec38eb2e6a.tar.gz |
odp-util: Use flexible sized buffer to hold Geneve options.
The 'mask' buffer in parse_odp_action() is supposed to always be big
enough:
/* 'mask' is big enough to hold any key. */
Geneve options can be really big and the comment was wrong. In addition,
the user might supply more options than can really fit in any case, so
we might as well just use a stub.
Found by libfuzzer.
Reported-by: Bhargava Shastry <bshastry@sec.t-labs.tu-berlin.de>
Signed-off-by: Ben Pfaff <blp@ovn.org>
-rw-r--r-- | lib/odp-util.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/odp-util.c b/lib/odp-util.c index 4cd74fd2d..e601c83fe 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -1228,20 +1228,19 @@ parse_odp_action(const char *s, const struct simap *port_names, if (!strncmp(s, "set(", 4)) { size_t start_ofs; int retval; - struct nlattr mask[128 / sizeof(struct nlattr)]; - struct ofpbuf maskbuf; + struct nlattr mask[1024 / sizeof(struct nlattr)]; + struct ofpbuf maskbuf = OFPBUF_STUB_INITIALIZER(mask); struct nlattr *nested, *key; size_t size; - /* 'mask' is big enough to hold any key. */ - ofpbuf_use_stack(&maskbuf, mask, sizeof mask); - start_ofs = nl_msg_start_nested(actions, OVS_ACTION_ATTR_SET); retval = parse_odp_key_mask_attr(s + 4, port_names, actions, &maskbuf); if (retval < 0) { + ofpbuf_uninit(&maskbuf); return retval; } if (s[retval + 4] != ')') { + ofpbuf_uninit(&maskbuf); return -EINVAL; } @@ -1259,6 +1258,7 @@ parse_odp_action(const char *s, const struct simap *port_names, nested->nla_type = OVS_ACTION_ATTR_SET_MASKED; } } + ofpbuf_uninit(&maskbuf); nl_msg_end_nested(actions, start_ofs); return retval + 5; |