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]
Message-Id: <20081205234105.430a7b5e.akpm@linux-foundation.org>
Date:	Fri, 5 Dec 2008 23:41:05 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Willy Tarreau <w@....eu>
Cc:	Nick Andrew <nick@...k-andrew.net>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Tejun Heo <tj@...nel.org>, Takashi Iwai <tiwai@...e.de>
Subject: Re: [RFC] Recursive printk

On Sat, 6 Dec 2008 08:33:05 +0100 Willy Tarreau <w@....eu> wrote:

> On Fri, Dec 05, 2008 at 11:20:16PM -0800, Andrew Morton wrote:
> > > void snd_verbose_printk(const char *file, int line, const char *format, ...)
> > > {
> > >         va_list args;
> > > 
> > >         if (format[0] == '<' && format[1] >= '0' && format[1] <= '7' && format[2] == '>') {
> > >                 char tmp[] = "<0>";
> > >                 tmp[1] = format[1];
> > >                 printk("%sALSA %s:%d: ", tmp, file, line);
> > >                 format += 3;
> > 
> > That's racy.  Two threads can fight over tmp[1].  It should do:
> > 
> > 		printk("<%c>ALSA %s:%d: ", format[1], tmp, file, line);
> > 
> > (I didn't know that you can even modify literal strings - shouldn't
> > they be in read-only storage?)
> 
> no Andrew, this tmp[] is declared on the stack, and gcc emits code to
> copy the constant "<0>" onto the stack every time this code is called

Good heavens, so it does.  It is unusual for C to cater to such stupid
code by generating such inefficient code.  A bit of a trap, really.

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