From: Edward Adam Davis <eadavis@qq.com>
To: syzbot+7ec955e36bb239bd720f@syzkaller.appspotmail.com
Cc: andrew@lunn.ch, daniel@iogearbox.net, davem@davemloft.net,
edumazet@google.com, f.fainelli@gmail.com, hkallweit1@gmail.com,
kuba@kernel.org, linux-kernel@vger.kernel.org,
linux@armlinux.org.uk, maxime.chevallier@bootlin.com,
netdev@vger.kernel.org, olteanv@gmail.com, pabeni@redhat.com,
sd@queasysnail.net, syzkaller-bugs@googlegroups.com,
vladimir.oltean@nxp.com
Subject: [PATCH] net/dsa: fix oob in dsa_user_prechangeupper
Date: Tue, 16 Jan 2024 22:56:26 +0800 [thread overview]
Message-ID: <tencent_293767377D86CBF3726365497A43BD445205@qq.com> (raw)
In-Reply-To: <00000000000002faa2060f02e766@google.com>
If the private data is not allocated memory when generating an instance of
struct net_device, i.e. priv_size is too small, then its corresponding private
data should not be accessed.
Reported-and-tested-by: syzbot+7ec955e36bb239bd720f@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
net/dsa/user.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/dsa/user.h b/net/dsa/user.h
index 996069130bea..9a40918ee7fc 100644
--- a/net/dsa/user.h
+++ b/net/dsa/user.h
@@ -53,7 +53,11 @@ int dsa_user_manage_vlan_filtering(struct net_device *dev,
static inline struct dsa_port *dsa_user_to_port(const struct net_device *dev)
{
- struct dsa_user_priv *p = netdev_priv(dev);
+ const struct rtnl_link_ops *ops = dev->rtnl_link_ops;
+ struct dsa_user_priv *p = ops->priv_size >= sizeof(*p) ?
+ netdev_priv(dev) : NULL;
+ if (!p)
+ return NULL;
return p->dp;
}
--
2.43.0
next prev parent reply other threads:[~2024-01-16 15:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-15 21:43 [syzbot] [net?] KASAN: slab-out-of-bounds Read " syzbot
2024-01-16 9:13 ` Edward Adam Davis
2024-01-16 9:56 ` syzbot
2024-01-16 10:02 ` Edward Adam Davis
2024-01-16 10:18 ` syzbot
2024-01-16 11:34 ` Hillf Danton
2024-01-16 11:55 ` syzbot
2024-01-16 12:33 ` Hillf Danton
2024-01-16 12:56 ` syzbot
2024-01-16 14:13 ` Edward Adam Davis
2024-01-16 14:51 ` syzbot
2024-01-16 14:47 ` Vladimir Oltean
2024-01-16 14:56 ` Edward Adam Davis [this message]
2024-01-16 15:31 ` [PATCH] net/dsa: fix oob " Vladimir Oltean
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=tencent_293767377D86CBF3726365497A43BD445205@qq.com \
--to=eadavis@qq.com \
--cc=andrew@lunn.ch \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=sd@queasysnail.net \
--cc=syzbot+7ec955e36bb239bd720f@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=vladimir.oltean@nxp.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
all inboxes | Powered by JetHome®