]> git.baikalelectronics.ru Git - kernel.git/commitdiff
openvswitch: fix send of uninitialized stack memory in ct limit reply
authorIlya Maximets <i.maximets@ovn.org>
Sun, 4 Apr 2021 17:50:31 +0000 (19:50 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 5 Apr 2021 19:54:42 +0000 (12:54 -0700)
'struct ovs_zone_limit' has more members than initialized in
ovs_ct_limit_get_default_limit().  The rest of the memory is a random
kernel stack content that ends up being sent to userspace.

Fix that by using designated initializer that will clear all
non-specified fields.

Fixes: 11efd5cb04a1 ("openvswitch: Support conntrack zone limit")
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/openvswitch/conntrack.c

index 71cec03e861249209c1cb3f20ca09be2f300091b..d217bd91176b612b9b155b5ad4598fe0c40f344b 100644 (file)
@@ -2034,10 +2034,10 @@ static int ovs_ct_limit_del_zone_limit(struct nlattr *nla_zone_limit,
 static int ovs_ct_limit_get_default_limit(struct ovs_ct_limit_info *info,
                                          struct sk_buff *reply)
 {
-       struct ovs_zone_limit zone_limit;
-
-       zone_limit.zone_id = OVS_ZONE_LIMIT_DEFAULT_ZONE;
-       zone_limit.limit = info->default_limit;
+       struct ovs_zone_limit zone_limit = {
+               .zone_id = OVS_ZONE_LIMIT_DEFAULT_ZONE,
+               .limit   = info->default_limit,
+       };
 
        return nla_put_nohdr(reply, sizeof(zone_limit), &zone_limit);
 }