[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221018230728.1039524-5-kuba@kernel.org>
Date: Tue, 18 Oct 2022 16:07:19 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: davem@...emloft.net, johannes@...solutions.net
Cc: netdev@...r.kernel.org, edumazet@...gle.com, pabeni@...hat.com,
jiri@...nulli.us, razor@...ckwall.org, nicolas.dichtel@...nd.com,
gnault@...hat.com, jacob.e.keller@...el.com, fw@...len.de,
Jakub Kicinski <kuba@...nel.org>
Subject: [PATCH net-next 04/13] genetlink: load policy based on validation flags
Set the policy and maxattr pointers based on validation flags.
Signed-off-by: Jakub Kicinski <kuba@...nel.org>
---
net/netlink/genetlink.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 23d3682d8f94..26ddbd23549d 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -181,8 +181,14 @@ genl_cmd_full_to_split(struct genl_split_ops *op,
op->post_doit = family->post_doit;
}
- op->policy = full->policy;
- op->maxattr = full->maxattr;
+ if (flags & GENL_CMD_CAP_DUMP &&
+ full->validate & GENL_DONT_VALIDATE_DUMP) {
+ op->policy = NULL;
+ op->maxattr = 0;
+ } else {
+ op->policy = full->policy;
+ op->maxattr = full->maxattr;
+ }
op->cmd = full->cmd;
op->internal_flags = full->internal_flags;
@@ -612,10 +618,8 @@ static int genl_start(struct netlink_callback *cb)
int rc = 0;
ops = ctx->ops;
- if (ops->validate & GENL_DONT_VALIDATE_DUMP)
- goto no_attrs;
-
- if (ctx->nlh->nlmsg_len < nlmsg_msg_size(ctx->hdrlen))
+ if (!(ops->validate & GENL_DONT_VALIDATE_DUMP) &&
+ ctx->nlh->nlmsg_len < nlmsg_msg_size(ctx->hdrlen))
return -EINVAL;
attrs = genl_family_rcv_msg_attrs_parse(ctx->family, ctx->nlh, ctx->extack,
@@ -624,7 +628,6 @@ static int genl_start(struct netlink_callback *cb)
if (IS_ERR(attrs))
return PTR_ERR(attrs);
-no_attrs:
info = genl_dumpit_info_alloc();
if (!info) {
genl_family_rcv_msg_attrs_free(attrs);
--
2.37.3
Powered by blists - more mailing lists