mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 13:14:02 +02:00
RDMA/nldev: validate dynamic counter attribute length
RDMA_NLDEV_ATTR_STAT_HWCOUNTERS is a nested attribute whose children are
consumed directly with nla_get_u32(). The top-level policy validates only
the container, so it does not establish the fixed shape of each child.
Require every child payload to be exactly one u32 before reading it.
Fixes: 3c3c1f1416 ("RDMA/nldev: Allow optional-counter status configuration through RDMA netlink")
Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Link: https://patch.msgid.link/20260720114918.70323-1-pengpeng@iscas.ac.cn
Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
parent
28a06de731
commit
74f4925549
|
|
@ -2157,6 +2157,11 @@ static int nldev_stat_set_counter_dynamic_doit(struct nlattr *tb[],
|
|||
|
||||
nla_for_each_nested(entry_attr, tb[RDMA_NLDEV_ATTR_STAT_HWCOUNTERS],
|
||||
rem) {
|
||||
if (nla_len(entry_attr) != sizeof(u32)) {
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
index = nla_get_u32(entry_attr);
|
||||
if ((index >= stats->num_counters) ||
|
||||
!(stats->descs[index].flags & IB_STAT_FLAG_OPTIONAL)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user