Netdev List
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: jiale yao <19888972804@163.com>, Jiri Pirko <jiri@resnulli.us>,
	Oleksij Rempel <o.rempel@pengutronix.de>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"linux-can@vger.kernel.org" <linux-can@vger.kernel.org>
Subject: Re: [PATCH v2] team: reject CAN and IEEE 802.15.4 devices in team_port_add
Date: Sat, 15 Aug 2026 17:54:28 +0200	[thread overview]
Message-ID: <4375eab3-b112-47ad-a499-4467c91b98b8@hartkopp.net> (raw)
In-Reply-To: <23268b84-a1c5-4551-91ba-0a596cff21a1@hartkopp.net>



On 14.08.26 16:45, Oliver Hartkopp wrote:
> +CC: linux-can ML
> 
> On 29.07.26 14:11, jiale yao wrote:
>> How about adding a helper in include/linux/if_arp.h, similar to 
>> dev_is_mac_header_xmit()? Perhaps
>> something like dev_is_can_or_ieee802154()?
>>
> 
> Good idea.
> 
> But I would rather suggest some
> 
> static inline bool netdev_has_ml_priv(struct net_device *dev)
> 
> in
> 
> include/linux/netdevice.h
> 
> next to
> 
> netdev_set_ml_priv() / netdev_get_ml_priv()
> 
> Currently only the CAN subsystem properly handles the dev->ml_priv_type 
> to make sure the correct "user" of the ml_priv pointer:
> 
> /* Specifies the type of the struct net_device::ml_priv pointer */
> enum netdev_ml_priv_type {
>      ML_PRIV_NONE,
>      ML_PRIV_CAN,
> }
> 
> There are some other ethernet adapters of dev->ml_priv beyond 
> ARPHRD_IEEE802154, and ARPHRD_IEEE802154_MONITOR. Not sure if those 
> adapters need to be fixed.
> 
> But to be sure we don't run into problems with bonding or teaming we 
> should probably simply check for (dev->ml_priv != NULL) to reject them.
> No matter which netdev_ml_priv_type is set.
> 
> static inline bool netdev_has_ml_priv(struct net_device *dev) {
> 
>      return (dev->ml_priv != NULL);
> }
> 
> Would you like to provide a patch introducing this helper and directly 
> use it for bonding/team (with some updated comments, as the problem is 
> not related to CAN and IEEE 802.15.4 devices but to the use of ml_priv)?

I've sent my idea of a combined patch fixing either the bonding and the 
teaming sides by checking the use of ml_priv here:

https://lore.kernel.org/netdev/20260815153938.187073-1-socketcan@hartkopp.net/

Many thanks and best regards,
Oliver

> 
> 
>>
>> At 2026-07-29 17:15:06, "Jiri Pirko" <jiri@resnulli.us> wrote:
>>> Tue, Jul 28, 2026 at 05:12:40PM +0200, yaojiale02@163.com wrote:
>>>> Enslaving a CAN or IEEE 802.15.4 device (e.g. vxcan, wpan0) to a
>>>> team master triggers a NULL pointer dereference because these
>>>> device types use different Layer 2 architectures from Ethernet and
>>>> the team driver never initializes their private mid-layer data
>>>> structures.
>>>>
>>>> Reject ARPHRD_CAN, ARPHRD_IEEE802154, and ARPHRD_IEEE802154_MONITOR
>>>> devices in team_port_add(), mirroring the existing CAN check already
>>>> present in the bonding driver since commit 8ba68464e478 ("bonding:
>>>> refuse to enslave CAN devices").
>>>
>>> Can we perhaps have a unified helper for the check?
>>>
>>>
>>>>
>>>> Link: https://lore.kernel.org/all/b58d98e0-8fe3-4e4e-b8a5- 
>>>> c1c7e647ccca@hartkopp.net/
>>>> Fixes: 1d76efe1577b ("team: add support for non-ethernet devices")
>>>> Assisted-by: Claude:deepseek-v4-pro
>>>
>>> Looks your ai gone a bit wild here...
>>>
>>>
>>>> Signed-off-by: Jiale Yao <yaojiale02@163.com>
>>>> ---
>>>> V1 -> V2: Extended check to also reject ARPHRD_IEEE802154 and
>>>>   ARPHRD_IEEE802154_MONITOR devices per review feedback
>>>> ---
>>>> drivers/net/team/team_core.c | 11 +++++++++++
>>>> 1 file changed, 11 insertions(+)
>>>>
>>>> diff --git a/drivers/net/team/team_core.c b/drivers/net/team/ 
>>>> team_core.c
>>>> index feaa75fbf8fc..d8c46105fc8b 100644
>>>> --- a/drivers/net/team/team_core.c
>>>> +++ b/drivers/net/team/team_core.c
>>>> @@ -1224,6 +1224,17 @@ static int team_port_add(struct team *team, 
>>>> struct net_device *port_dev,
>>>>         return -EINVAL;
>>>>     }
>>>>
>>>> +        if (port_dev->type == ARPHRD_CAN ||
>>>> +            port_dev->type == ARPHRD_IEEE802154 ||
>>>> +            port_dev->type == ARPHRD_IEEE802154_MONITOR) {
>>>> +            NL_SET_ERR_MSG(extack,
>>>> +                       "CAN and IEEE 802.15.4 devices can't be 
>>>> added as a team port");
>>>> +            netdev_err(dev, "Device %s is CAN or IEEE 802.15.4. 
>>>> These device types can't be added as a team port\n",
>>>> +                   portname);
>>>> +            return -EINVAL;
>>>> +        }
>>>> +    }
>>>> +
>>>>     if (netif_is_team_port(port_dev)) {
>>>>         NL_SET_ERR_MSG(extack, "Device is already a port of a team 
>>>> device");
>>>>         netdev_err(dev, "Device %s is already a port "
>>>> -- 
>>>> 2.34.1
>>>>
> 


  reply	other threads:[~2026-08-15 15:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28 15:12 [PATCH v2] team: reject CAN and IEEE 802.15.4 devices in team_port_add Jiale Yao
2026-07-29  9:15 ` Jiri Pirko
2026-07-29 12:11   ` jiale yao
2026-08-14 14:45     ` Oliver Hartkopp
2026-08-15 15:54       ` Oliver Hartkopp [this message]
2026-08-05  5:00 ` kernel test robot
2026-08-05 15:42 ` kernel test robot

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=4375eab3-b112-47ad-a499-4467c91b98b8@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=19888972804@163.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.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