* [PATCH net-next] net: Document sockaddr safety in ARP and routing UAPI structures
@ 2025-07-22 16:58 Kees Cook
2025-07-22 17:41 ` Andrew Lunn
0 siblings, 1 reply; 2+ messages in thread
From: Kees Cook @ 2025-07-22 16:58 UTC (permalink / raw)
To: David S. Miller
Cc: Kees Cook, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev, Andrew Lunn, linux-kernel, linux-hardening
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] net: Document sockaddr safety in ARP and routing UAPI structures
2025-07-22 16:58 [PATCH net-next] net: Document sockaddr safety in ARP and routing UAPI structures Kees Cook
@ 2025-07-22 17:41 ` Andrew Lunn
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Lunn @ 2025-07-22 17:41 UTC (permalink / raw)
To: Kees Cook
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev, Andrew Lunn, linux-kernel, linux-hardening
On Tue, Jul 22, 2025 at 09:58:37AM -0700, Kees Cook wrote:
> 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
I'm not sure this second statement is strictly true:
https://elixir.bootlin.com/linux/v6.15.7/source/net/appletalk/ddp.c#L918
atrtr_ioctl() ->
atrtr_create()->
struct sockaddr_at *ta = (struct sockaddr_at *)&r->rt_dst;
where:
struct sockaddr_at {
__kernel_sa_family_t sat_family;
__u8 sat_port;
struct atalk_addr sat_addr;
char sat_zero[8];
};
This is not an IPv4 address.
Maybe this does fit with a 14 byte sockaddr::sa_data, so it is not an
issue, but the comment and commit message should be expanded to
explain this. And i only looked at the first SIOCADDRT i came across,
there are many other protocols using this ioctl.
Andrew
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-07-22 17:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-22 16:58 [PATCH net-next] net: Document sockaddr safety in ARP and routing UAPI structures Kees Cook
2025-07-22 17:41 ` Andrew Lunn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).