linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] openvswitch: check for null pointer return from nla_nest_start_noflag
@ 2019-05-01 13:41 Colin King
  2019-05-01 17:17 ` [ovs-dev] " Yi-Hung Wei
  2019-05-05  7:52 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2019-05-01 13:41 UTC (permalink / raw)
  To: Pravin B Shelar, David S . Miller, netdev, dev
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

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")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 net/openvswitch/conntrack.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index c4128082f88b..333ec5f298fe 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -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(
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [ovs-dev] [PATCH][next] openvswitch: check for null pointer return from nla_nest_start_noflag
  2019-05-01 13:41 [PATCH][next] openvswitch: check for null pointer return from nla_nest_start_noflag Colin King
@ 2019-05-01 17:17 ` Yi-Hung Wei
  2019-05-05  7:52 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Yi-Hung Wei @ 2019-05-01 17:17 UTC (permalink / raw)
  To: Colin King
  Cc: Pravin B Shelar, David S . Miller,
	Linux Kernel Network Developers, ovs dev, kernel-janitors,
	linux-kernel

On Wed, May 1, 2019 at 6:42 AM Colin King <colin.king@canonical.com> wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> 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")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  net/openvswitch/conntrack.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
> index c4128082f88b..333ec5f298fe 100644
> --- a/net/openvswitch/conntrack.c
> +++ b/net/openvswitch/conntrack.c
> @@ -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(
> --
Thanks for the bug fix.  Should it be on net rather than net-next?

Acked-by: Yi-Hung Wei <yihung.wei@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] openvswitch: check for null pointer return from nla_nest_start_noflag
  2019-05-01 13:41 [PATCH][next] openvswitch: check for null pointer return from nla_nest_start_noflag Colin King
  2019-05-01 17:17 ` [ovs-dev] " Yi-Hung Wei
@ 2019-05-05  7:52 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-05-05  7:52 UTC (permalink / raw)
  To: colin.king; +Cc: pshelar, netdev, dev, kernel-janitors, linux-kernel

From: Colin King <colin.king@canonical.com>
Date: Wed,  1 May 2019 14:41:58 +0100

> From: Colin Ian King <colin.king@canonical.com>
> 
> 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")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied, thank you.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-05  7:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-01 13:41 [PATCH][next] openvswitch: check for null pointer return from nla_nest_start_noflag Colin King
2019-05-01 17:17 ` [ovs-dev] " Yi-Hung Wei
2019-05-05  7:52 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).