.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * taskstats.c - Export per-task statistics to userland |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) Shailabh Nagar, IBM Corp. 2006 |
---|
5 | 6 | * (C) Balbir Singh, IBM Corp. 2006 |
---|
6 | | - * |
---|
7 | | - * This program is free software; you can redistribute it and/or modify |
---|
8 | | - * it under the terms of the GNU General Public License as published by |
---|
9 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
10 | | - * (at your option) any later version. |
---|
11 | | - * |
---|
12 | | - * This program is distributed in the hope that it will be useful, |
---|
13 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | | - * GNU General Public License for more details. |
---|
16 | | - * |
---|
17 | 7 | */ |
---|
18 | 8 | |
---|
19 | 9 | #include <linux/kernel.h> |
---|
.. | .. |
---|
44 | 34 | |
---|
45 | 35 | static struct genl_family family; |
---|
46 | 36 | |
---|
47 | | -static const struct nla_policy taskstats_cmd_get_policy[TASKSTATS_CMD_ATTR_MAX+1] = { |
---|
| 37 | +static const struct nla_policy taskstats_cmd_get_policy[] = { |
---|
48 | 38 | [TASKSTATS_CMD_ATTR_PID] = { .type = NLA_U32 }, |
---|
49 | 39 | [TASKSTATS_CMD_ATTR_TGID] = { .type = NLA_U32 }, |
---|
50 | 40 | [TASKSTATS_CMD_ATTR_REGISTER_CPUMASK] = { .type = NLA_STRING }, |
---|
51 | 41 | [TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK] = { .type = NLA_STRING },}; |
---|
52 | 42 | |
---|
53 | | -/* |
---|
54 | | - * We have to use TASKSTATS_CMD_ATTR_MAX here, it is the maxattr in the family. |
---|
55 | | - * Make sure they are always aligned. |
---|
56 | | - */ |
---|
57 | | -static const struct nla_policy cgroupstats_cmd_get_policy[TASKSTATS_CMD_ATTR_MAX+1] = { |
---|
| 43 | +static const struct nla_policy cgroupstats_cmd_get_policy[] = { |
---|
58 | 44 | [CGROUPSTATS_CMD_ATTR_FD] = { .type = NLA_U32 }, |
---|
59 | 45 | }; |
---|
60 | 46 | |
---|
.. | .. |
---|
375 | 361 | ? TASKSTATS_TYPE_AGGR_PID |
---|
376 | 362 | : TASKSTATS_TYPE_AGGR_TGID; |
---|
377 | 363 | |
---|
378 | | - na = nla_nest_start(skb, aggr); |
---|
| 364 | + na = nla_nest_start_noflag(skb, aggr); |
---|
379 | 365 | if (!na) |
---|
380 | 366 | goto err; |
---|
381 | 367 | |
---|
.. | .. |
---|
657 | 643 | static const struct genl_ops taskstats_ops[] = { |
---|
658 | 644 | { |
---|
659 | 645 | .cmd = TASKSTATS_CMD_GET, |
---|
| 646 | + .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, |
---|
660 | 647 | .doit = taskstats_user_cmd, |
---|
661 | 648 | .policy = taskstats_cmd_get_policy, |
---|
| 649 | + .maxattr = ARRAY_SIZE(taskstats_cmd_get_policy) - 1, |
---|
662 | 650 | .flags = GENL_ADMIN_PERM, |
---|
663 | 651 | }, |
---|
664 | 652 | { |
---|
665 | 653 | .cmd = CGROUPSTATS_CMD_GET, |
---|
| 654 | + .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, |
---|
666 | 655 | .doit = cgroupstats_user_cmd, |
---|
667 | 656 | .policy = cgroupstats_cmd_get_policy, |
---|
| 657 | + .maxattr = ARRAY_SIZE(cgroupstats_cmd_get_policy) - 1, |
---|
668 | 658 | }, |
---|
669 | 659 | }; |
---|
670 | 660 | |
---|
671 | 661 | static struct genl_family family __ro_after_init = { |
---|
672 | 662 | .name = TASKSTATS_GENL_NAME, |
---|
673 | 663 | .version = TASKSTATS_GENL_VERSION, |
---|
674 | | - .maxattr = TASKSTATS_CMD_ATTR_MAX, |
---|
675 | 664 | .module = THIS_MODULE, |
---|
676 | 665 | .ops = taskstats_ops, |
---|
677 | 666 | .n_ops = ARRAY_SIZE(taskstats_ops), |
---|