]> www.infradead.org Git - users/jedix/linux-maple.git/commit
RDMA/nldev: Enhance netlink message parsing and validation
authorChiara Meiohas <cmeiohas@nvidia.com>
Tue, 30 Jul 2024 09:17:25 +0000 (12:17 +0300)
committerLeon Romanovsky <leon@kernel.org>
Sun, 11 Aug 2024 08:12:49 +0000 (11:12 +0300)
commitdf6d27a30970158466b632c82da09a9b24c30f4b
tree02ab77cfd9ef1f0c7c2bc3dc660ff0b491dcd30e
parent2a777679b8ccd09a9a65ea0716ef10365179caac
RDMA/nldev: Enhance netlink message parsing and validation

Use strict parsing validation for set commands, and liberal
validation for get commands. Additionally, remove all usage of
nlmsg_parse_depricate().

Strict parsing validation fails when encountering unrecognized
attributes in the Netlink message, while liberal parsing
validation ignores them.

In 57d7a8fd904c ("rdma: Add an option to display driver-specific QPs in the rdma tool")
in iproute2, the attribute RDMA_NLDEV_ATTR_DRIVER_DETAILS
was added. This cause backwards compatibility issues when using
the rdma tool with the new attribute and an older kernel which does
recognize this attribute.
In this case, the command "rdma stat show mr" would fail, because the
new rdma tool would fill the netlink message with the new attribute and
the older kernel would fail as it used strict parsing and did not
recognize the new attribute.

In general, strict validation is appropriate for set commands as they
modify the system, while liberal validation is suitable for get
commands which only query system information.

Replace all uses of nlmsg_parse_deprecated() with __nlmsg_parse(),
using the NL_VALIDATE_LIBERAL flag.
The nlmsg_parse_deprecated() function internally calls
__nlmsg_parse() with the NL_VALIDATE_LIBERAL flag, but its name
is confusing.

Signed-off-by: Chiara Meiohas <cmeiohas@nvidia.com>
Reviewed-by: Michael Guralnik <michaelgur@nvidia.com>
Link: https://lore.kernel.org/r/f633a979a49db090d05c24a3ba83d30727bb777b.1722331020.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/core/nldev.c