linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] openvswitch: fix send of uninitialized stack memory in ct limit reply
@ 2021-04-04 17:50 Ilya Maximets
  2021-04-04 18:01 ` Ilya Maximets
  2021-04-05 22:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Ilya Maximets @ 2021-04-04 17:50 UTC (permalink / raw)
  To: Pravin B Shelar
  Cc: David S. Miller, Jakub Kicinski, Yi-Hung Wei, netdev,
	linux-kernel, Ilya Maximets

'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>
---
 net/openvswitch/conntrack.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index c29b0ef1fc27..cadb6a29b285 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -2032,10 +2032,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);
 }
-- 
2.26.2


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

* Re: [PATCH net] openvswitch: fix send of uninitialized stack memory in ct limit reply
  2021-04-04 17:50 [PATCH net] openvswitch: fix send of uninitialized stack memory in ct limit reply Ilya Maximets
@ 2021-04-04 18:01 ` Ilya Maximets
  2021-04-05  3:09   ` [ovs-dev] " Tonghao Zhang
  2021-04-05 22:10 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 4+ messages in thread
From: Ilya Maximets @ 2021-04-04 18:01 UTC (permalink / raw)
  To: Ilya Maximets, Pravin B Shelar
  Cc: David S. Miller, Jakub Kicinski, Yi-Hung Wei, netdev,
	linux-kernel, ovs dev

CC: ovs-dev

On 4/4/21 7:50 PM, Ilya Maximets wrote:
> '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>
> ---
>  net/openvswitch/conntrack.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
> index c29b0ef1fc27..cadb6a29b285 100644
> --- a/net/openvswitch/conntrack.c
> +++ b/net/openvswitch/conntrack.c
> @@ -2032,10 +2032,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);
>  }
> 


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

* Re: [ovs-dev] [PATCH net] openvswitch: fix send of uninitialized stack memory in ct limit reply
  2021-04-04 18:01 ` Ilya Maximets
@ 2021-04-05  3:09   ` Tonghao Zhang
  0 siblings, 0 replies; 4+ messages in thread
From: Tonghao Zhang @ 2021-04-05  3:09 UTC (permalink / raw)
  To: Ilya Maximets
  Cc: Pravin B Shelar, ovs dev, Linux Kernel Network Developers, LKML,
	Jakub Kicinski, David S. Miller

On Mon, Apr 5, 2021 at 2:01 AM Ilya Maximets <i.maximets@ovn.org> wrote:
>
> CC: ovs-dev
>
> On 4/4/21 7:50 PM, Ilya Maximets wrote:
> > '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>
> > ---
> >  net/openvswitch/conntrack.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
> > index c29b0ef1fc27..cadb6a29b285 100644
> > --- a/net/openvswitch/conntrack.c
> > +++ b/net/openvswitch/conntrack.c
> > @@ -2032,10 +2032,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,
> > +     };
I review the code, userspace don't use the count of ovs_zone_lime
struct, but this patch looks to to me.
Thanks Ilya.
Acked-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> >       return nla_put_nohdr(reply, sizeof(zone_limit), &zone_limit);
> >  }
> >
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev



-- 
Best regards, Tonghao

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

* Re: [PATCH net] openvswitch: fix send of uninitialized stack memory in ct limit reply
  2021-04-04 17:50 [PATCH net] openvswitch: fix send of uninitialized stack memory in ct limit reply Ilya Maximets
  2021-04-04 18:01 ` Ilya Maximets
@ 2021-04-05 22:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-04-05 22:10 UTC (permalink / raw)
  To: Ilya Maximets; +Cc: pshelar, davem, kuba, yihung.wei, netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Sun,  4 Apr 2021 19:50:31 +0200 you wrote:
> '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.
> 
> [...]

Here is the summary with links:
  - [net] openvswitch: fix send of uninitialized stack memory in ct limit reply
    https://git.kernel.org/netdev/net/c/4d51419d4993

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-04-05 22:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-04 17:50 [PATCH net] openvswitch: fix send of uninitialized stack memory in ct limit reply Ilya Maximets
2021-04-04 18:01 ` Ilya Maximets
2021-04-05  3:09   ` [ovs-dev] " Tonghao Zhang
2021-04-05 22:10 ` patchwork-bot+netdevbpf

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).