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 7/8] ipv4: Use nlmsg_payload in ipmr file
Date: Tue, 15 Apr 2025 12:28:58 -0700 [thread overview]
Message-ID: <20250415-nlmsg_v2-v1-7-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.
Signed-off-by: Breno Leitao <leitao@debian.org>
---
net/ipv4/ipmr.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index a8b04d4abcaae..3b5677d8467ef 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -2511,7 +2511,8 @@ static int ipmr_rtm_valid_getroute_req(struct sk_buff *skb,
struct rtmsg *rtm;
int i, err;
- if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*rtm))) {
+ rtm = nlmsg_payload(nlh, sizeof(*rtm));
+ if (!rtm) {
NL_SET_ERR_MSG(extack, "ipv4: Invalid header for multicast route get request");
return -EINVAL;
}
@@ -2520,7 +2521,6 @@ static int ipmr_rtm_valid_getroute_req(struct sk_buff *skb,
return nlmsg_parse_deprecated(nlh, sizeof(*rtm), tb, RTA_MAX,
rtm_ipv4_policy, extack);
- rtm = nlmsg_data(nlh);
if ((rtm->rtm_src_len && rtm->rtm_src_len != 32) ||
(rtm->rtm_dst_len && rtm->rtm_dst_len != 32) ||
rtm->rtm_tos || rtm->rtm_table || rtm->rtm_protocol ||
@@ -2836,7 +2836,8 @@ static int ipmr_valid_dumplink(const struct nlmsghdr *nlh,
{
struct ifinfomsg *ifm;
- if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifm))) {
+ ifm = nlmsg_payload(nlh, sizeof(*ifm));
+ if (!ifm) {
NL_SET_ERR_MSG(extack, "ipv4: Invalid header for ipmr link dump");
return -EINVAL;
}
@@ -2846,7 +2847,6 @@ static int ipmr_valid_dumplink(const struct nlmsghdr *nlh,
return -EINVAL;
}
- ifm = nlmsg_data(nlh);
if (ifm->__ifi_pad || ifm->ifi_type || ifm->ifi_flags ||
ifm->ifi_change || ifm->ifi_index) {
NL_SET_ERR_MSG(extack, "Invalid values in header for ipmr link dump request");
--
2.47.1
next prev parent 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 ` [PATCH net-next 1/8] ipv6: Use nlmsg_payload in addrlabel file Breno Leitao
2025-04-16 0:54 ` 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 ` Breno Leitao [this message]
2025-04-16 1:06 ` [PATCH net-next 7/8] ipv4: Use nlmsg_payload in ipmr file 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-7-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.