Netdev List
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Frank Wunderlich <frank-w@public-files.de>,
	netdev@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>
Subject: Re: [BUG] [FIX] net: dsa: oops in br_vlan_enabled
Date: Sun, 17 Feb 2019 09:13:08 -0800	[thread overview]
Message-ID: <62c1c008-8484-3e6c-239a-906efb55a6d0@gmail.com> (raw)
In-Reply-To: <trinity-782c45c1-ef94-4340-8def-f949a4a929a9-1550334156901@3c-app-gmx-bs35>

Hi Frank,

On 2/16/2019 8:22 AM, Frank Wunderlich wrote:
> Hi,
> 
> i've found an oops in 4.19.23/10, seems to be fixed anyhow in 5.0 (also works in 4.14.101)
> 
> root@bpi-r2:~# ip link add link lan0 name lan0.5 type vlan id 5
> root@bpi-r2:~# ip addr add 192.168.5.200/24 brd 192.168.5.255 dev lan0.5
> root@bpi-r2:~# ip link set dev lan0 up
> root@bpi-r2:~# ip link set dev lan0.5 up

So that these steps don't involve a bridge, and because we don't (yet)
implment ndo_vlan_rx_{add,kill}_vid() netdevice_ops, there is no VLAN
programming, it's all software

> 
> 12: lan0.5@lan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state LOWERLAYERDOWN group default qlen 1000
>     link/ether 02:02:02:02:02:02 brd ff:ff:ff:ff:ff:ff
>     inet 192.168.5.200/24 brd 192.168.5.255 scope global lan0.5
>        valid_lft forever preferred_lft forever
> 
> root@bpi-r2:~# brctl addbr bridge_name
> root@bpi-r2:~# brctl addif bridge_name lan0.5

Unless you changed the bridge to have VLAN filtering/awareness with:

echo 1 > /sys/class/net/bridge_name/bridge/vlan_filtering

There will be no VLAN configuration/objects pushed to DSA since commit
2ea7a679ca2abd251c1ec03f20508619707e1749 ("net: dsa: Don't add vlans
when vlan filtering is disabled") so I am not sure how you got into that
situation because prior to pushing a VLAN object, the port must be part
of a bridge, so the steps typically look like:

- port_bridge_join which assigns dp->bridge_dev
- port_vlan_add

Does your 4.19.23 kernel somehow change how VLAN objects are pushed down
the switch driver?

> [  352.057128] bridge_name: port 1(lan0.5) entered blocking state
> [  352.063065] bridge_name: port 1(lan0.5) entered disabled state
> [  352.069181] device lan0.5 entered promiscuous mode
> [  352.074018] device lan0 entered promiscuous mode
> [  352.078906] Unable to handle kernel NULL pointer dereference at virtual address 00000558
> ...
> [  352.493085] [<bf0fde88>] (br_vlan_enabled [bridge]) from [<bf12c234>] (dsa_port_vlan_add+0x60/0xbc [dsa_core])
> [  352.503050] [<bf12c234>] (dsa_port_vlan_add [dsa_core]) from [<bf12cb64>] (dsa_slave_port_obj_add+0x4c/0x50 [dsa_core])
> [  352.513776] [<bf12cb64>] (dsa_slave_port_obj_add [dsa_core]) from [<c0b4e2d4>] (__switchdev_port_obj_add+0x50/0xc4)
> [  352.524138] [<c0b4e2d4>] (__switchdev_port_obj_add) from [<c0b4e324>] (__switchdev_port_obj_add+0xa0/0xc4)
> [  352.533721] [<c0b4e324>] (__switchdev_port_obj_add) from [<c0b4e3a8>] (switchdev_port_obj_add_now+0x60/0x130)
> [  352.543562] [<c0b4e3a8>] (switchdev_port_obj_add_now) from [<c0b4e7e4>] (switchdev_port_obj_add+0x44/0x190)
> [  352.553284] [<c0b4e7e4>] (switchdev_port_obj_add) from [<bf1013d0>] (br_switchdev_port_vlan_add+0x60/0x7c [bridge])
> [  352.563733] [<bf1013d0>] (br_switchdev_port_vlan_add [bridge]) from [<bf0ff250>] (__vlan_add+0xb0/0x620 [bridge])
> [  352.574007] [<bf0ff250>] (__vlan_add [bridge]) from [<bf0ffd04>] (nbp_vlan_add+0xc4/0x150 [bridge])
> [  352.583073] [<bf0ffd04>] (nbp_vlan_add [bridge]) from [<bf0ffec4>] (nbp_vlan_init+0x134/0x164 [bridge])
> [  352.592482] [<bf0ffec4>] (nbp_vlan_init [bridge]) from [<bf0edd4c>] (br_add_if+0x40c/0x5fc [bridge])
> [  352.601632] [<bf0edd4c>] (br_add_if [bridge]) from [<bf0eeb14>] (add_del_if+0x6c/0x80 [bridge])
> [  352.610351] [<bf0eeb14>] (add_del_if [bridge]) from [<bf0ef5b0>] (br_dev_ioctl+0x7c/0x9c [bridge])
> [  352.619290] [<bf0ef5b0>] (br_dev_ioctl [bridge]) from [<c09583d4>] (dev_ifsioc+0x184/0x324)
> [  352.627582] [<c09583d4>] (dev_ifsioc) from [<c09589e8>] (dev_ioctl+0x32c/0x5cc)
> [  352.634837] [<c09589e8>] (dev_ioctl) from [<c090913c>] (sock_ioctl+0x3bc/0x580)
> 
> 
> since my 4.19.23 kernel is modified a bit i tried with 4.19.10 without my net modifications and it is still reproducable with steps above (create a vlan on dsa-user-port and then use it in a bridge)
> 
> i fixed it with these changes:
> 
> diff --git a/net/dsa/port.c b/net/dsa/port.c
> index ed0595459df1..962887752ae8 100644
> --- a/net/dsa/port.c
> +++ b/net/dsa/port.c
> @@ -255,8 +255,9 @@ int dsa_port_vlan_add(struct dsa_port *dp,
>         if (netif_is_bridge_master(vlan->obj.orig_dev))
>                 return -EOPNOTSUPP;
>  
> -       if (br_vlan_enabled(dp->bridge_dev))
> -               return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_ADD, &info);
> +       printk(KERN_ALERT "DEBUG: Passed %s %d 0x%x \n",__FUNCTION__,__LINE__,(unsigned int)dp->bridge_dev);
> +       if (!dp->bridge_dev || br_vlan_enabled(dp->bridge_dev))
> +               return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_DEL, &info);
>  
>         return 0;
>  }
> @@ -273,7 +274,7 @@ int dsa_port_vlan_del(struct dsa_port *dp,
>         if (netif_is_bridge_master(vlan->obj.orig_dev))
>                 return -EOPNOTSUPP;
>  
> -       if (br_vlan_enabled(dp->bridge_dev))
> +       if (!dp->bridge_dev || br_vlan_enabled(dp->bridge_dev))
>                 return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_DEL, &info);
>  
>         return 0;
> 
> i've found in a Patch from florian/vivien: https://www.mail-archive.com/netdev@vger.kernel.org/msg281415.html
> 
> Strange that 5.0-rc1 does not crash,because these 2 code-sections are unchanged: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/dsa/port.c#n255 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/bridge/br_vlan.c#n788
> 
> maybe you know why only 4.19 is affected...
> 
> regards Frank
> 

-- 
Florian

  reply	other threads:[~2019-02-17 17:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-16 16:22 [BUG] [FIX] net: dsa: oops in br_vlan_enabled Frank Wunderlich
2019-02-17 17:13 ` Florian Fainelli [this message]
2019-02-17 23:20   ` Florian Fainelli
2019-02-18 17:11     ` Aw: " Frank Wunderlich
2019-02-18 19:09       ` Florian Fainelli
  -- strict thread matches above, loose matches on Subject: below --
2019-02-17 19:05 Frank Wunderlich
2019-02-17 22:38 ` Florian Fainelli

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=62c1c008-8484-3e6c-239a-906efb55a6d0@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=frank-w@public-files.de \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox