提交 0a3475eb 编写于 作者: X Xi Wang 提交者: Mauro Carvalho Chehab

[media] v4l2-ctrls: fix integer overflow in try_set_ext_ctrls()

A large cs->count from userspace may overflow the allocation size,
leading to memory corruption.  try_set_ext_ctrls() can be reached
from subdev_do_ioctl() or __video_do_ioctl().

Use kmalloc_array() to avoid the overflow.
Signed-off-by: NXi Wang <xi.wang@gmail.com>
Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
上级 5f0049bd
......@@ -2259,7 +2259,8 @@ static int try_set_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
return class_check(hdl, cs->ctrl_class);
if (cs->count > ARRAY_SIZE(helper)) {
helpers = kmalloc(sizeof(helper[0]) * cs->count, GFP_KERNEL);
helpers = kmalloc_array(cs->count, sizeof(helper[0]),
GFP_KERNEL);
if (!helpers)
return -ENOMEM;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册