Skip to contentSkip to conversation

fix NULL pointer dereference in br_handle_frame

PATCH In review Hong Zhiguo 5 participants 17 messages Sep 12, 2013 – Sep 13, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix NULL pointer dereference in br_handle_frame

From: Hong Zhiguo <[email protected]>

In function netdev_rx_handler_unregister it's said that:

/* a reader seeing a non NULL rx_handler in a rcu_read_lock()
* section has a guarantee to see a non NULL rx_handler_data
* as well.
*/

This is true. But br_port_get_rcu(dev) returns NULL if:

	!(dev->priv_flags & IFF_BRIDGE_PORT)

And this happended on my box when br_handle_frame is called between these 2 lines of del_nbp:

	dev->priv_flags &= ~IFF_BRIDGE_PORT;
	/* --> br_handle_frame is called at this time */
	netdev_upper_dev_unlink(dev, br->dev);

I got below Oops(some lines omitted):

BUG: unable to handle kernel NULL pointer dereference at 0000000000000021
IP: [<ffffffff8150901d>] br_handle_frame+0xed/0x230
Oops: 0000 [#1] PREEMPT SMP
RIP: 0010:[<ffffffff8150901d>]  [<ffffffff8150901d>] br_handle_frame+0xed/0x230
RSP: 0018:ffff880030403c10  EFLAGS: 00010286
Stack:
 ffff88002c945700 ffffffff81508f30 0000000000000000 ffff88002d41e000
 ffff880030403c98 ffffffff81477acb ffffffff81477821 ffff880030403c68
 ffffffff81090e10 00ff88002d545c80 ffff88002c945700 ffffffff81aa50c0
Call Trace:
 <IRQ>
 [<ffffffff81508f30>] ? br_handle_frame_finish+0x300/0x300
 [<ffffffff81477acb>] __netif_receive_skb_core+0x39b/0x880
---
 net/bridge/br_if.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/bridge/br_if.c +2 -2
index c41d5fb..bd21159 100644
@@ -133,6 +133,8 @@ static void del_nbp(struct net_bridge_port *p)
 
 	sysfs_remove_link(br->ifobj, p->dev->name);
 
+	netdev_rx_handler_unregister(dev);
+
 	dev_set_promiscuity(dev, -1);
 
 	spin_lock_bh(&br->lock);
@@ -148,8 +150,6 @@ static void del_nbp(struct net_bridge_port *p)
 
 	dev->priv_flags &= ~IFF_BRIDGE_PORT;
 
-	netdev_rx_handler_unregister(dev);
-
 	netdev_upper_dev_unlink(dev, br->dev);
 
 	br_multicast_del_port(p);
Signature · 1 line
1.8.1.2
#1 lore raw
Quoted 53 lines · Hong Zhiguo

From: Hong Zhiguo <[email protected]>

In function netdev_rx_handler_unregister it's said that:

/* a reader seeing a non NULL rx_handler in a rcu_read_lock()
* section has a guarantee to see a non NULL rx_handler_data
* as well.
*/

This is true. But br_port_get_rcu(dev) returns NULL if:

	!(dev->priv_flags & IFF_BRIDGE_PORT)

And this happended on my box when br_handle_frame is called between these 2 lines of del_nbp:

	dev->priv_flags &= ~IFF_BRIDGE_PORT;
	/* --> br_handle_frame is called at this time */
	netdev_upper_dev_unlink(dev, br->dev);

I got below Oops(some lines omitted):

BUG: unable to handle kernel NULL pointer dereference at 0000000000000021
IP: [<ffffffff8150901d>] br_handle_frame+0xed/0x230
Oops: 0000 [#1] PREEMPT SMP
RIP: 0010:[<ffffffff8150901d>]  [<ffffffff8150901d>] br_handle_frame+0xed/0x230
RSP: 0018:ffff880030403c10  EFLAGS: 00010286
Stack:
 ffff88002c945700 ffffffff81508f30 0000000000000000 ffff88002d41e000
 ffff880030403c98 ffffffff81477acb ffffffff81477821 ffff880030403c68
 ffffffff81090e10 00ff88002d545c80 ffff88002c945700 ffffffff81aa50c0
Call Trace:
 <IRQ>
 [<ffffffff81508f30>] ? br_handle_frame_finish+0x300/0x300
 [<ffffffff81477acb>] __netif_receive_skb_core+0x39b/0x880
---
 net/bridge/br_if.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/bridge/br_if.c +2 -0
index c41d5fb..bd21159 100644
@@ -133,6 +133,8 @@ static void del_nbp(struct net_bridge_port *p)
 
 	sysfs_remove_link(br->ifobj, p->dev->name);
 
+	netdev_rx_handler_unregister(dev);
+
 	dev_set_promiscuity(dev, -1);
 
 	spin_lock_bh(&br->lock);

net/bridge/br_if.c static void del_nbp(struct net_bridge_port *p) · line 155

Quoted 8 lines
net/bridge/br_if.c +0 -2
@@ -148,8 +150,6 @@ static void del_nbp(struct net_bridge_port *p)
 
 	dev->priv_flags &= ~IFF_BRIDGE_PORT;
 
-	netdev_rx_handler_unregister(dev);
-
 	netdev_upper_dev_unlink(dev, br->dev);
 
 	br_multicast_del_port(p);

Interesting.

Then br_handle_frame() should not even have to check IFF_BRIDGE_PORT flag.

net/bridge/br_input.c +1 -1
index a2fd37e..45b2568 100644
@@ -173,7 +173,7 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb)
 	if (!skb)
 		return RX_HANDLER_CONSUMED;
 
-	p = br_port_get_rcu(skb->dev);
+	p = rcu_dereference(skb->dev->rx_handler_data);
 
 	if (unlikely(is_link_local_ether_addr(dest))) {
 		/*
#2 lore raw

You mean IFF_BRIDGE_PORT should be only for admin/control path, but not for data path?

Quoted 83 lines · Eric Dumazet
Quoted 53 lines · Hong Zhiguo

From: Hong Zhiguo <[email protected]>

In function netdev_rx_handler_unregister it's said that:

/* a reader seeing a non NULL rx_handler in a rcu_read_lock()
* section has a guarantee to see a non NULL rx_handler_data
* as well.
*/

This is true. But br_port_get_rcu(dev) returns NULL if:

      !(dev->priv_flags & IFF_BRIDGE_PORT)

And this happended on my box when br_handle_frame is called between these 2 lines of del_nbp:

      dev->priv_flags &= ~IFF_BRIDGE_PORT;
      /* --> br_handle_frame is called at this time */
      netdev_upper_dev_unlink(dev, br->dev);

I got below Oops(some lines omitted):

BUG: unable to handle kernel NULL pointer dereference at 0000000000000021
IP: [<ffffffff8150901d>] br_handle_frame+0xed/0x230
Oops: 0000 [#1] PREEMPT SMP
RIP: 0010:[<ffffffff8150901d>]  [<ffffffff8150901d>] br_handle_frame+0xed/0x230
RSP: 0018:ffff880030403c10  EFLAGS: 00010286
Stack:
 ffff88002c945700 ffffffff81508f30 0000000000000000 ffff88002d41e000
 ffff880030403c98 ffffffff81477acb ffffffff81477821 ffff880030403c68
 ffffffff81090e10 00ff88002d545c80 ffff88002c945700 ffffffff81aa50c0
Call Trace:
 <IRQ>
 [<ffffffff81508f30>] ? br_handle_frame_finish+0x300/0x300
 [<ffffffff81477acb>] __netif_receive_skb_core+0x39b/0x880
---
 net/bridge/br_if.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/bridge/br_if.c +2 -0
index c41d5fb..bd21159 100644
@@ -133,6 +133,8 @@ static void del_nbp(struct net_bridge_port *p)
 
      sysfs_remove_link(br->ifobj, p->dev->name);
 
+     netdev_rx_handler_unregister(dev);
+
      dev_set_promiscuity(dev, -1);
 
      spin_lock_bh(&br->lock);

net/bridge/br_if.c static void del_nbp(struct net_bridge_port *p) · line 155

Quoted 8 lines
net/bridge/br_if.c +0 -2
@@ -148,8 +150,6 @@ static void del_nbp(struct net_bridge_port *p)
 
      dev->priv_flags &= ~IFF_BRIDGE_PORT;
 
-     netdev_rx_handler_unregister(dev);
-
      netdev_upper_dev_unlink(dev, br->dev);
 
      br_multicast_del_port(p);

Interesting.

Then br_handle_frame() should not even have to check IFF_BRIDGE_PORT flag.

net/bridge/br_input.c +1 -1
index a2fd37e..45b2568 100644
@@ -173,7 +173,7 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb)
        if (!skb)
                return RX_HANDLER_CONSUMED;
 
-       p = br_port_get_rcu(skb->dev);
+       p = rcu_dereference(skb->dev->rx_handler_data);
 
        if (unlikely(is_link_local_ether_addr(dest))) {
                /*
Signature · 2 lines
best regards
Hong Zhiguo
#3 lore raw
Quoted 2 lines · Hong zhi guo

You mean IFF_BRIDGE_PORT should be only for admin/control path, but not for data path?

By definition, br_handle_frame() should be called only when device is a bridge port.

After the call to synchronize_net() included in netdev_rx_handler_unregister(), you have guarantee br_handle_frame() wont be called.

Therefore, testing IFF_BRIDGE_PORT in br_handle_frame() is redundant.

#4 lore raw
Quoted 4 lines · Eric Dumazet
Quoted 2 lines · Hong zhi guo

You mean IFF_BRIDGE_PORT should be only for admin/control path, but not for data path?

Quoted 8 lines

By definition, br_handle_frame() should be called only when device is a bridge port.

After the call to synchronize_net() included in netdev_rx_handler_unregister(), you have guarantee br_handle_frame() wont be called.

Therefore, testing IFF_BRIDGE_PORT in br_handle_frame() is redundant.

Don't all tests for IFF_BRIDGE_PORT on the bridge receive path become redundant as well?

-vlad

Quoted 8 lines

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Acked-by
#5 lore raw
Quoted 2 lines · Vlad Yasevich

Don't all tests for IFF_BRIDGE_PORT on the bridge receive path become redundant as well?

Sure but anyway this part is net-next material

Lets fix the bug first.

#6 lore raw
Quoted 8 lines · Eric Dumazet
Quoted 2 lines · Vlad Yasevich

Don't all tests for IFF_BRIDGE_PORT on the bridge receive path become redundant as well?

Sure but anyway this part is net-next material

Lets fix the bug first.

Seems like the race is possible in net as well. If we just include the original patch, then br_add_if() also has to be modified to make sure the flag is set properly before netdev_rx_handler_register() is called.

If we remove the need to check the flag during bridge input handling, then br_add_if() change is not necessary.

-vlad

Quoted 9 lines

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw
Quoted 8 lines · Vlad Yasevich
Quoted 7 lines · Eric Dumazet
Quoted 2 lines · Vlad Yasevich

Don't all tests for IFF_BRIDGE_PORT on the bridge receive path become redundant as well?

Sure but anyway this part is net-next material

Quoted 8 lines
Quoted 1 line

Lets fix the bug first.

Seems like the race is possible in net as well. If we just include the original patch, then br_add_if() also has to be modified to make sure the flag is set properly before netdev_rx_handler_register() is called.

If we remove the need to check the flag during bridge input handling, then br_add_if() change is not necessary.

Yep, really testing IFF_BRIDGE_PORT in fast path is currently racy.

rcu protection should be enough.

#8 lore raw

PATCH 1/1 fix NULL pointer dereference in br_handle_frame

In reply to Hong Zhiguo

not check IFF_BRIDGE_PORT within br_handle_frame

---
 net/bridge/br_input.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
net/bridge/br_input.c +3 -3
index a2fd37e..da4714a 100644
@@ -60,7 +60,7 @@ static int br_pass_frame_up(struct sk_buff *skb)
 int br_handle_frame_finish(struct sk_buff *skb)
 {
 	const unsigned char *dest = eth_hdr(skb)->h_dest;
-	struct net_bridge_port *p = br_port_get_rcu(skb->dev);
+	enet_bridge_port *p = rcu_dereference(skb->dev->rx_handler_data);
 	struct net_bridge *br;
 	struct net_bridge_fdb_entry *dst;
 	struct net_bridge_mdb_entry *mdst;
@@ -143,7 +143,7 @@ drop:
 /* note: already called with rcu_read_lock */
 static int br_handle_local_finish(struct sk_buff *skb)
 {
-	struct net_bridge_port *p = br_port_get_rcu(skb->dev);
+	struct net_bridge_port *p = rcu_dereference(skb->dev->rx_handler_data);
 	u16 vid = 0;
 
 	br_vlan_get_tag(skb, &vid);
@@ -173,7 +173,7 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb)
 	if (!skb)
 		return RX_HANDLER_CONSUMED;
 
-	p = br_port_get_rcu(skb->dev);
+	p = rcu_dereference(skb->dev->rx_handler_data);
 
 	if (unlikely(is_link_local_ether_addr(dest))) {
 		/*
Signature · 1 line
1.7.0.4
#9 lore raw

You're right, Vlad.
One thing is missing in Eric's fix, NULL dereference is still possible in br_handle_local_finish. Above is the new version of fix.

Quoted 41 lines · Hong Zhiguo

not check IFF_BRIDGE_PORT within br_handle_frame

---
 net/bridge/br_input.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
net/bridge/br_input.c +3 -4
index a2fd37e..da4714a 100644
@@ -60,7 +60,7 @@ static int br_pass_frame_up(struct sk_buff *skb)
 int br_handle_frame_finish(struct sk_buff *skb)
 {
        const unsigned char *dest = eth_hdr(skb)->h_dest;
-       struct net_bridge_port *p = br_port_get_rcu(skb->dev);
+       enet_bridge_port *p = rcu_dereference(skb->dev->rx_handler_data);
        struct net_bridge *br;
        struct net_bridge_fdb_entry *dst;
        struct net_bridge_mdb_entry *mdst;
@@ -143,7 +143,7 @@ drop:
 /* note: already called with rcu_read_lock */
 static int br_handle_local_finish(struct sk_buff *skb)
 {
-       struct net_bridge_port *p = br_port_get_rcu(skb->dev);
+       struct net_bridge_port *p = rcu_dereference(skb->dev->rx_handler_data);
        u16 vid = 0;
 
        br_vlan_get_tag(skb, &vid);
@@ -173,7 +173,7 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb)
        if (!skb)
                return RX_HANDLER_CONSUMED;
 
-       p = br_port_get_rcu(skb->dev);
+       p = rcu_dereference(skb->dev->rx_handler_data);
 
        if (unlikely(is_link_local_ether_addr(dest))) {
                /*
--

1.7.0.4

Signature · 2 lines
best regards
Hong Zhiguo
#10 lore raw
Quoted 3 lines · Hong zhi guo

You're right, Vlad.
One thing is missing in Eric's fix, NULL dereference is still possible in br_handle_local_finish. Above is the new version of fix.

Hey, it was not a 'fix', but a comment on your patch and bridge defensive programming.

#11 lore raw

sorry, Eric, maybe I'm using wrong words. Thanks for your review and help. So you both prefer not testing IFF_BRIDGE_PORT. Let's take the new fix.

Quoted 10 lines · Eric Dumazet
Quoted 3 lines · Hong zhi guo

You're right, Vlad.
One thing is missing in Eric's fix, NULL dereference is still possible in br_handle_local_finish. Above is the new version of fix.

Hey, it was not a 'fix', but a comment on your patch and bridge defensive programming.

Signature · 2 lines
best regards
Hong Zhiguo
#12 lore raw
Quoted 2 lines · Hong zhi guo

sorry, Eric, maybe I'm using wrong words. Thanks for your review and help. So you both prefer not testing IFF_BRIDGE_PORT. Let's take the new fix.

Please do not top post on netdev.

Thanks

maintainer
#14 lore raw
In reply to Hong Zhiguo

From: Hong Zhiguo <[email protected]>
Date: Thu, 12 Sep 2013 23:57:08 +0800

net/bridge/br_input.c static int br_pass_frame_up(struct sk_buff *skb) · line 63

Quoted 6 lines
net/bridge/br_input.c +1 -1
@@ -60,7 +60,7 @@ static int br_pass_frame_up(struct sk_buff *skb)
 int br_handle_frame_finish(struct sk_buff *skb)
 {
 	const unsigned char *dest = eth_hdr(skb)->h_dest;
-	struct net_bridge_port *p = br_port_get_rcu(skb->dev);
+	enet_bridge_port *p = rcu_dereference(skb->dev->rx_handler_data);

You did not even compile test this patch.

This is a good way to make people not want to review your work at all, because if you don't care enough to even compile test your patch why should other people care enough to look at it?

#15 lore raw

PATCH 1/1 bridge: fix NULL pointer deref in br_handle_frame

In reply to Hong Zhiguo

From: Hong Zhiguo <[email protected]>

I got an Oops on my box when br_handle_frame is called between these 2 lines of del_nbp:

	dev->priv_flags &= ~IFF_BRIDGE_PORT;
	/* --> br_handle_frame is called at this time */
	netdev_rx_handler_unregister(dev);

In br_handle_frame the return of br_port_get_rcu(dev) is dereferenced without check but br_port_get_rcu(dev) returns NULL if:

	!(dev->priv_flags & IFF_BRIDGE_PORT)

In my first fix I moved netdev_rx_handler_unregister up. Eric Dumazet pointed out the testing of IFF_BRIDGE_PORT is not necessary here since we're in rcu_read_lock and we have synchronize_net() in netdev_rx_handler_unregister. This fix removed the testing of IFF_BRIDGE_PORT.

I tested the fix on my box with script doing "brctl addif" and "brctl delif" repeatedly while a lot of broadcast frame present on the LAN. I added msleep in del_nbp between setting of priv_flags and unregister so it's easy to reproduce the oops without the fix.

I'll send another patch to net-next to take care of br_netfilter and ebtable if necessary(seems there's NULL check following but I'll have a look).

The Oops(some lines omitted):

BUG: unable to handle kernel NULL pointer dereference at 0000000000000021
IP: [<ffffffff8150901d>] br_handle_frame+0xed/0x230
Oops: 0000 [#1] PREEMPT SMP
RIP: 0010:[<ffffffff8150901d>]  [<ffffffff8150901d>] br_handle_frame+0xed/0x230
RSP: 0018:ffff880030403c10  EFLAGS: 00010286
Stack:
 ffff88002c945700 ffffffff81508f30 0000000000000000 ffff88002d41e000
 ffff880030403c98 ffffffff81477acb ffffffff81477821 ffff880030403c68
 ffffffff81090e10 00ff88002d545c80 ffff88002c945700 ffffffff81aa50c0
Call Trace:
 <IRQ>
 [<ffffffff81508f30>] ? br_handle_frame_finish+0x300/0x300
 [<ffffffff81477acb>] __netif_receive_skb_core+0x39b/0x880
---
 net/bridge/br_input.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
net/bridge/br_input.c +3 -3
index a2fd37e..2244049 100644
@@ -60,7 +60,7 @@ static int br_pass_frame_up(struct sk_buff *skb)
 int br_handle_frame_finish(struct sk_buff *skb)
 {
 	const unsigned char *dest = eth_hdr(skb)->h_dest;
-	struct net_bridge_port *p = br_port_get_rcu(skb->dev);
+	struct net_bridge_port *p = rcu_dereference(skb->dev->rx_handler_data);
 	struct net_bridge *br;
 	struct net_bridge_fdb_entry *dst;
 	struct net_bridge_mdb_entry *mdst;
@@ -143,7 +143,7 @@ drop:
 /* note: already called with rcu_read_lock */
 static int br_handle_local_finish(struct sk_buff *skb)
 {
-	struct net_bridge_port *p = br_port_get_rcu(skb->dev);
+	struct net_bridge_port *p = rcu_dereference(skb->dev->rx_handler_data);
 	u16 vid = 0;
 
 	br_vlan_get_tag(skb, &vid);
@@ -173,7 +173,7 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb)
 	if (!skb)
 		return RX_HANDLER_CONSUMED;
 
-	p = br_port_get_rcu(skb->dev);
+	p = rcu_dereference(skb->dev->rx_handler_data);
 
 	if (unlikely(is_link_local_ether_addr(dest))) {
 		/*
Signature · 1 line
1.8.1.2
#16 lore raw

Re: [PATCH net-next] bridge: fix NULL pointer deref in br_handle_frame

Quoted 70 lines · On Fri, 13 Sep 2013 11:09:47 +0800 Hong Zhiguo <[email protected]> wrote:

From: Hong Zhiguo <[email protected]>

I got an Oops on my box when br_handle_frame is called between these 2 lines of del_nbp:

	dev->priv_flags &= ~IFF_BRIDGE_PORT;
	/* --> br_handle_frame is called at this time */
	netdev_rx_handler_unregister(dev);

In br_handle_frame the return of br_port_get_rcu(dev) is dereferenced without check but br_port_get_rcu(dev) returns NULL if:

	!(dev->priv_flags & IFF_BRIDGE_PORT)

In my first fix I moved netdev_rx_handler_unregister up. Eric Dumazet pointed out the testing of IFF_BRIDGE_PORT is not necessary here since we're in rcu_read_lock and we have synchronize_net() in netdev_rx_handler_unregister. This fix removed the testing of IFF_BRIDGE_PORT.

I tested the fix on my box with script doing "brctl addif" and "brctl delif" repeatedly while a lot of broadcast frame present on the LAN. I added msleep in del_nbp between setting of priv_flags and unregister so it's easy to reproduce the oops without the fix.

I'll send another patch to net-next to take care of br_netfilter and ebtable if necessary(seems there's NULL check following but I'll have a look).

The Oops(some lines omitted):

BUG: unable to handle kernel NULL pointer dereference at 0000000000000021
IP: [<ffffffff8150901d>] br_handle_frame+0xed/0x230
Oops: 0000 [#1] PREEMPT SMP
RIP: 0010:[<ffffffff8150901d>]  [<ffffffff8150901d>] br_handle_frame+0xed/0x230
RSP: 0018:ffff880030403c10  EFLAGS: 00010286
Stack:
 ffff88002c945700 ffffffff81508f30 0000000000000000 ffff88002d41e000
 ffff880030403c98 ffffffff81477acb ffffffff81477821 ffff880030403c68
 ffffffff81090e10 00ff88002d545c80 ffff88002c945700 ffffffff81aa50c0
Call Trace:
 <IRQ>
 [<ffffffff81508f30>] ? br_handle_frame_finish+0x300/0x300
 [<ffffffff81477acb>] __netif_receive_skb_core+0x39b/0x880
---
 net/bridge/br_input.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
net/bridge/br_input.c +2 -2
index a2fd37e..2244049 100644
@@ -60,7 +60,7 @@ static int br_pass_frame_up(struct sk_buff *skb)
 int br_handle_frame_finish(struct sk_buff *skb)
 {
 	const unsigned char *dest = eth_hdr(skb)->h_dest;
-	struct net_bridge_port *p = br_port_get_rcu(skb->dev);
+	struct net_bridge_port *p = rcu_dereference(skb->dev->rx_handler_data);
 	struct net_bridge *br;
 	struct net_bridge_fdb_entry *dst;
 	struct net_bridge_mdb_entry *mdst;
@@ -143,7 +143,7 @@ drop:
 /* note: already called with rcu_read_lock */
 static int br_handle_local_finish(struct sk_buff *skb)
 {
-	struct net_bridge_port *p = br_port_get_rcu(skb->dev);
+	struct net_bridge_port *p = rcu_dereference(skb->dev->rx_handler_data);
 	u16 vid = 0;
 
 	br_vlan_get_tag(skb, &vid);

net/bridge/br_input.c rx_handler_result_t br_handle_frame(struct sk_buff **pskb) · line 179

Quoted 8 lines
net/bridge/br_input.c +1 -1
@@ -173,7 +173,7 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb)
 	if (!skb)
 		return RX_HANDLER_CONSUMED;
 
-	p = br_port_get_rcu(skb->dev);
+	p = rcu_dereference(skb->dev->rx_handler_data);
 
 	if (unlikely(is_link_local_ether_addr(dest))) {
 		/*

There are more uses of br_port_get_rcu that have the same problem.
For example receiving an STP packet in that window.
I bet if you look at all the callers of br_port_get_rcu() you will
see the same issue, therefore either the check should be removed from br_port_get_rcu.

A little bit of history, the bridge code orginally did not use RCU, and there was a flag on the device. Then RCU was added, then the receive handler stuff was added.