Skip to content

Commit 10bb75a

Browse files
nickdesaulniersintel-lab-lkp
authored andcommitted
KEYS: trusted: fix -Wvarags warning
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); ^ security/keys/trusted.c:126:37: note: parameter of type 'unsigned char' is declared here unsigned char *h2, unsigned char h3, ...) ^ Specifically, it seems that both the C90 (4.8.1.1) and C11 (7.16.1.4) standards explicitly call this out as undefined behavior: The parameter parmN is the identifier of the rightmost parameter in the variable parameter list in the function definition (the one just before the ...). If the parameter parmN is declared with ... or with a type that is not compatible with the type that results after application of the default argument promotions, the behavior is undefined. Link: ClangBuiltLinux#41 Suggested-by: James Bottomley <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]>
1 parent 10e3781 commit 10bb75a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

security/keys/trusted.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static int TSS_rawhmac(unsigned char *digest, const unsigned char *key,
123123
*/
124124
static int TSS_authhmac(unsigned char *digest, const unsigned char *key,
125125
unsigned int keylen, unsigned char *h1,
126-
unsigned char *h2, unsigned char h3, ...)
126+
unsigned char h2, unsigned char *h3, ...)
127127
{
128128
unsigned char paramdigest[SHA1_DIGEST_SIZE];
129129
struct sdesc *sdesc;
@@ -139,7 +139,7 @@ static int TSS_authhmac(unsigned char *digest, const unsigned char *key,
139139
return PTR_ERR(sdesc);
140140
}
141141

142-
c = h3;
142+
c = h2;
143143
ret = crypto_shash_init(&sdesc->shash);
144144
if (ret < 0)
145145
goto out;
@@ -163,7 +163,7 @@ static int TSS_authhmac(unsigned char *digest, const unsigned char *key,
163163
if (!ret)
164164
ret = TSS_rawhmac(digest, key, keylen, SHA1_DIGEST_SIZE,
165165
paramdigest, TPM_NONCE_SIZE, h1,
166-
TPM_NONCE_SIZE, h2, 1, &c, 0, 0);
166+
TPM_NONCE_SIZE, h3, 1, &c, 0, 0);
167167
out:
168168
kzfree(sdesc);
169169
return ret;
@@ -509,15 +509,15 @@ static int tpm_seal(struct tpm_buf *tb, uint16_t keytype,
509509
if (pcrinfosize == 0) {
510510
/* no pcr info specified */
511511
ret = TSS_authhmac(td->pubauth, sess.secret, SHA1_DIGEST_SIZE,
512-
sess.enonce, td->nonceodd, cont,
512+
sess.enonce, cont, td->nonceodd,
513513
sizeof(uint32_t), &ordinal, SHA1_DIGEST_SIZE,
514514
td->encauth, sizeof(uint32_t), &pcrsize,
515515
sizeof(uint32_t), &datsize, datalen, data, 0,
516516
0);
517517
} else {
518518
/* pcr info specified */
519519
ret = TSS_authhmac(td->pubauth, sess.secret, SHA1_DIGEST_SIZE,
520-
sess.enonce, td->nonceodd, cont,
520+
sess.enonce, cont, td->nonceodd,
521521
sizeof(uint32_t), &ordinal, SHA1_DIGEST_SIZE,
522522
td->encauth, sizeof(uint32_t), &pcrsize,
523523
pcrinfosize, pcrinfo, sizeof(uint32_t),
@@ -609,12 +609,12 @@ static int tpm_unseal(struct tpm_buf *tb,
609609
return ret;
610610
}
611611
ret = TSS_authhmac(authdata1, keyauth, TPM_NONCE_SIZE,
612-
enonce1, nonceodd, cont, sizeof(uint32_t),
612+
enonce1, cont, nonceodd, sizeof(uint32_t),
613613
&ordinal, bloblen, blob, 0, 0);
614614
if (ret < 0)
615615
return ret;
616616
ret = TSS_authhmac(authdata2, blobauth, TPM_NONCE_SIZE,
617-
enonce2, nonceodd, cont, sizeof(uint32_t),
617+
enonce2, cont, nonceodd, sizeof(uint32_t),
618618
&ordinal, bloblen, blob, 0, 0);
619619
if (ret < 0)
620620
return ret;

0 commit comments

Comments
 (0)