genetlink: limit the use of validation workarounds to old ops
authorJakub Kicinski <kuba@kernel.org>
Wed, 26 Oct 2022 00:15:24 +0000 (17:15 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 27 Oct 2022 15:20:21 +0000 (08:20 -0700)
During review of previous change another thing came up - we should
limit the use of validation workarounds to old commands.
Don't list the workarounds one by one, as we're rejecting all existing
ones. We can deal with the masking in the unlikely event that new flag
is added.

Link: https://lore.kernel.org/all/6ba9f727e555fd376623a298d5d305ad408c3d47.camel@sipsolutions.net/
Link: https://lore.kernel.org/r/20221026001524.1892202-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/netlink/genetlink.c

index b1fd059..3e16527 100644 (file)
@@ -380,6 +380,8 @@ static int genl_validate_ops(const struct genl_family *family)
                genl_get_cmd_by_index(i, family, &op);
                if (op.dumpit == NULL && op.doit == NULL)
                        return -EINVAL;
+               if (WARN_ON(op.cmd >= family->resv_start_op && op.validate))
+                       return -EINVAL;
                for (j = i + 1; j < genl_get_cmd_cnt(family); j++) {
                        struct genl_ops op2;