Skip to contentSkip to conversation

of: avoid format string parsing in kobject names

PATCH Applied Kees Cook 2 participants 3 messages Jun 10, 2014 – Jun 13, 2014 Device tree

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 of: avoid format string parsing in kobject names

This makes sure a format string cannot leak into the kobject name that is constructed. (And splits the >80 character line.)

---
 drivers/of/base.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/of/base.c +2 -1
index 8368d96ae7b4..f27d922eaece 100644
@@ -227,7 +227,8 @@ static int __of_node_add(struct device_node *np)
 	np->kobj.kset = of_kset;
 	if (!np->parent) {
 		/* Nodes without parents are new top level trees */
-		rc = kobject_add(&np->kobj, NULL, safe_name(&of_kset->kobj, "base"));
+		rc = kobject_add(&np->kobj, NULL, "%s",
+				 safe_name(&of_kset->kobj, "base"));
 	} else {
 		name = safe_name(&np->parent->kobj, kbasename(np->full_name));
 		if (!name || !name[0])
Signature · 6 lines
1.7.9.5


-- 
Kees Cook
Chrome OS Security
Applied
#1 lore raw
Quoted 4 lines · Kees Cook

This makes sure a format string cannot leak into the kobject name that is constructed. (And splits the >80 character line.)

Applied.

This seems like a non-obvious thing to do, but I guess most people aren't dealing directly with kobjects.

Rob

Quoted 25 lines
---
 drivers/of/base.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/of/base.c +2 -2
index 8368d96ae7b4..f27d922eaece 100644
@@ -227,7 +227,8 @@ static int __of_node_add(struct device_node *np)
        np->kobj.kset = of_kset;
        if (!np->parent) {
                /* Nodes without parents are new top level trees */
-               rc = kobject_add(&np->kobj, NULL, safe_name(&of_kset->kobj, "base"));
+               rc = kobject_add(&np->kobj, NULL, "%s",
+                                safe_name(&of_kset->kobj, "base"));
        } else {
                name = safe_name(&np->parent->kobj, kbasename(np->full_name));
                if (!name || !name[0])
--

1.7.9.5

--
Kees Cook
Chrome OS Security

author
#2 lore raw
Quoted 10 lines · Rob Herring
Quoted 4 lines · Kees Cook

This makes sure a format string cannot leak into the kobject name that is constructed. (And splits the >80 character line.)

Applied.

This seems like a non-obvious thing to do, but I guess most people aren't dealing directly with kobjects.

Yeah, it's really unlikely this could get reached, but I just keep cleaning this up any time I see them just to be safe. :)

Thanks!

-Kees

Signature · 2 lines
Kees Cook
Chrome OS Security