Skip to contentSkip to conversation

sparc: use %s for unaligned panic

PATCH Superseded Kees Cook 3 participants 3 messages Mar 11, 2014 – Mar 17, 2014 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 sparc: use %s for unaligned panic

Since unaligned_panic() takes a literal string, make sure it can never accidentally be used as a format string.

---
 arch/sparc/kernel/unaligned_32.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/kernel/unaligned_32.c +1 -1
index c0ec89786193..892e399414e0 100644
@@ -162,7 +162,7 @@ unsigned long safe_compute_effective_address(struct pt_regs *regs,
 /* This is just to make gcc think panic does return... */
 static void unaligned_panic(char *str)
 {
-	panic(str);
+	panic("%s", str);
 }
 
 /* una_asm.S */
Signature · 6 lines
1.7.9.5


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

Since unaligned_panic() takes a literal string, make sure it can never accidentally be used as a format string.

---
 arch/sparc/kernel/unaligned_32.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/kernel/unaligned_32.c +0 -0
index c0ec89786193..892e399414e0 100644

arch/sparc/kernel/unaligned_32.c unsigned long safe_compute_effective_address(struct pt_regs *regs, · line 168

Quoted 8 lines
arch/sparc/kernel/unaligned_32.c +1 -1
@@ -162,7 +162,7 @@ unsigned long safe_compute_effective_address(struct pt_regs *regs,
 /* This is just to make gcc think panic does return... */
 static void unaligned_panic(char *str)
 {
-	panic(str);
+	panic("%s", str);
 }
 
 /* una_asm.S */

Another "fix" would be to align with sparc64 and call die_if_kernel()

Sam

maintainer
#2 lore raw

From: Sam Ravnborg <[email protected]>
Date: Sat, 15 Mar 2014 09:07:09 +0100

Quoted 21 lines · Kees Cook
Quoted 20 lines

Since unaligned_panic() takes a literal string, make sure it can never accidentally be used as a format string.

---
 arch/sparc/kernel/unaligned_32.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/kernel/unaligned_32.c +1 -1
index c0ec89786193..892e399414e0 100644
@@ -162,7 +162,7 @@ unsigned long safe_compute_effective_address(struct pt_regs *regs,
 /* This is just to make gcc think panic does return... */
 static void unaligned_panic(char *str)
 {
-	panic(str);
+	panic("%s", str);
 }
 
Quoted 3 lines

arch/sparc/kernel/unaligned_32.c unsigned long safe_compute_effective_address(struct pt_regs *regs, · line 168

Quoted 1 line
arch/sparc/kernel/unaligned_32.c +0 -0
 /* una_asm.S */

Another "fix" would be to align with sparc64 and call die_if_kernel()

Furthermore, this is a silly change because there are only two call sites, they are both in this file, and they clearly do not pass format strings embedded in the string.