提交 d2ffed51 编写于 作者: G Geert Uytterhoeven 提交者: Greg Kroah-Hartman

ARM: amba: Don't read past the end of sysfs "driver_override" buffer

When printing the driver_override parameter when it is 4095 and 4094
bytes long, the printing code would access invalid memory because we
need count + 1 bytes for printing.

Cfr. commits 4efe874a ("PCI: Don't read past the end of sysfs
"driver_override" buffer") and bf563b01 ("driver core: platform:
Don't read past the end of "driver_override" buffer").

Fixes: 3cf38571 ("ARM: 8256/1: driver coamba: add device binding path 'driver_override'")
Signed-off-by: NGeert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: NTodd Kjos <tkjos@google.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 6b614a87
...@@ -87,7 +87,8 @@ static ssize_t driver_override_store(struct device *_dev, ...@@ -87,7 +87,8 @@ static ssize_t driver_override_store(struct device *_dev,
struct amba_device *dev = to_amba_device(_dev); struct amba_device *dev = to_amba_device(_dev);
char *driver_override, *old, *cp; char *driver_override, *old, *cp;
if (count > PATH_MAX) /* We need to keep extra room for a newline */
if (count >= (PAGE_SIZE - 1))
return -EINVAL; return -EINVAL;
driver_override = kstrndup(buf, count, GFP_KERNEL); driver_override = kstrndup(buf, count, GFP_KERNEL);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册