[ovs-dev] [PATCH] odp-util: Initialize nsh_hdr in odp_nsh_hdr_from_attr

Yifeng Sun pkusunyifeng at gmail.com
Thu Oct 18 21:10:49 UTC 2018


For function odp_nsh_hdr_from_attr, paramemter `attr` may not contain
all necessary OVS_NSH_KEY_ATTR_ to fully initialize data of nsh_hdr.
On return, nsh_hdr can contain uninitialized values in its fields.

This patch zeroes out nsh_hdr in the beginning in order to prevent it.

Reported-by: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10863
Signed-off-by: Yifeng Sun <pkusunyifeng at gmail.com>
---
 lib/odp-util.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/odp-util.c b/lib/odp-util.c
index d156fa7265de..1a52f3bc5ad9 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -2559,6 +2559,8 @@ odp_nsh_hdr_from_attr(const struct nlattr *attr,
     bool has_md1 = false;
     bool has_md2 = false;
 
+    memset(nsh_hdr, 0, size);
+
     NL_NESTED_FOR_EACH (a, left, attr) {
         uint16_t type = nl_attr_type(a);
         size_t len = nl_attr_get_size(a);
-- 
2.7.4



More information about the dev mailing list