Skip to content

net: Introduce nlmsg_payload helper

Breno Leitao lkml netdev 2 versions – Applied

Status from this message: This series was applied to netdev/net-next.git (main)

Get series with b4
b4 am [email protected] change-id 20250411-nlmsg-2dd8c30ba35c

Versions newest first

  1. v2 Latest10 patches 1 replyApplied 10/10
  2. v19 patches 11 repliesSuperseded

Changes in v2 from the cover letter

- Add the "Return" kdoc entry for nlmsg_payload() (Jakub)
- Use the same function in some other places (Kuniyuki Iwashima)
- Link to v1: https://lore.kernel.org/r/[email protected]

Patches in v2 All 10 applied

#Subject and filesSizeRepliesApplied
1/10netlink: Introduce nlmsg_payload helperinclude/net/netlink.h+16 -00 repliesApplied
2/10neighbour: Use nlmsg_payload in neightbl_valid_dump_infonet/core/neighbour.c+2 -20 repliesApplied
3/10neighbour: Use nlmsg_payload in neigh_valid_get_reqnet/core/neighbour.c+2 -20 repliesApplied
4/10rtnetlink: Use nlmsg_payload in valid_fdb_dump_strictnet/core/rtnetlink.c+2 -20 repliesApplied
5/10mpls: Use nlmsg_payload in mpls_valid_fib_dump_reqnet/mpls/af_mpls.c+2 -20 repliesApplied
6/10ipv6: Use nlmsg_payload in inet6_valid_dump_ifaddr_reqnet/ipv6/addrconf.c+2 -20 repliesApplied
7/10ipv6: Use nlmsg_payload in inet6_rtm_valid_getaddr_reqnet/ipv6/addrconf.c+2 -20 repliesApplied
8/10mpls: Use nlmsg_payload in mpls_valid_getroute_reqnet/mpls/af_mpls.c+2 -20 repliesApplied
9/10net: fib_rules: Use nlmsg_payload in fib_valid_dumprule_reqnet/core/fib_rules.c+2 -20 repliesApplied
10/10net: fib_rules: Use nlmsg_payload in fib_{new,del}rule()net/core/fib_rules.c+6 -41 replyApplied

Reviews trailers per patch

All 10 patches have a Reviewed-by or Acked-by.

PatchJakub KicinskiKuniyuki Iwashima
1/10R-b R-b
2/10R-b
3/10R-b
4/10R-b
5/10R-b
6/10R-b
7/10R-b
8/10R-b
9/10R-b
10/10R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH net-next v2 00/10] net: Introduce nlmsg_payload helper

In the current codebase, there are multiple instances where the structure size is checked before assigning it to a Netlink message. This check is crucial for ensuring that the structure is correctly mapped onto the Netlink message, providing a layer of security.

To streamline this process, Jakub Kicinski suggested creating a helper function, nlmsg_payload, which verifies if the structure fits within the message. If it does, the function returns the data; otherwise, it returns NULL. This approach simplifies the code and reduces redundancy.

This patchset introduces the nlmsg_payload helper and updates several parts of the code to use it. Further updates will follow in subsequent patchsets.

---
Changes in v2:
- Add the "Return" kdoc entry for nlmsg_payload() (Jakub)
- Use the same function in some other places (Kuniyuki Iwashima)
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Breno Leitao (10):
netlink: Introduce nlmsg_payload helper
neighbour: Use nlmsg_payload in neightbl_valid_dump_info
neighbour: Use nlmsg_payload in neigh_valid_get_req
rtnetlink: Use nlmsg_payload in valid_fdb_dump_strict
mpls: Use nlmsg_payload in mpls_valid_fib_dump_req
ipv6: Use nlmsg_payload in inet6_valid_dump_ifaddr_req
ipv6: Use nlmsg_payload in inet6_rtm_valid_getaddr_req
mpls: Use nlmsg_payload in mpls_valid_getroute_req
net: fib_rules: Use nlmsg_payload in fib_valid_dumprule_req
net: fib_rules: Use nlmsg_payload in fib_{new,del}rule()

 include/net/netlink.h | 16 ++++++++++++++++
 net/core/fib_rules.c  | 14 ++++++++------
 net/core/neighbour.c  |  8 ++++----
 net/core/rtnetlink.c  |  4 ++--
 net/ipv6/addrconf.c   |  8 ++++----
 net/mpls/af_mpls.c    |  8 ++++----
 6 files changed, 38 insertions(+), 20 deletions(-)

---
base-commit: 6a325aed130bb68790e765f923e76ec5669d2da7
change-id: 20250411-nlmsg-2dd8c30ba35c

Best regards,

Signature · 1 line
Breno Leitao <[email protected]>