diff options
author | Jiri Pirko <jiri@nvidia.com> | 2023-07-20 14:13:54 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2023-07-22 04:49:12 +0300 |
commit | 5766946ea5117e4edeb78c80cac367fb06854cc1 (patch) | |
tree | 2872d4031495f4056009058d76b2f1b95a4d8000 /net/netlink | |
parent | 070e8bd31b288c3aa3f965778417708c8bfedb06 (diff) | |
download | linux-5766946ea5117e4edeb78c80cac367fb06854cc1.tar.xz |
genetlink: add explicit ordering break check for split ops
Currently, if cmd in the split ops array is of lower value than the
previous one, genl_validate_ops() continues to do the checks as if
the values are equal. This may result in non-obvious WARN_ON() hit in
these check.
Instead, check the incorrect ordering explicitly and put a WARN_ON()
in case it is broken.
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://lore.kernel.org/r/20230720111354.562242-1-jiri@resnulli.us
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/netlink')
-rw-r--r-- | net/netlink/genetlink.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index a157247a1e45..6bd2ce51271f 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c @@ -593,8 +593,12 @@ static int genl_validate_ops(const struct genl_family *family) return -EINVAL; /* Check sort order */ - if (a->cmd < b->cmd) + if (a->cmd < b->cmd) { continue; + } else if (a->cmd > b->cmd) { + WARN_ON(1); + return -EINVAL; + } if (a->internal_flags != b->internal_flags || ((a->flags ^ b->flags) & ~(GENL_CMD_CAP_DO | |