Skip to content

Commit d2ffed5

Browse files
geertugregkh
authored andcommitted
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 4efe874 ("PCI: Don't read past the end of sysfs "driver_override" buffer") and bf563b0 ("driver core: platform: Don't read past the end of "driver_override" buffer"). Fixes: 3cf3857 ("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>
1 parent 6b614a8 commit d2ffed5

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎drivers/amba/bus.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ static ssize_t driver_override_store(struct device *_dev,
8787
struct amba_device *dev = to_amba_device(_dev);
8888
char *driver_override, *old, *cp;
8989

90-
if (count > PATH_MAX)
90+
/* We need to keep extra room for a newline */
91+
if (count >= (PAGE_SIZE - 1))
9192
return -EINVAL;
9293

9394
driver_override = kstrndup(buf, count, GFP_KERNEL);

0 commit comments

Comments
 (0)