From: Roland Dreier <rdreier@cisco.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Nguyen Anh Quynh <aquynh@gmail.com>,
LKML <linux-kernel@vger.kernel.org>,
Kuniyasu Suzaki <k.suzaki@aist.go.jp>
Subject: Re: [PATCH] fix calls to request_module()
Date: Wed, 10 Dec 2008 21:03:37 -0800 [thread overview]
Message-ID: <adatz9b2thy.fsf@cisco.com> (raw)
In-Reply-To: <20081211044901.GL28946@ZenIV.linux.org.uk> (Al Viro's message of "Thu, 11 Dec 2008 04:49:01 +0000")
> I mean, I do not believe that any gcc version would start spewing warnings
> of
> printf("-- \n");
> and its ilk...
No, I haven't seen gcc warn about anything that crazy (ie where it can
see the format string and prove it's safe).
I do see warnings from the Ubuntu gcc with code like:
#include <stdio.h>
extern char *a;
void foo()
{
printf(a);
}
which produces
a.c: In function 'foo':
a.c:7: warning: format not a string literal and no format arguments
The kernel has such code eg in init/main.c, which does
printk(linux_banner);
when linux_banner is only visible to the compiler as
extern const char linux_banner[];
however the trivial fix
diff --git a/init/main.c b/init/main.c
index 7e117a2..e471598 100644
--- a/init/main.c
+++ b/init/main.c
@@ -568,7 +568,7 @@ asmlinkage void __init start_kernel(void)
boot_cpu_init();
page_address_init();
printk(KERN_NOTICE);
- printk(linux_banner);
+ printk("%s", linux_banner);
setup_arch(&command_line);
mm_init_owner(&init_mm, &init_task);
setup_command_line(command_line);
doesn't seem that appealing, since it bloats the object code for a
non-bug -- 7 bytes for me on x86_64:
add/remove: 0/0 grow/shrink: 1/0 up/down: 7/0 (7)
function old new delta
start_kernel 680 687 +7
given the number of such warnings I see in a typical compile, this would
be a fairly hefty amount of bloat just to shut up gcc.
On the other hand, gcc warning on such code (untrusted format string
passed into a printf-like function) seems quite legitimate as well.
So I dunno.
- Roland
next prev parent reply other threads:[~2008-12-11 5:03 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-11 3:35 [PATCH] fix calls to request_module() Nguyen Anh Quynh
2008-12-11 4:01 ` Al Viro
2008-12-11 4:14 ` Nguyen Anh Quynh
2008-12-11 4:14 ` Andrew Morton
2008-12-11 4:23 ` Nguyen Anh Quynh
2008-12-11 4:40 ` Jianjun Kong
2008-12-11 4:43 ` Nguyen Anh Quynh
2008-12-11 5:02 ` Jianjun Kong
2008-12-11 5:00 ` Al Viro
2008-12-11 5:42 ` Nguyen Anh Quynh
2008-12-11 6:00 ` Al Viro
2008-12-11 6:28 ` Nguyen Anh Quynh
2008-12-11 4:49 ` Al Viro
2008-12-11 5:03 ` Roland Dreier [this message]
2008-12-11 5:41 ` Andrew Morton
2008-12-11 23:25 ` Roland Dreier
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=adatz9b2thy.fsf@cisco.com \
--to=rdreier@cisco.com \
--cc=akpm@linux-foundation.org \
--cc=aquynh@gmail.com \
--cc=k.suzaki@aist.go.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/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