From: ndesaulniers@google.com To: dhowells@redhat.com, jejb@linux.vnet.ibm.com Cc: natechancellor@gmail.com, David.Laight@aculab.com, denkenz@gmail.com, Nick Desaulniers <ndesaulniers@google.com>, Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>, Mimi Zohar <zohar@linux.vnet.ibm.com>, James Morris <jmorris@namei.org>, "Serge E. Hallyn" <serge@hallyn.com>, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [PATCH v2] [PATCH] KEYS: trusted: fix -Wvarags warning Date: Mon, 22 Oct 2018 23:43:57 +0000 [thread overview] Message-ID: <20181022234357.82217-1-ndesaulniers@google.com> (raw) In-Reply-To: <0147a993d4a94426afa469a8dcc4e5d7@AcuMS.aculab.com> Fixes the warning reported by Clang: 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: https://github.com/ClangBuiltLinux/linux/issues/41 Link: https://www.eskimo.com/~scs/cclass/int/sx11c.html Suggested-by: David Laight <David.Laight@aculab.com> Suggested-by: Denis Kenzior <denkenz@gmail.com> Suggested-by: James Bottomley <jejb@linux.vnet.ibm.com> Suggested-by: Nathan Chancellor <natechancellor@gmail.com> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> --- v1 -> v2: * Don't reorder args, just use default function promotion type of unsigned int. * Add !! boolean cast as per Denis in https://lkml.org/lkml/2018/10/12/838. * Tested with gcc-8 and clang-8. include/keys/trusted.h | 2 +- security/keys/trusted.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/keys/trusted.h b/include/keys/trusted.h index adbcb6817826..0071298b9b28 100644 --- a/include/keys/trusted.h +++ b/include/keys/trusted.h @@ -38,7 +38,7 @@ enum { int TSS_authhmac(unsigned char *digest, const unsigned char *key, unsigned int keylen, unsigned char *h1, - unsigned char *h2, unsigned char h3, ...); + unsigned char *h2, unsigned int h3, ...); int TSS_checkhmac1(unsigned char *buffer, const uint32_t command, const unsigned char *ononce, diff --git a/security/keys/trusted.c b/security/keys/trusted.c index ff6789365a12..335ce6d1cf6b 100644 --- a/security/keys/trusted.c +++ b/security/keys/trusted.c @@ -123,7 +123,7 @@ static int TSS_rawhmac(unsigned char *digest, const unsigned char *key, */ int TSS_authhmac(unsigned char *digest, const unsigned char *key, unsigned int keylen, unsigned char *h1, - unsigned char *h2, unsigned char h3, ...) + unsigned char *h2, unsigned int h3, ...) { unsigned char paramdigest[SHA1_DIGEST_SIZE]; struct sdesc *sdesc; @@ -139,7 +139,7 @@ int TSS_authhmac(unsigned char *digest, const unsigned char *key, return PTR_ERR(sdesc); } - c = h3; + c = !!h3; ret = crypto_shash_init(&sdesc->shash); if (ret < 0) goto out; -- 2.19.1.568.g152ad8e336-goog
WARNING: multiple messages have this Message-ID (diff)
From: ndesaulniers@google.com To: dhowells@redhat.com, jejb@linux.vnet.ibm.com Cc: natechancellor@gmail.com, David.Laight@aculab.com, denkenz@gmail.com, Nick Desaulniers <ndesaulniers@google.com>, Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>, Mimi Zohar <zohar@linux.vnet.ibm.com>, James Morris <jmorris@namei.org>, "Serge E. Hallyn" <serge@hallyn.com>, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [PATCH v2] [PATCH] KEYS: trusted: fix -Wvarags warning Date: Mon, 22 Oct 2018 16:43:57 -0700 [thread overview] Message-ID: <20181022234357.82217-1-ndesaulniers@google.com> (raw) In-Reply-To: <0147a993d4a94426afa469a8dcc4e5d7@AcuMS.aculab.com> Fixes the warning reported by Clang: 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: https://github.com/ClangBuiltLinux/linux/issues/41 Link: https://www.eskimo.com/~scs/cclass/int/sx11c.html Suggested-by: David Laight <David.Laight@aculab.com> Suggested-by: Denis Kenzior <denkenz@gmail.com> Suggested-by: James Bottomley <jejb@linux.vnet.ibm.com> Suggested-by: Nathan Chancellor <natechancellor@gmail.com> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> --- v1 -> v2: * Don't reorder args, just use default function promotion type of unsigned int. * Add !! boolean cast as per Denis in https://lkml.org/lkml/2018/10/12/838. * Tested with gcc-8 and clang-8. include/keys/trusted.h | 2 +- security/keys/trusted.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/keys/trusted.h b/include/keys/trusted.h index adbcb6817826..0071298b9b28 100644 --- a/include/keys/trusted.h +++ b/include/keys/trusted.h @@ -38,7 +38,7 @@ enum { int TSS_authhmac(unsigned char *digest, const unsigned char *key, unsigned int keylen, unsigned char *h1, - unsigned char *h2, unsigned char h3, ...); + unsigned char *h2, unsigned int h3, ...); int TSS_checkhmac1(unsigned char *buffer, const uint32_t command, const unsigned char *ononce, diff --git a/security/keys/trusted.c b/security/keys/trusted.c index ff6789365a12..335ce6d1cf6b 100644 --- a/security/keys/trusted.c +++ b/security/keys/trusted.c @@ -123,7 +123,7 @@ static int TSS_rawhmac(unsigned char *digest, const unsigned char *key, */ int TSS_authhmac(unsigned char *digest, const unsigned char *key, unsigned int keylen, unsigned char *h1, - unsigned char *h2, unsigned char h3, ...) + unsigned char *h2, unsigned int h3, ...) { unsigned char paramdigest[SHA1_DIGEST_SIZE]; struct sdesc *sdesc; @@ -139,7 +139,7 @@ int TSS_authhmac(unsigned char *digest, const unsigned char *key, return PTR_ERR(sdesc); } - c = h3; + c = !!h3; ret = crypto_shash_init(&sdesc->shash); if (ret < 0) goto out; -- 2.19.1.568.g152ad8e336-goog
next prev parent reply other threads:[~2018-10-22 23:43 UTC|newest] Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-10-09 22:11 undefined behavior (-Wvarargs) in security/keys/trusted.c#TSS_authhmac() Nick Desaulniers 2018-10-09 22:11 ` Nick Desaulniers 2018-10-11 16:02 ` Arnd Bergmann 2018-10-11 16:02 ` Arnd Bergmann 2018-10-11 16:10 ` James Bottomley 2018-10-11 16:10 ` James Bottomley 2018-10-11 20:31 ` [PATCH] KEYS: trusted: fix -Wvarags warning ndesaulniers 2018-10-11 20:31 ` ndesaulniers 2018-10-12 1:50 ` Nathan Chancellor 2018-10-12 1:50 ` Nathan Chancellor 2018-10-12 16:55 ` Nick Desaulniers 2018-10-12 16:55 ` Nick Desaulniers 2018-10-12 17:03 ` Nathan Chancellor 2018-10-12 17:03 ` Nathan Chancellor 2018-10-12 12:29 ` Denis Kenzior 2018-10-12 12:29 ` Denis Kenzior 2018-10-12 15:05 ` James Bottomley 2018-10-12 15:05 ` James Bottomley 2018-10-12 15:13 ` Denis Kenzior 2018-10-12 15:13 ` Denis Kenzior 2018-10-12 15:22 ` James Bottomley 2018-10-12 15:22 ` James Bottomley 2018-10-12 15:44 ` Denis Kenzior 2018-10-12 15:44 ` Denis Kenzior 2018-10-12 15:46 ` James Bottomley 2018-10-12 15:46 ` James Bottomley 2018-10-12 15:53 ` Denis Kenzior 2018-10-12 15:53 ` Denis Kenzior 2018-10-12 16:01 ` James Bottomley 2018-10-12 16:01 ` James Bottomley 2018-10-12 17:14 ` Nick Desaulniers 2018-10-12 17:14 ` Nick Desaulniers 2018-10-12 15:25 ` James Bottomley 2018-10-12 15:25 ` James Bottomley 2018-10-12 17:05 ` Nick Desaulniers 2018-10-12 17:05 ` Nick Desaulniers 2018-10-12 17:17 ` Nick Desaulniers 2018-10-12 17:17 ` Nick Desaulniers 2018-10-12 17:27 ` Denis Kenzior 2018-10-12 17:27 ` Denis Kenzior 2018-10-12 18:39 ` Nick Desaulniers 2018-10-12 18:39 ` Nick Desaulniers 2018-10-12 17:02 ` Nick Desaulniers 2018-10-12 17:02 ` Nick Desaulniers 2018-10-12 17:15 ` Denis Kenzior 2018-10-12 17:15 ` Denis Kenzior 2018-10-15 9:26 ` David Laight 2018-10-15 9:26 ` David Laight 2018-10-15 9:26 ` David Laight 2018-10-15 21:53 ` Nick Desaulniers 2018-10-15 21:53 ` Nick Desaulniers 2018-10-16 8:13 ` David Laight 2018-10-16 8:13 ` David Laight 2018-10-16 8:13 ` David Laight 2018-10-22 23:43 ` ndesaulniers [this message] 2018-10-22 23:43 ` [PATCH v2] " ndesaulniers 2018-10-23 0:00 ` Nathan Chancellor 2018-10-23 0:00 ` Nathan Chancellor 2018-10-24 8:36 ` Jarkko Sakkinen 2018-10-24 8:36 ` Jarkko Sakkinen 2018-10-29 17:54 ` Nick Desaulniers 2018-10-29 17:54 ` Nick Desaulniers 2019-02-11 18:36 ` Nick Desaulniers 2019-02-11 18:36 ` Nick Desaulniers 2019-02-12 23:12 ` Jarkko Sakkinen 2019-02-12 23:12 ` Jarkko Sakkinen 2019-02-14 10:52 ` Jarkko Sakkinen 2019-02-14 10:52 ` Jarkko Sakkinen
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20181022234357.82217-1-ndesaulniers@google.com \ --to=ndesaulniers@google.com \ --cc=David.Laight@aculab.com \ --cc=denkenz@gmail.com \ --cc=dhowells@redhat.com \ --cc=jarkko.sakkinen@linux.intel.com \ --cc=jejb@linux.vnet.ibm.com \ --cc=jmorris@namei.org \ --cc=keyrings@vger.kernel.org \ --cc=linux-integrity@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-security-module@vger.kernel.org \ --cc=natechancellor@gmail.com \ --cc=serge@hallyn.com \ --cc=zohar@linux.vnet.ibm.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.