From: Jiaming Zhang <r772577952@gmail.com>
To: kuba@kernel.org
Cc: davem@davemloft.net, edumazet@google.com, horms@kernel.org,
kory.maincent@bootlin.com, kuniyu@google.com,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
pabeni@redhat.com, r772577952@gmail.com, sdf@fomichev.me,
syzkaller@googlegroups.com, vladimir.oltean@nxp.com
Subject: [PATCH v4 1/1] net: core: prevent NULL deref in generic_hwtstamp_ioctl_lower()
Date: Wed, 12 Nov 2025 01:36:52 +0800 [thread overview]
Message-ID: <20251111173652.749159-2-r772577952@gmail.com> (raw)
In-Reply-To: <20251111173652.749159-1-r772577952@gmail.com>
The ethtool tsconfig Netlink path can trigger a null pointer
dereference. A call chain such as:
tsconfig_prepare_data() ->
dev_get_hwtstamp_phylib() ->
vlan_hwtstamp_get() ->
generic_hwtstamp_get_lower() ->
generic_hwtstamp_ioctl_lower()
results in generic_hwtstamp_ioctl_lower() being called with
kernel_cfg->ifr as NULL.
The generic_hwtstamp_ioctl_lower() function does not expect a
NULL ifr and dereferences it, leading to a system crash.
Fix this by adding a NULL check for kernel_cfg->ifr in
generic_hwtstamp_ioctl_lower(). If ifr is NULL, return -EINVAL.
Fixes: 6e9e2eed4f39 ("net: ethtool: Add support for tsconfig command to get/set hwtstamp config")
Closes: https://lore.kernel.org/lkml/cd6a7056-fa6d-43f8-b78a-f5e811247ba8@linux.dev/T/#mf5df538e21753e3045de98f25aa18d948be07df3
Signed-off-by: Jiaming Zhang <r772577952@gmail.com>
---
net/core/dev_ioctl.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
index ad54b12d4b4c..8bb71a10dba0 100644
--- a/net/core/dev_ioctl.c
+++ b/net/core/dev_ioctl.c
@@ -443,6 +443,9 @@ static int generic_hwtstamp_ioctl_lower(struct net_device *dev, int cmd,
struct ifreq ifrr;
int err;
+ if (!kernel_cfg->ifr)
+ return -EINVAL;
+
strscpy_pad(ifrr.ifr_name, dev->name, IFNAMSIZ);
ifrr.ifr_ifru = kernel_cfg->ifr->ifr_ifru;
--
2.34.1
next prev parent reply other threads:[~2025-11-11 17:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-29 8:45 [Linux Kernel Bug] KASAN: null-ptr-deref Read in generic_hwtstamp_ioctl_lower Jiaming Zhang
2025-10-29 10:06 ` Kory Maincent
2025-10-29 12:22 ` Jiaming Zhang
2025-10-29 16:19 ` Vladimir Oltean
2025-10-29 16:47 ` Kory Maincent
2025-10-29 19:28 ` Vadim Fedorenko
2025-10-30 9:36 ` [PATCH] net: core: prevent NULL deref in generic_hwtstamp_ioctl_lower() Jiaming Zhang
2025-10-30 10:14 ` Kory Maincent
2025-10-30 10:49 ` [PATCH v2] " Jiaming Zhang
2025-10-30 12:49 ` [PATCH v3 0/1] " Jiaming Zhang
2025-10-30 12:49 ` [PATCH v3 1/1] " Jiaming Zhang
2025-11-04 1:15 ` Jakub Kicinski
2025-11-11 17:36 ` [PATCH v4 0/1] " Jiaming Zhang
2025-11-11 17:36 ` Jiaming Zhang [this message]
2025-11-12 8:45 ` [PATCH v4 1/1] " Kory Maincent
2025-11-14 1:40 ` [PATCH v4 0/1] " patchwork-bot+netdevbpf
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=20251111173652.749159-2-r772577952@gmail.com \
--to=r772577952@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kory.maincent@bootlin.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=syzkaller@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®