From: Matt Fleming <matt@console-pimps.org>
To: Kees Cook <keescook@chromium.org>
Cc: Paul Mundt <lethal@linux-sh.org>,
kbuild test robot <fengguang.wu@intel.com>,
LKML <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-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
Date: Tue, 11 Mar 2014 09:59:10 +0000 [thread overview]
Message-ID: <20140311095910.GA5834@console-pimps.org> (raw)
In-Reply-To: <CAGXu5jJsyAHdiMfoAZHS-4w1+rGKGQH9s9FF83Y59VLmczfaXQ@mail.gmail.com>
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.
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@intel.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@chromium.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: stable@vger.kernel.org
Signed-off-by: Matt Fleming <matt.fleming@intel.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
next prev parent reply other threads:[~2014-03-11 9:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <531d3b0e.4MeVQMzUoamEWeW7%fengguang.wu@intel.com>
2014-03-10 17:41 ` Kees Cook
2014-03-11 9:59 ` Matt Fleming [this message]
2014-03-11 20:01 ` Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140311095910.GA5834@console-pimps.org \
--to=matt@console-pimps.org \
--cc=akpm@linux-foundation.org \
--cc=fengguang.wu@intel.com \
--cc=keescook@chromium.org \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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