diff options
author | Geert Uytterhoeven <geert+renesas@glider.be> | 2018-04-10 15:21:45 +0200 |
---|---|---|
committer | Sasha Levin <alexander.levin@microsoft.com> | 2018-05-22 21:36:39 -0400 |
commit | dbb94eebe42ac07eaee43afc23acdd0bf5674036 (patch) | |
tree | 0ca95f8f23a40bb9511a601977d5e2e379f5d718 | |
parent | 1d4ddc30e2b52aeb1b42c1c1a35b4b3792ce162e (diff) | |
download | linux-stable-dbb94eebe42ac07eaee43afc23acdd0bf5674036.tar.gz |
ARM: amba: Don't read past the end of sysfs "driver_override" buffer
[ Upstream commit d2ffed5185df9d8d9ccd150e4340e3b6f96a8381 ]
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 4efe874aace57dba ("PCI: Don't read past the end of sysfs
"driver_override" buffer") and bf563b01c2895a4b ("driver core: platform:
Don't read past the end of "driver_override" buffer").
Fixes: 3cf385713460eb2b ("ARM: 8256/1: driver coamba: add device binding path 'driver_override'")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Todd Kjos <tkjos@google.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
-rw-r--r-- | drivers/amba/bus.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index 13727fc250d5..1accc01fb0ca 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c @@ -83,7 +83,8 @@ static ssize_t driver_override_store(struct device *_dev, struct amba_device *dev = to_amba_device(_dev); 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; driver_override = kstrndup(buf, count, GFP_KERNEL); |