Skip to content

genetlink: Reject joining multicast groups no family owns

Anil Kaushik linux-kselftest lkml netdev 8 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v8 Latest2 patches 0 repliesNew
  2. v72 patches 0 repliesSuperseded
  3. v61 patch 3 repliesSuperseded
Earlier versions · 5
VersionPostedPatchesRepliesStatus
v52 patches2 repliesSuperseded
v42 patches4 repliesSuperseded
v32 patches1 replySuperseded
v22 patches0 repliesSuperseded
v11 patch4 repliesSuperseded

Changes in v8 from the cover letter

- In the selftest, read the group memberships in host byte order, so it also works on big-endian (Sashiko).
- Skip the selftest outside the initial network namespace: the family dump there does not list the families that are not netnsok, so it could take one of their groups as free (Sashiko).
- Close the selftest sockets, also when a check is skipped (Sashiko).
- Skip the drop_monitor check when NET_DM gets no group ID that was free, so it cannot pass without testing anything (Sashiko).
- Rebase on net.

Patches in v8 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2genetlink: Reject joining multicast groups no family ownsinclude/linux/netlink.h include/uapi/linux/net_dropmon.h net/netlink/af_netlink.c +1 more+15 -10 replies
2/2selftests: net: test joining genetlink groups no family ownstools/testing/selftests/net/Makefile tools/testing/selftests/net/nl_genl_mcast.py+128 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v8 yet.

Read the v8 thread

Cover letter [PATCH net v8 0/2] genetlink: Reject joining multicast groups no family owns

genl_bind() lets any user join a multicast group ID that no family owns. A family registered later can get that ID, and the socket stays a member without a capability check. Patch 1 makes genl_bind() return -ENOENT for such an ID. Patch 2 adds a selftest for it.

v8:
- In the selftest, read the group memberships in host byte order, so it also works on big-endian (Sashiko).
- Skip the selftest outside the initial network namespace: the family dump there does not list the families that are not netnsok, so it could take one of their groups as free (Sashiko).
- Close the selftest sockets, also when a check is skipped (Sashiko).
- Skip the drop_monitor check when NET_DM gets no group ID that was free, so it cannot pass without testing anything (Sashiko).
- Rebase on net.

v7: https://lore.kernel.org/netdev/[email protected]/
- Add a selftest as patch 2, as Nicolas asked.
- Say in the comments on the static IDs, and on NET_DM_GRP_ALERT, that
they can be joined only after the family is registered (Sashiko).
- Say in the commit message that the unregister window was already
there for the capability check.

v6: https://lore.kernel.org/netdev/[email protected]/

I used an LLM to help write and review the code, the tests and the commit messages of this series. I checked and tested every change myself.

Anil Kaushik (2):
genetlink: Reject joining multicast groups no family owns
selftests: net: test joining genetlink groups no family owns

 include/linux/netlink.h                      |   3 +
 include/uapi/linux/net_dropmon.h             |   2 +
 net/netlink/af_netlink.c                     |   6 +
 net/netlink/genetlink.c                      |   5 +-
 tools/testing/selftests/net/Makefile         |   1 +
 tools/testing/selftests/net/nl_genl_mcast.py | 127 +++++++++++++++++++
 6 files changed, 143 insertions(+), 1 deletion(-)
 create mode 100755 tools/testing/selftests/net/nl_genl_mcast.py

base-commit: 7b0c5f0c757cb61e28dc4128633877aaa8f6f9bd

Signature · 1 line
2.25.1