net: Adopting nlmsg_payload() (final series)
Subsystems (2)
cover net: Adopting nlmsg_payload() (final series)
This patchset marks the final step in converting users to the new nlmsg_payload() function. It addresses the last two files that were not converted in previous series, specifically updating the following functions:
neigh_valid_dump_req
rtnl_valid_dump_ifinfo_req
rtnl_valid_getlink_req
valid_fdb_get_strict
valid_bridge_getlink_req
rtnl_valid_stats_req
rtnl_mdb_valid_dump_req
I would like to extend a big thank you to Kuniyuki Iwashima for his invaluable help and review of this effort.
---
Breno Leitao (2):
net: Use nlmsg_payload in neighbour file
net: Use nlmsg_payload in rtnetlink file
net/core/neighbour.c | 4 ++-- net/core/rtnetlink.c | 25 ++++++++++++------------- 2 files changed, 14 insertions(+), 15 deletions(-)
---
base-commit: aa5f7b9bc025408a84c4c1828501b42335b8fd68
change-id: 20250417-nlmsg_v3-2c8e6915e0d7
Best regards,
Signature · 1 line
Breno Leitao <[email protected]>
PATCH 1/2 net: Use nlmsg_payload in neighbour file
Leverage the new nlmsg_payload() helper to avoid checking for message size and then reading the nlmsg data.
--- net/core/neighbour.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/neighbour.c +2 -2
@@ -2747,12 +2747,12 @@ static int neigh_valid_dump_req(const struct nlmsghdr *nlh,if (strict_check) {struct ndmsg *ndm; -if (nlh->nlmsg_len <nlmsg_msg_size (sizeof (*ndm))) { + ndm =nlmsg_payload (nlh,sizeof (*ndm)); +if (!ndm) {NL_SET_ERR_MSG (extack,"Invalid header for neighbor dump request" );return -EINVAL ; } - ndm =nlmsg_data (nlh);if (ndm->ndm_pad1 || ndm->ndm_pad2 || ndm->ndm_ifindex || ndm->ndm_state || ndm->ndm_type) {NL_SET_ERR_MSG (extack,"Invalid values in header for neighbor dump request" );
Signature · 1 line
2.47.1
Re: [PATCH net-next 1/2] net: Use nlmsg_payload in neighbour file
From: Breno Leitao <[email protected]>
Date: Thu, 17 Apr 2025 06:03:07 -0700
Quoted 4 lines
Leverage the new
nlmsg_payload()helper to avoid checking for message size and then reading the nlmsg data.Signed-off-by Breno Leitao <[email protected]>
PATCH 2/2 net: Use nlmsg_payload in rtnetlink file
In reply to Breno LeitaoLeverage the new nlmsg_payload() helper to avoid checking for message size and then reading the nlmsg data.
--- net/core/rtnetlink.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
net/core/rtnetlink.c +12 -13
@@ -2390,12 +2390,12 @@ static int rtnl_valid_dump_ifinfo_req(const struct nlmsghdr *nlh,if (strict_check) {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,"Invalid header for link dump" );return -EINVAL ; } - ifm =nlmsg_data (nlh);if (ifm->__ifi_pad || ifm->ifi_type || ifm->ifi_flags || ifm->ifi_change) {NL_SET_ERR_MSG (extack,"Invalid values in header for link dump request" );
@@ -4087,7 +4087,8 @@ static int rtnl_valid_getlink_req(struct sk_buff *skb,struct ifinfomsg *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 (extack,"Invalid header for get link" );return -EINVAL ; }
@@ -4096,7 +4097,6 @@ static int rtnl_valid_getlink_req(struct sk_buff *skb,return nlmsg_parse_deprecated (nlh,sizeof (*ifm), tb,IFLA_MAX , ifla_policy, extack); - ifm =nlmsg_data (nlh);if (ifm->__ifi_pad || ifm->ifi_type || ifm->ifi_flags || ifm->ifi_change) {NL_SET_ERR_MSG (extack,"Invalid values in header for get link request" );
@@ -5055,12 +5055,12 @@ static int valid_fdb_get_strict(const struct nlmsghdr *nlh,struct ndmsg *ndm;int err, i; -if (nlh->nlmsg_len <nlmsg_msg_size (sizeof (*ndm))) { + ndm =nlmsg_payload (nlh,sizeof (*ndm)); +if (!ndm) {NL_SET_ERR_MSG (extack,"Invalid header for fdb get request" );return -EINVAL ; } - ndm =nlmsg_data (nlh);if (ndm->ndm_pad1 || ndm->ndm_pad2 || ndm->ndm_state || ndm->ndm_type) {NL_SET_ERR_MSG (extack,"Invalid values in header for fdb get request" );
@@ -5327,12 +5327,12 @@ static int valid_bridge_getlink_req(const struct nlmsghdr *nlh,if (strict_check) {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,"Invalid header for bridge link dump" );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 bridge link dump request" );
@@ -6224,7 +6224,8 @@ static int rtnl_valid_stats_req(const struct nlmsghdr *nlh, bool strict_check, {struct if_stats_msg *ifsm; -if (nlh->nlmsg_len <nlmsg_msg_size (sizeof (*ifsm))) { + ifsm =nlmsg_payload (nlh,sizeof (*ifsm)); +if (!ifsm) {NL_SET_ERR_MSG (extack,"Invalid header for stats dump" );return -EINVAL ; }
@@ -6232,8 +6233,6 @@ static int rtnl_valid_stats_req(const struct nlmsghdr *nlh, bool strict_check,if (!strict_check)return 0 ; - ifsm =nlmsg_data (nlh); -/* only requests using strict checks can pass data to influence * the dump. The legacy exception is filter_mask. */
@@ -6461,12 +6460,12 @@ static int rtnl_mdb_valid_dump_req(const struct nlmsghdr *nlh, {struct br_port_msg *bpm; -if (nlh->nlmsg_len <nlmsg_msg_size (sizeof (*bpm))) { + bpm =nlmsg_payload (nlh,sizeof (*bpm)); +if (!bpm) {NL_SET_ERR_MSG (extack,"Invalid header for mdb dump request" );return -EINVAL ; } - bpm =nlmsg_data (nlh);if (bpm->ifindex) {NL_SET_ERR_MSG (extack,"Filtering by device index is not supported for mdb dump request" );return -EINVAL ;
Signature · 1 line
2.47.1
Re: [PATCH net-next 2/2] net: Use nlmsg_payload in rtnetlink file
From: Breno Leitao <[email protected]>
Date: Thu, 17 Apr 2025 06:03:08 -0700
Quoted 4 lines
Leverage the new
nlmsg_payload()helper to avoid checking for message size and then reading the nlmsg data.Signed-off-by Breno Leitao <[email protected]>
Thanks!
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 13 lines · On Thu, 17 Apr 2025 06:03:06 -0700 you wrote:
This patchset marks the final step in converting users to the new
nlmsg_payload()function. It addresses the last two files that were not converted in previous series, specifically updating the following functions:
neigh_valid_dump_req
rtnl_valid_dump_ifinfo_req
rtnl_valid_getlink_req
valid_fdb_get_strict
valid_bridge_getlink_req
rtnl_valid_stats_req
rtnl_mdb_valid_dump_req
Quoted 1 line
[...]
Here is the summary with links:
- [net-next,1/2] net: Use nlmsg_payload in neighbour file
https://git.kernel.org/netdev/net-next/c/9929ba194299 - [net-next,2/2] net: Use nlmsg_payload in rtnetlink file https://git.kernel.org/netdev/net-next/c/a45193018001
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html