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] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 10 Dec 2008 21:03:37 -0800
From:	Roland Dreier <rdreier@...co.com>
To:	Al Viro <viro@...IV.linux.org.uk>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Nguyen Anh Quynh <aquynh@...il.com>,
	LKML <linux-kernel@...r.kernel.org>,
	Kuniyasu Suzaki <k.suzaki@...t.go.jp>
Subject: Re: [PATCH] fix calls to request_module()

 > 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
--
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