Netdev List
 help / color / mirror / Atom feed
From: Ren Wei <weir@nebusec.ai>
To: netdev@vger.kernel.org, idosch@nvidia.com
Cc: dsahern@kernel.org, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
	jiri@resnulli.us, vega@nebusec.ai, milkory@outlook.com,
	weir@nebusec.ai
Subject: [PATCH net v2 1/1] net: arp: terminate device name before lookup
Date: Mon, 21 Sep 2026 01:36:19 +0800	[thread overview]
Message-ID: <fabf02a70787d17299e4b3153eadffaf20d154b3.1789910973.git.milkory@outlook.com> (raw)
In-Reply-To: <cover.1789910973.git.milkory@outlook.com>

From: Zijie Huang <milkory@outlook.com>

The ARP ioctl copies a user-provided struct arpreq into a stack object. Its
arp_dev field may contain IFNAMSIZ bytes without a NUL terminator.

Such input is passed to dev_get_by_name_rcu() or __dev_get_by_name(), where
strcmp() can read past the end of the stack object when a matching
alternative interface name exists.

Terminate the field before the lookup to prevent the out-of-bounds read.

Fixes: 36fbf1e52bd3 ("net: rtnetlink: add linkprop commands to add and delete alternative ifnames")
Cc: stable@vger.kernel.org
Reported-by: Vega <vega@nebusec.ai>
Assisted-by: LLM
Signed-off-by: Zijie Huang <milkory@outlook.com>
Signed-off-by: Ren Wei <weir@nebusec.ai>
---

changes in v2:
  - Change to terminate the field instead of returning an error, as
    suggested by Ido Schimmel.
  - Changed Fixes to be more accurate, as suggested by Ido Schimmel.
  - v1 Link: https://lore.kernel.org/all/cover.1789648438.git.milkory@outlook.com/

 net/ipv4/arp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index d409f606aec0..60009d92e071 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -1278,6 +1278,7 @@ int arp_ioctl(struct net *net, unsigned int cmd, void __user *arg)
 		err = copy_from_user(&r, arg, sizeof(struct arpreq));
 		if (err)
 			return -EFAULT;
+		r.arp_dev[IFNAMSIZ - 1] = '\0';
 		break;
 	default:
 		return -EINVAL;
-- 
2.47.3

  reply	other threads:[~2026-09-20 17:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-20 17:36 [PATCH net v2 0/1] net: arp: fix stack out-of-bounds read via unterminated device name Ren Wei
2026-09-20 17:36 ` Ren Wei [this message]
2026-09-21  9:31   ` [PATCH net v2 1/1] net: arp: terminate device name before lookup Ido Schimmel
2026-09-24  2:10 ` [PATCH net v2 0/1] net: arp: fix stack out-of-bounds read via unterminated device name 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=fabf02a70787d17299e4b3153eadffaf20d154b3.1789910973.git.milkory@outlook.com \
    --to=weir@nebusec.ai \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=milkory@outlook.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=vega@nebusec.ai \
    /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