public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: "David S. Miller" <davem@davemloft.net>
Cc: Kees Cook <kees@kernel.org>, Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	netdev@vger.kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: [PATCH net-next] net: Document sockaddr safety in ARP and routing UAPI structures
Date: Tue, 22 Jul 2025 09:58:37 -0700	[thread overview]
Message-ID: <20250722165836.work.418-kees@kernel.org> (raw)

Add documentation clarifying that ARP and routing UAPI structures are
constrained to IPv4-only usage, making them safe for the coming fixed-size
sockaddr conversion (with the 14-byte struct sockaddr::sa_data). These
are fine as-is, but their use was non-obvious to me, so I figured they
could use a little more documentation:

- struct arpreq: ARP protocol is IPv4-only by design
- struct rtentry: Legacy IPv4 routing API, IPv6 uses different structures

Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>
Cc: <netdev@vger.kernel.org>
---
 include/uapi/linux/if_arp.h | 3 ++-
 include/uapi/linux/route.h  | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/if_arp.h b/include/uapi/linux/if_arp.h
index 4783af9fe520..4164cc6e8aa5 100644
--- a/include/uapi/linux/if_arp.h
+++ b/include/uapi/linux/if_arp.h
@@ -113,7 +113,7 @@
 #define	ARPOP_NAK	10		/* (ATM)ARP NAK			*/
 
 
-/* ARP ioctl request. */
+/* ARP ioctl request; IPv4-only protocol. */
 struct arpreq {
 	struct sockaddr	arp_pa;		/* protocol address		 */
 	struct sockaddr	arp_ha;		/* hardware address		 */
@@ -122,6 +122,7 @@ struct arpreq {
 	char		arp_dev[IFNAMSIZ];
 };
 
+/* Legacy ARP ioctl request; IPv4-only protocol. */
 struct arpreq_old {
 	struct sockaddr	arp_pa;		/* protocol address		 */
 	struct sockaddr	arp_ha;		/* hardware address		 */
diff --git a/include/uapi/linux/route.h b/include/uapi/linux/route.h
index a0de9a7331a2..a2955e25d7ee 100644
--- a/include/uapi/linux/route.h
+++ b/include/uapi/linux/route.h
@@ -27,7 +27,7 @@
 #include <linux/if.h>
 #include <linux/compiler.h>
 
-/* This structure gets passed by the SIOCADDRT and SIOCDELRT calls. */
+/* This IPv4-only structure gets passed by the SIOCADDRT and SIOCDELRT calls. */
 struct rtentry {
 	unsigned long	rt_pad1;
 	struct sockaddr	rt_dst;		/* target address		*/
-- 
2.34.1


             reply	other threads:[~2025-07-22 16:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-22 16:58 Kees Cook [this message]
2025-07-22 17:41 ` [PATCH net-next] net: Document sockaddr safety in ARP and routing UAPI structures Andrew Lunn

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=20250722165836.work.418-kees@kernel.org \
    --to=kees@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --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