Skip to contentSkip to conversation

openvswitch: check for null pointer return from nla_nest_start_noflag

PATCH Applied Colin King 3 participants 3 messages May 1, 2019 – May 5, 2019

Subsystems (4)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 openvswitch: check for null pointer return from nla_nest_start_noflag

From: Colin Ian King <[email protected]>

The call to nla_nest_start_noflag can return null in the unlikely event that nla_put returns -EMSGSIZE. Check for this condition to avoid a null pointer dereference on pointer nla_reply.

Addresses-Coverity: ("Dereference null return value")

Fixes 11efd5cb04a1 ("openvswitch: Support conntrack zone limit")
---
 net/openvswitch/conntrack.c | 4 ++++
 1 file changed, 4 insertions(+)
net/openvswitch/conntrack.c +4 -0
index c4128082f88b..333ec5f298fe 100644
@@ -2175,6 +2175,10 @@ static int ovs_ct_limit_cmd_get(struct sk_buff *skb, struct genl_info *info)
 		return PTR_ERR(reply);
 
 	nla_reply = nla_nest_start_noflag(reply, OVS_CT_LIMIT_ATTR_ZONE_LIMIT);
+	if (!nla_reply) {
+		err = -EMSGSIZE;
+		goto exit_err;
+	}
 
 	if (a[OVS_CT_LIMIT_ATTR_ZONE_LIMIT]) {
 		err = ovs_ct_limit_get_zone_limit(
Signature · 1 line
2.20.1
Acked-by on v1 1/1
#1 lore raw
Quoted 20 lines · Colin King

From: Colin Ian King <[email protected]>

The call to nla_nest_start_noflag can return null in the unlikely event that nla_put returns -EMSGSIZE. Check for this condition to avoid a null pointer dereference on pointer nla_reply.

Addresses-Coverity: ("Dereference null return value")

Fixes 11efd5cb04a1 ("openvswitch: Support conntrack zone limit")
---
 net/openvswitch/conntrack.c | 4 ++++
 1 file changed, 4 insertions(+)
net/openvswitch/conntrack.c +0 -0
index c4128082f88b..333ec5f298fe 100644
@@ -2175,6 +2175,10 @@ static int ovs_ct_limit_cmd_get(struct sk_buff *skb, struct genl_info *info)
                return PTR_ERR(reply);

net/openvswitch/conntrack.c static int ovs_ct_limit_cmd_get(struct sk_buff *skb, struct genl_info *info)

Quoted 10 lines
net/openvswitch/conntrack.c +4 -1
 
        nla_reply = nla_nest_start_noflag(reply, OVS_CT_LIMIT_ATTR_ZONE_LIMIT);
+       if (!nla_reply) {
+               err = -EMSGSIZE;
+               goto exit_err;
+       }
 
        if (a[OVS_CT_LIMIT_ATTR_ZONE_LIMIT]) {
                err = ovs_ct_limit_get_zone_limit(
--

Thanks for the bug fix. Should it be on net rather than net-next?

maintainer Applied
#2 lore raw
In reply to Colin King

From: Colin King <[email protected]>
Date: Wed, 1 May 2019 14:41:58 +0100

Quoted 9 lines

From: Colin Ian King <[email protected]>

The call to nla_nest_start_noflag can return null in the unlikely event that nla_put returns -EMSGSIZE. Check for this condition to avoid a null pointer dereference on pointer nla_reply.

Addresses-Coverity: ("Dereference null return value")

Fixes 11efd5cb04a1 ("openvswitch: Support conntrack zone limit")

Applied, thank you.