diff options
Diffstat (limited to 'kernel/taskstats.c')
-rw-r--r-- | kernel/taskstats.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/kernel/taskstats.c b/kernel/taskstats.c index 4e62a4a8fa91..1b942a7caf26 100644 --- a/kernel/taskstats.c +++ b/kernel/taskstats.c | |||
@@ -650,16 +650,37 @@ static const struct genl_ops taskstats_ops[] = { | |||
650 | { | 650 | { |
651 | .cmd = TASKSTATS_CMD_GET, | 651 | .cmd = TASKSTATS_CMD_GET, |
652 | .doit = taskstats_user_cmd, | 652 | .doit = taskstats_user_cmd, |
653 | .policy = taskstats_cmd_get_policy, | 653 | /* policy enforced later */ |
654 | .flags = GENL_ADMIN_PERM, | 654 | .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_HASPOL, |
655 | }, | 655 | }, |
656 | { | 656 | { |
657 | .cmd = CGROUPSTATS_CMD_GET, | 657 | .cmd = CGROUPSTATS_CMD_GET, |
658 | .doit = cgroupstats_user_cmd, | 658 | .doit = cgroupstats_user_cmd, |
659 | .policy = cgroupstats_cmd_get_policy, | 659 | /* policy enforced later */ |
660 | .flags = GENL_CMD_CAP_HASPOL, | ||
660 | }, | 661 | }, |
661 | }; | 662 | }; |
662 | 663 | ||
664 | static int taskstats_pre_doit(const struct genl_ops *ops, struct sk_buff *skb, | ||
665 | struct genl_info *info) | ||
666 | { | ||
667 | const struct nla_policy *policy = NULL; | ||
668 | |||
669 | switch (ops->cmd) { | ||
670 | case TASKSTATS_CMD_GET: | ||
671 | policy = taskstats_cmd_get_policy; | ||
672 | break; | ||
673 | case CGROUPSTATS_CMD_GET: | ||
674 | policy = cgroupstats_cmd_get_policy; | ||
675 | break; | ||
676 | default: | ||
677 | return -EINVAL; | ||
678 | } | ||
679 | |||
680 | return nlmsg_validate(info->nlhdr, GENL_HDRLEN, TASKSTATS_CMD_ATTR_MAX, | ||
681 | policy, info->extack); | ||
682 | } | ||
683 | |||
663 | static struct genl_family family __ro_after_init = { | 684 | static struct genl_family family __ro_after_init = { |
664 | .name = TASKSTATS_GENL_NAME, | 685 | .name = TASKSTATS_GENL_NAME, |
665 | .version = TASKSTATS_GENL_VERSION, | 686 | .version = TASKSTATS_GENL_VERSION, |
@@ -667,6 +688,7 @@ static struct genl_family family __ro_after_init = { | |||
667 | .module = THIS_MODULE, | 688 | .module = THIS_MODULE, |
668 | .ops = taskstats_ops, | 689 | .ops = taskstats_ops, |
669 | .n_ops = ARRAY_SIZE(taskstats_ops), | 690 | .n_ops = ARRAY_SIZE(taskstats_ops), |
691 | .pre_doit = taskstats_pre_doit, | ||
670 | }; | 692 | }; |
671 | 693 | ||
672 | /* Needed early in initialization */ | 694 | /* Needed early in initialization */ |