All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert+renesas@glider.be>
To: Russell King <linux@armlinux.org.uk>
Cc: Antonios Motakis <a.motakis@virtualopensystems.com>,
	Adrian Salido <salidoa@google.com>,
	Sasha Levin <sasha.levin@oracle.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org,
	Geert Uytterhoeven <geert+renesas@glider.be>
Subject: [PATCH 3/4] ARM: amba: Don't read past the end of sysfs "driver_override" buffer
Date: Fri, 19 Jan 2018 16:24:09 +0100	[thread overview]
Message-ID: <1516375450-30575-4-git-send-email-geert+renesas@glider.be> (raw)
In-Reply-To: <1516375450-30575-1-git-send-email-geert+renesas@glider.be>

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>
---
 drivers/amba/bus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 36c5653ced5742b7..4a3ac31c07d0ee49 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -84,7 +84,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);
-- 
2.7.4

  parent reply	other threads:[~2018-01-19 15:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-19 15:24 [PATCH 0/4] ARM: amba: driver_override improvements Geert Uytterhoeven
2018-01-19 15:24 ` [PATCH 1/4] ARM: amba: Make driver_override output consistent with other buses Geert Uytterhoeven
2018-01-19 15:24 ` [PATCH 2/4] ARM: amba: Fix race condition with driver_override Geert Uytterhoeven
2018-03-02 18:23   ` Todd Kjos
2018-03-05  8:08     ` Geert Uytterhoeven
2018-01-19 15:24 ` Geert Uytterhoeven [this message]
2018-01-19 15:24 ` [PATCH 4/4] ARM: amba: Fix wrong indentation in driver_override_store() Geert Uytterhoeven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1516375450-30575-4-git-send-email-geert+renesas@glider.be \
    --to=geert+renesas@glider.be \
    --cc=a.motakis@virtualopensystems.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=salidoa@google.com \
    --cc=sasha.levin@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.