public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] net: Adopting nlmsg_payload() (final series)
@ 2025-04-17 13:03 Breno Leitao
  2025-04-17 13:03 ` [PATCH net-next 1/2] net: Use nlmsg_payload in neighbour file Breno Leitao
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Breno Leitao @ 2025-04-17 13:03 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, kuniyu
  Cc: netdev, linux-kernel, Breno Leitao, kernel-team

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.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
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,
-- 
Breno Leitao <leitao@debian.org>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next 1/2] net: Use nlmsg_payload in neighbour file
  2025-04-17 13:03 [PATCH net-next 0/2] net: Adopting nlmsg_payload() (final series) Breno Leitao
@ 2025-04-17 13:03 ` Breno Leitao
  2025-04-17 21:35   ` Kuniyuki Iwashima
  2025-04-17 13:03 ` [PATCH net-next 2/2] net: Use nlmsg_payload in rtnetlink file Breno Leitao
  2025-04-22  9:10 ` [PATCH net-next 0/2] net: Adopting nlmsg_payload() (final series) patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Breno Leitao @ 2025-04-17 13:03 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, kuniyu
  Cc: netdev, linux-kernel, Breno Leitao, kernel-team

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/core/neighbour.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 65cf582b5dacd..254067b719da3 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -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");

-- 
2.47.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 2/2] net: Use nlmsg_payload in rtnetlink file
  2025-04-17 13:03 [PATCH net-next 0/2] net: Adopting nlmsg_payload() (final series) Breno Leitao
  2025-04-17 13:03 ` [PATCH net-next 1/2] net: Use nlmsg_payload in neighbour file Breno Leitao
@ 2025-04-17 13:03 ` Breno Leitao
  2025-04-17 21:37   ` Kuniyuki Iwashima
  2025-04-22  9:10 ` [PATCH net-next 0/2] net: Adopting nlmsg_payload() (final series) patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Breno Leitao @ 2025-04-17 13:03 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, kuniyu
  Cc: netdev, linux-kernel, Breno Leitao, kernel-team

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/core/rtnetlink.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index f5c018090efc3..3becb79a97c69 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -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;

-- 
2.47.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 1/2] net: Use nlmsg_payload in neighbour file
  2025-04-17 13:03 ` [PATCH net-next 1/2] net: Use nlmsg_payload in neighbour file Breno Leitao
@ 2025-04-17 21:35   ` Kuniyuki Iwashima
  0 siblings, 0 replies; 6+ messages in thread
From: Kuniyuki Iwashima @ 2025-04-17 21:35 UTC (permalink / raw)
  To: leitao
  Cc: davem, edumazet, horms, kernel-team, kuba, kuniyu, linux-kernel,
	netdev, pabeni

From: Breno Leitao <leitao@debian.org>
Date: Thu, 17 Apr 2025 06:03:07 -0700
> 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>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 2/2] net: Use nlmsg_payload in rtnetlink file
  2025-04-17 13:03 ` [PATCH net-next 2/2] net: Use nlmsg_payload in rtnetlink file Breno Leitao
@ 2025-04-17 21:37   ` Kuniyuki Iwashima
  0 siblings, 0 replies; 6+ messages in thread
From: Kuniyuki Iwashima @ 2025-04-17 21:37 UTC (permalink / raw)
  To: leitao
  Cc: davem, edumazet, horms, kernel-team, kuba, kuniyu, linux-kernel,
	netdev, pabeni

From: Breno Leitao <leitao@debian.org>
Date: Thu, 17 Apr 2025 06:03:08 -0700
> 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>

Thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 0/2] net: Adopting nlmsg_payload() (final series)
  2025-04-17 13:03 [PATCH net-next 0/2] net: Adopting nlmsg_payload() (final series) Breno Leitao
  2025-04-17 13:03 ` [PATCH net-next 1/2] net: Use nlmsg_payload in neighbour file Breno Leitao
  2025-04-17 13:03 ` [PATCH net-next 2/2] net: Use nlmsg_payload in rtnetlink file Breno Leitao
@ 2025-04-22  9:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-04-22  9:10 UTC (permalink / raw)
  To: Breno Leitao
  Cc: davem, edumazet, kuba, pabeni, horms, kuniyu, netdev,
	linux-kernel, kernel-team

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

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
> 
> [...]

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-04-22  9:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-17 13:03 [PATCH net-next 0/2] net: Adopting nlmsg_payload() (final series) Breno Leitao
2025-04-17 13:03 ` [PATCH net-next 1/2] net: Use nlmsg_payload in neighbour file Breno Leitao
2025-04-17 21:35   ` Kuniyuki Iwashima
2025-04-17 13:03 ` [PATCH net-next 2/2] net: Use nlmsg_payload in rtnetlink file Breno Leitao
2025-04-17 21:37   ` Kuniyuki Iwashima
2025-04-22  9:10 ` [PATCH net-next 0/2] net: Adopting nlmsg_payload() (final series) patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox