Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755160AbYLKFmD (ORCPT ); Thu, 11 Dec 2008 00:42:03 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750987AbYLKFlv (ORCPT ); Thu, 11 Dec 2008 00:41:51 -0500 Received: from smtp1.linux-foundation.org ([140.211.169.13]:46383 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750871AbYLKFlv (ORCPT ); Thu, 11 Dec 2008 00:41:51 -0500 Date: Wed, 10 Dec 2008 21:41:42 -0800 From: Andrew Morton To: Roland Dreier Cc: Al Viro , Nguyen Anh Quynh , LKML , Kuniyasu Suzaki Subject: Re: [PATCH] fix calls to request_module() Message-Id: <20081210214142.9e7b2298.akpm@linux-foundation.org> In-Reply-To: References: <9cde8bff0812101935j5ef56140k67035d892a868738@mail.gmail.com> <20081211040118.GK28946@ZenIV.linux.org.uk> <20081210201455.0c611484.akpm@linux-foundation.org> <20081211044901.GL28946@ZenIV.linux.org.uk> X-Mailer: Sylpheed 2.4.8 (GTK+ 2.12.5; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1907 Lines: 53 On Wed, 10 Dec 2008 21:03:37 -0800 Roland Dreier wrote: > 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. yes, that would suck. otoh, our current warning spew actually causes bugs. I wonder if we could add a printk_stfu() which isn't declared attribute(printf) and which simply calls printk. We might still get a single warning at the interface point. > On the other hand, gcc warning on such code (untrusted format string > passed into a printf-like function) seems quite legitimate as well. Yes, we've had actual bugs in the kernel from this, where the control string was user-provided. root-only user, fortunately. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/