]> git.baikalelectronics.ru Git - kernel.git/commit
taskstats: fix the length of cgroupstats_cmd_get_policy
authorWANG Cong <xiyou.wangcong@gmail.com>
Thu, 3 Nov 2016 16:42:36 +0000 (09:42 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 3 Nov 2016 20:55:58 +0000 (16:55 -0400)
commit0d1901a91313db9665fdbb99c939285863e32ff7
treed8437d736ef3723ae9fd58aaf67d7324b2433286
parent3fb7b5783fab2c49db4c87774891e74d5cbd3385
taskstats: fix the length of cgroupstats_cmd_get_policy

cgroupstats_cmd_get_policy is [CGROUPSTATS_CMD_ATTR_MAX+1],
taskstats_cmd_get_policy[TASKSTATS_CMD_ATTR_MAX+1],
but their family.maxattr is TASKSTATS_CMD_ATTR_MAX.
CGROUPSTATS_CMD_ATTR_MAX is less than TASKSTATS_CMD_ATTR_MAX,
so we could end up accessing out-of-bound.

Change cgroupstats_cmd_get_policy to TASKSTATS_CMD_ATTR_MAX+1,
this is safe because the rest are initialized to 0's.

Reported-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
kernel/taskstats.c