[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <dd64d12079ec788d337b17840e54f0fc60d3b8ce.1451990751.git.viresh.kumar@linaro.org>
Date: Tue, 5 Jan 2016 16:15:54 +0530
From: Viresh Kumar <viresh.kumar@...aro.org>
To: Rafael Wysocki <rjw@...ysocki.net>
Cc: linaro-kernel@...ts.linaro.org, linux-pm@...r.kernel.org,
Viresh Kumar <viresh.kumar@...aro.org>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Len Brown <len.brown@...el.com>,
linux-kernel@...r.kernel.org (open list),
Nishanth Menon <nm@...com>, Pavel Machek <pavel@....cz>,
Stephen Boyd <sboyd@...eaurora.org>,
Viresh Kumar <vireshk@...nel.org>
Subject: [PATCH] PM / OPP: Use snprintf() instead of sprintf()
sprintf() can access memory outside of the range of the character array,
and is risky in some situations. The driver specified prop_name string
can be longer than NAME_MAX here (only an attacker will do that though)
and so blindly copying it into the character array of size NAME_MAX
isn't safe. Instead we must use snprintf() here.
Reported-by: Geert Uytterhoeven <geert@...ux-m68k.org>
Signed-off-by: Viresh Kumar <viresh.kumar@...aro.org>
---
drivers/base/power/opp/core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
index cd230c63aee6..cf351d3dab1c 100644
--- a/drivers/base/power/opp/core.c
+++ b/drivers/base/power/opp/core.c
@@ -808,7 +808,8 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev,
/* Search for "opp-microvolt-<name>" */
if (dev_opp->prop_name) {
- sprintf(name, "opp-microvolt-%s", dev_opp->prop_name);
+ snprintf(name, sizeof(name), "opp-microvolt-%s",
+ dev_opp->prop_name);
prop = of_find_property(opp->np, name, NULL);
}
@@ -849,7 +850,8 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev,
/* Search for "opp-microamp-<name>" */
prop = NULL;
if (dev_opp->prop_name) {
- sprintf(name, "opp-microamp-%s", dev_opp->prop_name);
+ snprintf(name, sizeof(name), "opp-microamp-%s",
+ dev_opp->prop_name);
prop = of_find_property(opp->np, name, NULL);
}
--
2.7.0.rc1.186.g94414c4
--
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