public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: "David S. Miller" <davem@davemloft.net>,
	 Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	 David Ahern <dsahern@kernel.org>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Breno Leitao <leitao@debian.org>,
	kernel-team@meta.com,  Kuniyuki Iwashima <kuniyu@amazon.com>
Subject: [PATCH net-next v2 07/10] ipv6: Use nlmsg_payload in inet6_rtm_valid_getaddr_req
Date: Mon, 14 Apr 2025 06:24:13 -0700	[thread overview]
Message-ID: <20250414-nlmsg-v2-7-3d90cb42c6af@debian.org> (raw)
In-Reply-To: <20250414-nlmsg-v2-0-3d90cb42c6af@debian.org>

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

Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
 net/ipv6/addrconf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index a9aeb949d9c8e..4af2761795428 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -5484,7 +5484,8 @@ static int inet6_rtm_valid_getaddr_req(struct sk_buff *skb,
 	struct ifaddrmsg *ifm;
 	int i, err;
 
-	if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifm))) {
+	ifm = nlmsg_payload(nlh, sizeof(*ifm));
+	if (!ifm) {
 		NL_SET_ERR_MSG_MOD(extack, "Invalid header for get address request");
 		return -EINVAL;
 	}
@@ -5493,7 +5494,6 @@ static int inet6_rtm_valid_getaddr_req(struct sk_buff *skb,
 		return nlmsg_parse_deprecated(nlh, sizeof(*ifm), tb, IFA_MAX,
 					      ifa_ipv6_policy, extack);
 
-	ifm = nlmsg_data(nlh);
 	if (ifm->ifa_prefixlen || ifm->ifa_flags || ifm->ifa_scope) {
 		NL_SET_ERR_MSG_MOD(extack, "Invalid values in header for get address request");
 		return -EINVAL;

-- 
2.47.1


  parent reply	other threads:[~2025-04-14 13:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-14 13:24 [PATCH net-next v2 00/10] net: Introduce nlmsg_payload helper Breno Leitao
2025-04-14 13:24 ` [PATCH net-next v2 01/10] netlink: " Breno Leitao
2025-04-14 13:24 ` [PATCH net-next v2 02/10] neighbour: Use nlmsg_payload in neightbl_valid_dump_info Breno Leitao
2025-04-14 13:24 ` [PATCH net-next v2 03/10] neighbour: Use nlmsg_payload in neigh_valid_get_req Breno Leitao
2025-04-14 13:24 ` [PATCH net-next v2 04/10] rtnetlink: Use nlmsg_payload in valid_fdb_dump_strict Breno Leitao
2025-04-14 13:24 ` [PATCH net-next v2 05/10] mpls: Use nlmsg_payload in mpls_valid_fib_dump_req Breno Leitao
2025-04-14 13:24 ` [PATCH net-next v2 06/10] ipv6: Use nlmsg_payload in inet6_valid_dump_ifaddr_req Breno Leitao
2025-04-14 13:24 ` Breno Leitao [this message]
2025-04-14 13:24 ` [PATCH net-next v2 08/10] mpls: Use nlmsg_payload in mpls_valid_getroute_req Breno Leitao
2025-04-14 13:24 ` [PATCH net-next v2 09/10] net: fib_rules: Use nlmsg_payload in fib_valid_dumprule_req Breno Leitao
2025-04-14 13:24 ` [PATCH net-next v2 10/10] net: fib_rules: Use nlmsg_payload in fib_{new,del}rule() Breno Leitao
2025-04-14 18:42   ` Kuniyuki Iwashima
2025-04-15 15:40 ` [PATCH net-next v2 00/10] net: Introduce nlmsg_payload helper 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=20250414-nlmsg-v2-7-3d90cb42c6af@debian.org \
    --to=leitao@debian.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox