[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1431455457-25322-3-git-send-email-mcgrof@do-not-panic.com>
Date: Tue, 12 May 2015 11:30:54 -0700
From: "Luis R. Rodriguez" <mcgrof@...not-panic.com>
To: ming.lei@...onical.com, rusty@...tcorp.com.au
Cc: dhowells@...hat.com, seth.forshee@...onical.com,
torvalds@...ux-foundation.org, linux-kernel@...r.kernel.org,
pebolle@...cali.nl, linux-wireless@...r.kernel.org,
"Luis R. Rodriguez" <mcgrof@...e.com>,
Kyle McMartin <kyle@...nel.org>
Subject: [PATCH v2 2/5] firmware: check for file truncation on direct firmware loading
From: "Luis R. Rodriguez" <mcgrof@...e.com>
When direct firmware loading is used we iterate over a list
of possible firmware paths and concatenate the desired firmware
name with each path and look for the file there. Should the
passed firmware name be too long we end up truncating the
file we want to look for, the search however is still done.
Add a check for truncation instead of looking for a
truncated firmware filename.
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Ming Lei <ming.lei@...onical.com>
Cc: Rusty Russell <rusty@...tcorp.com.au>
Cc: David Howells <dhowells@...hat.com>
Cc: Kyle McMartin <kyle@...nel.org>
Signed-off-by: Luis R. Rodriguez <mcgrof@...e.com>
---
drivers/base/firmware_class.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index bc6c8e6..99385fc 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -320,7 +320,7 @@ fail:
static int fw_get_filesystem_firmware(struct device *device,
struct firmware_buf *buf)
{
- int i;
+ int i, len;
int rc = -ENOENT;
char *path;
@@ -335,7 +335,12 @@ static int fw_get_filesystem_firmware(struct device *device,
if (!fw_path[i][0])
continue;
- snprintf(path, PATH_MAX, "%s/%s", fw_path[i], buf->fw_id);
+ len = snprintf(path, PATH_MAX, "%s/%s",
+ fw_path[i], buf->fw_id);
+ if (len >= PATH_MAX) {
+ rc = -ENAMETOOLONG;
+ break;
+ }
file = filp_open(path, O_RDONLY, 0);
if (IS_ERR(file))
--
2.3.2.209.gd67f9d5.dirty
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists