• Chiara Meiohas's avatar
    RDMA/nldev: Enhance netlink message parsing and validation · df6d27a3
    Chiara Meiohas authored
    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: default avatarChiara Meiohas <cmeiohas@nvidia.com>
    Reviewed-by: default avatarMichael Guralnik <michaelgur@nvidia.com>
    Link: https://lore.kernel.org/r/f633a979a49db090d05c24a3ba83d30727bb777b.1722331020.git.leon@kernel.orgSigned-off-by: default avatarLeon Romanovsky <leon@kernel.org>
    df6d27a3
nldev.c 70.9 KB