Re: [syzbot] [net?] KASAN: slab-out-of-bounds Read in dsa_user_prechangeupper
From: Edward Adam Davis
Date: Tue Jan 16 2024 - 04:22:20 EST
please test slab-out-of-bounds Read in dsa_user_prechangeupper
#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 3e7aeb78ab01
diff --git a/net/dsa/user.c b/net/dsa/user.c
index b738a466e2dc..e6bb2c527067 100644
--- a/net/dsa/user.c
+++ b/net/dsa/user.c
@@ -2865,7 +2865,8 @@ static int dsa_user_changeupper(struct net_device *dev,
static int dsa_user_prechangeupper(struct net_device *dev,
struct netdev_notifier_changeupper_info *info)
{
- struct dsa_port *dp = dsa_user_to_port(dev);
+ const struct rtnl_link_ops *ops = dev->rtnl_link_ops;
+ struct dsa_port *dp = ops->priv_size ? dsa_user_to_port(dev) : NULL;
if (!dsa_user_dev_check(dev))
return NOTIFY_DONE;