mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sparc: use %s for unaligned panic
@ 2014-03-11 20:24 Kees Cook
  2014-03-15  8:07 ` Sam Ravnborg
  0 siblings, 1 reply; 3+ messages in thread
From: Kees Cook @ 2014-03-11 20:24 UTC (permalink / raw)
  To: linux-kernel; +Cc: David S. Miller, sparclinux

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

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 arch/sparc/kernel/unaligned_32.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sparc/kernel/unaligned_32.c b/arch/sparc/kernel/unaligned_32.c
index c0ec89786193..892e399414e0 100644
--- a/arch/sparc/kernel/unaligned_32.c
+++ b/arch/sparc/kernel/unaligned_32.c
@@ -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 */
-- 
1.7.9.5


-- 
Kees Cook
Chrome OS Security

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sparc: use %s for unaligned panic
  2014-03-11 20:24 [PATCH] sparc: use %s for unaligned panic Kees Cook
@ 2014-03-15  8:07 ` Sam Ravnborg
  2014-03-17 19:51   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Sam Ravnborg @ 2014-03-15  8:07 UTC (permalink / raw)
  To: Kees Cook; +Cc: linux-kernel, David S. Miller, sparclinux

On Tue, Mar 11, 2014 at 01:24:46PM -0700, Kees Cook wrote:
> Since unaligned_panic() takes a literal string, make sure it can never
> accidentally be used as a format string.
> 
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>  arch/sparc/kernel/unaligned_32.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/sparc/kernel/unaligned_32.c b/arch/sparc/kernel/unaligned_32.c
> index c0ec89786193..892e399414e0 100644
> --- a/arch/sparc/kernel/unaligned_32.c
> +++ b/arch/sparc/kernel/unaligned_32.c
> @@ -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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sparc: use %s for unaligned panic
  2014-03-15  8:07 ` Sam Ravnborg
@ 2014-03-17 19:51   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2014-03-17 19:51 UTC (permalink / raw)
  To: sam; +Cc: keescook, linux-kernel, sparclinux

From: Sam Ravnborg <sam@ravnborg.org>
Date: Sat, 15 Mar 2014 09:07:09 +0100

> On Tue, Mar 11, 2014 at 01:24:46PM -0700, Kees Cook wrote:
>> Since unaligned_panic() takes a literal string, make sure it can never
>> accidentally be used as a format string.
>> 
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>> ---
>>  arch/sparc/kernel/unaligned_32.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/arch/sparc/kernel/unaligned_32.c b/arch/sparc/kernel/unaligned_32.c
>> index c0ec89786193..892e399414e0 100644
>> --- a/arch/sparc/kernel/unaligned_32.c
>> +++ b/arch/sparc/kernel/unaligned_32.c
>> @@ -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()

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-03-17 19:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-11 20:24 [PATCH] sparc: use %s for unaligned panic Kees Cook
2014-03-15  8:07 ` Sam Ravnborg
2014-03-17 19:51   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome