All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tim Yi <tim.yi@pica8.com>
To: nikolay@nvidia.com
Cc: roopa@nvidia.com, davem@davemloft.net, kuba@kernel.org,
	bridge@lists.linux-foundation.org, netdev@vger.kernel.org,
	Tim Yi <tim.yi@pica8.com>
Subject: [PATCH] net: bridge: vlan: fix memory leak in __allowed_ingress
Date: Thu, 27 Jan 2022 15:49:53 +0800	[thread overview]
Message-ID: <20220127074953.12632-1-tim.yi@pica8.com> (raw)

When using per-vlan state, if vlan snooping and stats are disabled,
untagged or priority-tagged ingress frame will go to check pvid state.
If the port state is forwarding and the pvid state is not
learning/forwarding, untagged or priority-tagged frame will be dropped
but skb memory is not freed.
Should free skb when __allowed_ingress returns false.

Signed-off-by: Tim Yi <tim.yi@pica8.com>
---
 net/bridge/br_vlan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index 84ba456a78cc..88c4297cddee 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -560,10 +560,10 @@ static bool __allowed_ingress(const struct net_bridge *br,
 		    !br_opt_get(br, BROPT_VLAN_STATS_ENABLED)) {
 			if (*state == BR_STATE_FORWARDING) {
 				*state = br_vlan_get_pvid_state(vg);
-				return br_vlan_state_allowed(*state, true);
-			} else {
-				return true;
+				if (!br_vlan_state_allowed(*state, true))
+					goto drop;
 			}
+			return true;
 		}
 	}
 	v = br_vlan_find(vg, *vid);
-- 
2.28.0.618.g9bc233ae1c


WARNING: multiple messages have this Message-ID (diff)
From: Tim Yi <tim.yi@pica8.com>
To: nikolay@nvidia.com
Cc: Tim Yi <tim.yi@pica8.com>,
	netdev@vger.kernel.org, bridge@lists.linux-foundation.org,
	roopa@nvidia.com, kuba@kernel.org, davem@davemloft.net
Subject: [Bridge] [PATCH] net: bridge: vlan: fix memory leak in __allowed_ingress
Date: Thu, 27 Jan 2022 15:49:53 +0800	[thread overview]
Message-ID: <20220127074953.12632-1-tim.yi@pica8.com> (raw)

When using per-vlan state, if vlan snooping and stats are disabled,
untagged or priority-tagged ingress frame will go to check pvid state.
If the port state is forwarding and the pvid state is not
learning/forwarding, untagged or priority-tagged frame will be dropped
but skb memory is not freed.
Should free skb when __allowed_ingress returns false.

Signed-off-by: Tim Yi <tim.yi@pica8.com>
---
 net/bridge/br_vlan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index 84ba456a78cc..88c4297cddee 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -560,10 +560,10 @@ static bool __allowed_ingress(const struct net_bridge *br,
 		    !br_opt_get(br, BROPT_VLAN_STATS_ENABLED)) {
 			if (*state == BR_STATE_FORWARDING) {
 				*state = br_vlan_get_pvid_state(vg);
-				return br_vlan_state_allowed(*state, true);
-			} else {
-				return true;
+				if (!br_vlan_state_allowed(*state, true))
+					goto drop;
 			}
+			return true;
 		}
 	}
 	v = br_vlan_find(vg, *vid);
-- 
2.28.0.618.g9bc233ae1c


             reply	other threads:[~2022-01-27  7:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-27  7:49 Tim Yi [this message]
2022-01-27  7:49 ` [Bridge] [PATCH] net: bridge: vlan: fix memory leak in __allowed_ingress Tim Yi
2022-01-27  8:03 ` Nikolay Aleksandrov
2022-01-27  8:03   ` [Bridge] " Nikolay Aleksandrov
2022-01-27 17:10 ` patchwork-bot+netdevbpf
2022-01-27 17:10   ` [Bridge] " patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220127074953.12632-1-tim.yi@pica8.com \
    --to=tim.yi@pica8.com \
    --cc=bridge@lists.linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@nvidia.com \
    --cc=roopa@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.