RE: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-16 Thread David Laight
From: Nick Desaulniers > Sent: 15 October 2018 22:54 > On Mon, Oct 15, 2018 at 2:26 AM David Laight wrote: > > > > From: ndesaulni...@google.com > > > Sent: 11 October 2018 21:31 > > ... > > > by swapping h2 and h3. > > > > > > security/keys/trusted.c:146:17: warning: passing an object that > > >

Re: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-15 Thread Nick Desaulniers
On Mon, Oct 15, 2018 at 2:26 AM David Laight wrote: > > From: ndesaulni...@google.com > > Sent: 11 October 2018 21:31 > ... > > by swapping h2 and h3. > > > > security/keys/trusted.c:146:17: warning: passing an object that > > undergoes default > > argument promotion to 'va_start' has undefi

RE: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-15 Thread David Laight
From: ndesaulni...@google.com > Sent: 11 October 2018 21:31 ... > by swapping h2 and h3. > > security/keys/trusted.c:146:17: warning: passing an object that > undergoes default > argument promotion to 'va_start' has undefined behavior [-Wvarargs] > va_start(argp, h3); >

Re: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-12 Thread Nick Desaulniers
On Fri, Oct 12, 2018 at 10:27 AM Denis Kenzior wrote: > > Hi Nick, > > >> So maybe I'm misunderstanding something, but the issue seems to be that > >> unsigned char is promoted to 'unsigned char *' by Clang and probably > >> unsigned int or int by gcc. > > > > No. This is extremely well defined be

Re: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-12 Thread Denis Kenzior
Hi Nick, So maybe I'm misunderstanding something, but the issue seems to be that unsigned char is promoted to 'unsigned char *' by Clang and probably unsigned int or int by gcc. No. This is extremely well defined behavior in C. In C, integral types are NEVER promoted to pointer to integer typ

Re: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-12 Thread Nick Desaulniers
On Fri, Oct 12, 2018 at 10:05 AM Nick Desaulniers wrote: > > On Fri, Oct 12, 2018 at 8:14 AM Denis Kenzior wrote: > > > > Hi James, > > > > >> So can't we simply use 'bool' or uint32 as the type for h3 instead > > >> of re-ordering everything > > > > > > The problem is the standard is ambiguious.

Re: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-12 Thread Denis Kenzior
Hi Nick, Refer to https://trustedcomputinggroup.org/wp-content/uploads/TPM-Main-Part-3-Commands_v1.2_rev116_01032011.pdf for details. Can you cite the relevant section? Just pick any section that describes a TPM command. I randomly used Section 10.3 for TPM Unbind. See the 'Incoming op

Re: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-12 Thread Nick Desaulniers
On Fri, Oct 12, 2018 at 9:01 AM James Bottomley wrote: > > On Fri, 2018-10-12 at 10:53 -0500, Denis Kenzior wrote: > > Hi James, > > > > > > From the links provided in the patch it seems that one cannot > > > > pass char/float/short to va_start(). Fair enough. So if we make > > > > h3 an unsig

Re: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-12 Thread Nick Desaulniers
On Fri, Oct 12, 2018 at 8:14 AM Denis Kenzior wrote: > > Hi James, > > >> So can't we simply use 'bool' or uint32 as the type for h3 instead > >> of re-ordering everything > > > > The problem is the standard is ambiguious. The only thing that's > > guaranteed to work for all time is a char *. If

Re: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-12 Thread Nathan Chancellor
On Fri, Oct 12, 2018 at 09:55:55AM -0700, Nick Desaulniers wrote: > On Thu, Oct 11, 2018 at 6:50 PM Nathan Chancellor > wrote: > > > > On Thu, Oct 11, 2018 at 01:31:26PM -0700, ndesaulni...@google.com wrote: > > > by swapping h2 and h3. > > > > > > security/keys/trusted.c:146:17: warning: passing

Re: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-12 Thread Nick Desaulniers
On Fri, Oct 12, 2018 at 5:29 AM Denis Kenzior wrote: > > Hi Nick, > > > @@ -123,7 +123,7 @@ static int TSS_rawhmac(unsigned char *digest, const > > unsigned char *key, > >*/ > > static int TSS_authhmac(unsigned char *digest, const unsigned char *key, > > unsigned int k

Re: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-12 Thread Nick Desaulniers
On Thu, Oct 11, 2018 at 6:50 PM Nathan Chancellor wrote: > > On Thu, Oct 11, 2018 at 01:31:26PM -0700, ndesaulni...@google.com wrote: > > by swapping h2 and h3. > > > > security/keys/trusted.c:146:17: warning: passing an object that > > undergoes default > > argument promotion to 'va_start'

Re: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-12 Thread James Bottomley
On Fri, 2018-10-12 at 10:53 -0500, Denis Kenzior wrote: > Hi James, > > > > From the links provided in the patch it seems that one cannot > > > pass char/float/short to va_start(). Fair enough. So if we make > > > h3 an unsigned int, the issue goes away, no? > > > > For the current version of

Re: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-12 Thread Denis Kenzior
Hi James, From the links provided in the patch it seems that one cannot pass char/float/short to va_start(). Fair enough. So if we make h3 an unsigned int, the issue goes away, no? For the current version of clang, yes. However, if we're fixing this for good a char * pointer is the only g

Re: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-12 Thread James Bottomley
On Fri, 2018-10-12 at 10:44 -0500, Denis Kenzior wrote: > Hi James, > > > > So instead of having unsigned char h3, can't we simply have bool > > > h3 or unsigned int h3? > > > > Given the ambiguity in the standards, the safe thing that will work > > for all time and all potential compilers is a c

Re: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-12 Thread Denis Kenzior
Hi James, So instead of having unsigned char h3, can't we simply have bool h3 or unsigned int h3? Given the ambiguity in the standards, the safe thing that will work for all time and all potential compilers is a char * All right. You state this with certainty, but I'd still like you to ed

Re: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-12 Thread James Bottomley
On Fri, 2018-10-12 at 10:13 -0500, Denis Kenzior wrote: > Hi James, > > > > So can't we simply use 'bool' or uint32 as the type for h3 > > > instead > > > of re-ordering everything > > > > The problem is the standard is ambiguious. The only thing that's > > guaranteed to work for all time is a c

Re: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-12 Thread James Bottomley
On Fri, 2018-10-12 at 10:13 -0500, Denis Kenzior wrote: > Hi James, > > > > So can't we simply use 'bool' or uint32 as the type for h3 > > > instead of re-ordering everything > > > > The problem is the standard is ambiguious. The only thing that's > > guaranteed to work for all time is a char *.

Re: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-12 Thread Denis Kenzior
Hi James, So can't we simply use 'bool' or uint32 as the type for h3 instead of re-ordering everything The problem is the standard is ambiguious. The only thing that's guaranteed to work for all time is a char *. If you want to keep the order, what I'd suggest is inserting a dummy pointer ar

Re: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-12 Thread James Bottomley
On Fri, 2018-10-12 at 07:29 -0500, Denis Kenzior wrote: > Hi Nick, > > > @@ -123,7 +123,7 @@ static int TSS_rawhmac(unsigned char *digest, > > const unsigned char *key, > >*/ > > static int TSS_authhmac(unsigned char *digest, const unsigned > > char *key, > > unsigned int

Re: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-12 Thread Denis Kenzior
Hi Nick, @@ -123,7 +123,7 @@ static int TSS_rawhmac(unsigned char *digest, const unsigned char *key, */ static int TSS_authhmac(unsigned char *digest, const unsigned char *key, unsigned int keylen, unsigned char *h1, - unsigned char *h2, unsign

Re: [PATCH] KEYS: trusted: fix -Wvarags warning

2018-10-11 Thread Nathan Chancellor
On Thu, Oct 11, 2018 at 01:31:26PM -0700, ndesaulni...@google.com wrote: > by swapping h2 and h3. > > security/keys/trusted.c:146:17: warning: passing an object that > undergoes default > argument promotion to 'va_start' has undefined behavior [-Wvarargs] > va_start(argp, h3); >