From: Breno Leitao <leitao@debian.org>
To: kuniyu@amazon.com, "David S. Miller" <davem@davemloft.net>,
	 David Ahern <dsahern@kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	 Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,  Simon Horman <horms@kernel.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Breno Leitao <leitao@debian.org>,
	kernel-team@meta.com
Subject: [PATCH net-next 1/8] ipv6: Use nlmsg_payload in addrlabel file
Date: Tue, 15 Apr 2025 12:28:52 -0700	[thread overview]
Message-ID: <20250415-nlmsg_v2-v1-1-a1c75d493fd7@debian.org> (raw)
In-Reply-To: <20250415-nlmsg_v2-v1-0-a1c75d493fd7@debian.org>

Leverage the new nlmsg_payload() helper to avoid checking for message
size and then reading the nlmsg data.

This changes function ip6addrlbl_valid_get_req() and
ip6addrlbl_valid_dump_req().

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 net/ipv6/addrlabel.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/ipv6/addrlabel.c b/net/ipv6/addrlabel.c
index ab054f329e12d..fb63ffbcfc647 100644
--- a/net/ipv6/addrlabel.c
+++ b/net/ipv6/addrlabel.c
@@ -473,12 +473,12 @@ static int ip6addrlbl_valid_dump_req(const struct nlmsghdr *nlh,
 {
 	struct ifaddrlblmsg *ifal;
 
-	if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifal))) {
+	ifal = nlmsg_payload(nlh, sizeof(*ifal));
+	if (!ifal) {
 		NL_SET_ERR_MSG_MOD(extack, "Invalid header for address label dump request");
 		return -EINVAL;
 	}
 
-	ifal = nlmsg_data(nlh);
 	if (ifal->__ifal_reserved || ifal->ifal_prefixlen ||
 	    ifal->ifal_flags || ifal->ifal_index || ifal->ifal_seq) {
 		NL_SET_ERR_MSG_MOD(extack, "Invalid values in header for address label dump request");
@@ -543,7 +543,8 @@ static int ip6addrlbl_valid_get_req(struct sk_buff *skb,
 	struct ifaddrlblmsg *ifal;
 	int i, err;
 
-	if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifal))) {
+	ifal = nlmsg_payload(nlh, sizeof(*ifal));
+	if (!ifal) {
 		NL_SET_ERR_MSG_MOD(extack, "Invalid header for addrlabel get request");
 		return -EINVAL;
 	}
@@ -552,7 +553,6 @@ static int ip6addrlbl_valid_get_req(struct sk_buff *skb,
 		return nlmsg_parse_deprecated(nlh, sizeof(*ifal), tb,
 					      IFAL_MAX, ifal_policy, extack);
 
-	ifal = nlmsg_data(nlh);
 	if (ifal->__ifal_reserved || ifal->ifal_flags || ifal->ifal_seq) {
 		NL_SET_ERR_MSG_MOD(extack, "Invalid values in header for addrlabel get request");
 		return -EINVAL;

-- 
2.47.1


  reply	other threads:[~2025-04-15 19:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-15 19:28 [PATCH net-next 0/8] Adopting nlmsg_payload() in IPv4/IPv6 Breno Leitao
2025-04-15 19:28 ` Breno Leitao [this message]
2025-04-16  0:54   ` [PATCH net-next 1/8] ipv6: Use nlmsg_payload in addrlabel file Kuniyuki Iwashima
2025-04-15 19:28 ` [PATCH net-next 2/8] ipv6: Use nlmsg_payload in addrconf file Breno Leitao
2025-04-16  0:56   ` Kuniyuki Iwashima
2025-04-15 19:28 ` [PATCH net-next 3/8] ipv6: Use nlmsg_payload in route file Breno Leitao
2025-04-16  0:59   ` Kuniyuki Iwashima
2025-04-15 19:28 ` [PATCH net-next 4/8] ipv4: Use nlmsg_payload in devinet file Breno Leitao
2025-04-16  1:00   ` Kuniyuki Iwashima
2025-04-15 19:28 ` [PATCH net-next 5/8] ipv4: Use nlmsg_payload in fib_frontend file Breno Leitao
2025-04-16  1:03   ` Kuniyuki Iwashima
2025-04-15 19:28 ` [PATCH net-next 6/8] ipv4: Use nlmsg_payload in route file Breno Leitao
2025-04-16  1:04   ` Kuniyuki Iwashima
2025-04-15 19:28 ` [PATCH net-next 7/8] ipv4: Use nlmsg_payload in ipmr file Breno Leitao
2025-04-16  1:06   ` Kuniyuki Iwashima
2025-04-15 19:28 ` [PATCH net-next 8/8] vxlan: Use nlmsg_payload in vxlan_vnifilter_dump Breno Leitao
2025-04-16  1:13   ` Kuniyuki Iwashima
2025-04-16 13:55     ` Breno Leitao
2025-04-17  1:40 ` [PATCH net-next 0/8] Adopting nlmsg_payload() in IPv4/IPv6 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=20250415-nlmsg_v2-v1-1-a1c75d493fd7@debian.org \
    --to=leitao@debian.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.