lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Tue, 11 Mar 2014 13:01:40 -0700
From:	Kees Cook <keescook@...omium.org>
To:	Matt Fleming <matt@...sole-pimps.org>
Cc:	Paul Mundt <lethal@...ux-sh.org>,
	kbuild test robot <fengguang.wu@...el.com>,
	LKML <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [kees:format-security 2/3] arch/sh/kernel/dumpstack.c:118:2:
 error: format not a string literal and no format arguments

On Tue, Mar 11, 2014 at 2:59 AM, Matt Fleming <matt@...sole-pimps.org> wrote:
> On Mon, 10 Mar, at 10:41:57AM, Kees Cook wrote:
>> > 4e14dfc7 Matt Fleming 2009-08-07  113  /*
>> > 4e14dfc7 Matt Fleming 2009-08-07  114   * Print one address/symbol entries per line.
>> > 4e14dfc7 Matt Fleming 2009-08-07  115   */
>> > 4e14dfc7 Matt Fleming 2009-08-07  116  static void print_trace_address(void *data, unsigned long addr, int reliable)
>> > 4e14dfc7 Matt Fleming 2009-08-07  117  {
>> > 4e14dfc7 Matt Fleming 2009-08-07 @118   printk(data);
>>
>> This needs to be "printk("%s", data);" so there is no chance of having
>> "data" interpreted as a format string itself.
>
> OMG, I suck. Thanks for the report Kees. Have you got a patch for x86?
> I think that's where this code came from.

Your patch looks great, thanks!

-Kees

>
> Including Andrew, because I'm not sure who else is going to take this
> patch.
>
> ---
>
> From 2284f3a27f68cec665aa982c0a226cf3fbf96ddf Mon Sep 17 00:00:00 2001
> From: Matt Fleming <matt.fleming@...el.com>
> Date: Tue, 11 Mar 2014 09:50:26 +0000
> Subject: [PATCH] sh: Fix format string bug in stack tracer
>
> Kees reported the following error,
>
>    arch/sh/kernel/dumpstack.c: In function 'print_trace_address':
>>> arch/sh/kernel/dumpstack.c:118:2: error: format not a string literal and no format arguments [-Werror=format-security]
>
> Use the "%s" format so that it's impossible to interpret 'data' as a
> format string.
>
> Reported-by: Kees Cook <keescook@...omium.org>
> Cc: Paul Mundt <lethal@...ux-sh.org>
> Cc: Andrew Morton <akpm@...ux-foundation.org>
> Cc: stable@...r.kernel.org
> Signed-off-by: Matt Fleming <matt.fleming@...el.com>
> ---
>  arch/sh/kernel/dumpstack.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/sh/kernel/dumpstack.c b/arch/sh/kernel/dumpstack.c
> index b959f5592604..8dfe645bcc4b 100644
> --- a/arch/sh/kernel/dumpstack.c
> +++ b/arch/sh/kernel/dumpstack.c
> @@ -115,7 +115,7 @@ static int print_trace_stack(void *data, char *name)
>   */
>  static void print_trace_address(void *data, unsigned long addr, int reliable)
>  {
> -       printk(data);
> +       printk("%s", (char *)data);
>         printk_address(addr, reliable);
>  }
>
> --
> 1.8.5.3
>
> --
> Matt Fleming, Intel Open Source Technology Center



-- 
Kees Cook
Chrome OS Security
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ