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:	Sun, 20 Feb 2011 11:42:17 -0700
From:	Matthew Wilcox <matthew@....cx>
To:	Borislav Petkov <bp@...en8.de>, Borislav Petkov <bp@...64.org>,
	Ingo Molnar <mingo@...e.hu>, Dan Carpenter <error27@...il.com>,
	"Herrmann3, Andreas" <Andreas.Herrmann3@....com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	"H. Peter Anvin" <hpa@...or.com>,
	"maintainer:X86 ARCHITECTURE..." <x86@...nel.org>,
	"open list:AMD MICROCODE UPD..." <amd64-microcode@...64.org>,
	open list <linux-kernel@...r.kernel.org>,
	"kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>
Subject: Re: [patch -next] x86, microcode, AMD: signedness bug in
	generic_load_microcode()

On Sun, Feb 20, 2011 at 07:08:45PM +0100, Borislav Petkov wrote:
> On Sun, Feb 20, 2011 at 10:50:11AM -0700, Matthew Wilcox wrote:
> > No, that's not what's going on.  GCC _is_ truncating to a byte, 0xa5,
> > whether it's signed or not.  Then at the time of the call to printf,
> > the 0xa5 is cast to int.  If the char is signed, 0xa5 is sign-extended;
> > if unsigned, it's zero-extended.
> 
> Yes, you're right, I missed the fact that printf does convert its
> arguments based on the format string. I should've done
> 
> 	printf("ret = 0x%hhx\n", ret);

GCC's special treatment of the printf format string is only in the
gneration of warnings.  It doesn't promote differently based on the
format string.

You need to look at 6.5.2.2, parts 6 and 7.  Part 7 says:

	The ellipsis notation in a function prototype declarator causes
	argument type conversion to stop after the last declared
	parameter. The default argument promotions are performed on
	trailing arguments.

And part 6 describes the default argument promotions:

	If the expression that denotes the called function has a type that
	does not include a prototype, the integer promotions are performed
	on each argument, and arguments that have type float are promoted
	to double. These are called the default argument promotions.

So passing a char to printf will cause it to be promoted to int, no
matter what the format string says.  All the format string will do is
change how it's printed.  Probably by casting it back to a char :-)

-- 
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."
--
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