netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Kees Cook <kees@kernel.org>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	linux-hardening@vger.kernel.org
Subject: [PATCH RFC 2/5] net: core: dev.c confirmed to use classic sockaddr
Date: Mon,  4 Nov 2024 14:25:04 -0800	[thread overview]
Message-ID: <20241104222513.3469025-2-kees@kernel.org> (raw)
In-Reply-To: <20241104221450.work.053-kees@kernel.org>

Add comments about the sockaddr arguments being actual classic "max 14
bytes in sa_data" sockaddr.

Signed-off-by: Kees Cook <kees@kernel.org>
---
 net/core/dev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 582466a0176a..c95779cb42a6 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -9075,7 +9075,8 @@ EXPORT_SYMBOL(dev_pre_changeaddr_notify);
 /**
  *	dev_set_mac_address - Change Media Access Control Address
  *	@dev: device
- *	@sa: new address
+ *	@sa: new address in a classic "struct sockaddr", which will never
+ *	     have more than 14 bytes in @sa::sa_data
  *	@extack: netlink extended ack
  *
  *	Change the hardware (MAC) address of the device
@@ -9109,6 +9110,7 @@ EXPORT_SYMBOL(dev_set_mac_address);
 
 DECLARE_RWSEM(dev_addr_sem);
 
+/* "sa" is a classic sockaddr: it will only ever use 14 bytes from sa_data. */
 int dev_set_mac_address_user(struct net_device *dev, struct sockaddr *sa,
 			     struct netlink_ext_ack *extack)
 {
@@ -9121,6 +9123,7 @@ int dev_set_mac_address_user(struct net_device *dev, struct sockaddr *sa,
 }
 EXPORT_SYMBOL(dev_set_mac_address_user);
 
+/* "sa" is a classic sockaddr: it will only ever use 14 bytes from sa_data. */
 int dev_get_mac_address(struct sockaddr *sa, struct net *net, char *dev_name)
 {
 	size_t size = sizeof(sa->sa_data);
-- 
2.34.1


  parent reply	other threads:[~2024-11-04 22:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-04 22:25 [PATCH RFC 0/5] sockaddr usage removal Kees Cook
2024-11-04 22:25 ` [PATCH RFC 1/5] Revert "net: dev: Convert sa_data to flexible array in struct sockaddr" Kees Cook
2024-11-04 22:25 ` Kees Cook [this message]
2024-11-04 22:25 ` [PATCH RFC 3/5] rtnetlink: do_setlink: Use sockaddr_storage Kees Cook
2024-11-05 10:59   ` Eric Dumazet
2024-12-17  1:52     ` Kees Cook
2024-11-04 22:25 ` [PATCH RFC 4/5] net: core: Convert inet_addr_is_any() to sockaddr_storage Kees Cook
2024-11-04 22:25 ` [PATCH RFC 5/5] net: Convert proto_ops::getname " Kees Cook
2024-11-06  1:16 ` [PATCH RFC 0/5] sockaddr usage removal Jakub Kicinski

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=20241104222513.3469025-2-kees@kernel.org \
    --to=kees@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).