提交 8d361fa2 编写于 作者: K Kees Cook 提交者: Greg Kroah-Hartman

usb: typec: tps6598x: Remove VLA usage

In the quest to remove all stack VLA usage from the kernel[1], this
uses the maximum buffer size and adds a sanity check. While 25 bytes
is the size of the largest current things coming through, Heikki
Krogerus pointed out that the actual max in 64 bytes, as per ch 1.3.2
http://www.ti.com/lit/ug/slvuan1a/slvuan1a.pdf

[1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.comSigned-off-by: NKees Cook <keescook@chromium.org>
Acked-by: NHeikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 579b9cca
...@@ -81,12 +81,21 @@ struct tps6598x { ...@@ -81,12 +81,21 @@ struct tps6598x {
struct typec_capability typec_cap; struct typec_capability typec_cap;
}; };
/*
* Max data bytes for Data1, Data2, and other registers. See ch 1.3.2:
* http://www.ti.com/lit/ug/slvuan1a/slvuan1a.pdf
*/
#define TPS_MAX_LEN 64
static int static int
tps6598x_block_read(struct tps6598x *tps, u8 reg, void *val, size_t len) tps6598x_block_read(struct tps6598x *tps, u8 reg, void *val, size_t len)
{ {
u8 data[len + 1]; u8 data[TPS_MAX_LEN + 1];
int ret; int ret;
if (WARN_ON(len + 1 > sizeof(data)))
return -EINVAL;
if (!tps->i2c_protocol) if (!tps->i2c_protocol)
return regmap_raw_read(tps->regmap, reg, val, len); return regmap_raw_read(tps->regmap, reg, val, len);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册