From patchwork Thu Oct 11 20:31:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 10637387 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D4F469B1 for ; Thu, 11 Oct 2018 20:31:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D6F62C147 for ; Thu, 11 Oct 2018 20:31:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 319422C15A; Thu, 11 Oct 2018 20:31:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B90E42C14E for ; Thu, 11 Oct 2018 20:31:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725742AbeJLEAd (ORCPT ); Fri, 12 Oct 2018 00:00:33 -0400 Received: from mail-io1-f74.google.com ([209.85.166.74]:33668 "EHLO mail-io1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725781AbeJLEAd (ORCPT ); Fri, 12 Oct 2018 00:00:33 -0400 Received: by mail-io1-f74.google.com with SMTP id c5-v6so9130597ioa.0 for ; Thu, 11 Oct 2018 13:31:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=eECGZ7zgHaOkyIeJc2S18LiRW9XEEqnkBBRxWwCTjgc=; b=WBlsMmHNlunZU5eyzxqxwQfehc/iOHgjBTalkbbOiIANwYXW5ZYDoMZdyfK5y14rRI M5+bmDl7CqpoTnuVRmLtqHJNcEztJqawA8IHLMNk37ULeFkfnmECnpZ4Du/J7cWEbHNj cEdCfBkY96PlR2ZN3eiJ3pcuuO18yY9+0UiVLZ/i7N8f8oVkypcIoCcuf8FueNBe4ntJ gEhNOw5uKV8WR9jVQi6GpH25RLqNM8bfOlKeN6/kN4ojVcP+7yEstVbjEUs4iqXT8wrE y+drHO0TIvD+nWD0ti/wx4vZKhmgWiWxN/y/m/+5TXuI9GgcGIEyLPkf3XarMfacIG6S Vh+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=eECGZ7zgHaOkyIeJc2S18LiRW9XEEqnkBBRxWwCTjgc=; b=ORwIfGyEp652RGsSj9OAX+jKLJtFPPMeMHWnYnwusjny0UsYpZ5Jghi0WAJGTYHTon dWjowvRinAkBtmTguxGkqRFvrd7BH+cV7fRTPHAhOCGZY0FZmlkbge6lloN3Q2ajVYz1 7fpiPpjOyUaDrrMh76DaXrjtDO88LVm3yr9k6oykULzZIbYFSTMKnVXE5ms6LB3oBPw9 eyVm0QnfCr3mWeGf3OHWC1NwMT9wsX22263P2VM/57MyNavL/giNVx1ZYpJHZVJsIuUs iqFzLQifdjz6VLMssV5/BpmWHzMsuW5iVdVQ0t5NKs25zuh/TTadg1R5TEZypJafqjEK +D/Q== X-Gm-Message-State: ABuFfoho8j/8/lrUjhRrleugFCX/bVI+kxpNEszrj1582DVPSzd2KIV4 PezBU1NSrdeL84YPb4BmJfSMYjfd1PPXpKOEjS8= X-Google-Smtp-Source: ACcGV60FxIyjqcG0qVQ/kIO/WL1FMP3WGHNkZdx1fa3V46efJSJ6CaZbWea5IP7f/6PgwfmHpBiLKQcLDR19n0Cdtlc= X-Received: by 2002:a24:dd45:: with SMTP id t66-v6mr5776020itf.5.1539289898802; Thu, 11 Oct 2018 13:31:38 -0700 (PDT) Date: Thu, 11 Oct 2018 13:31:26 -0700 In-Reply-To: <1539274203.2623.56.camel@linux.vnet.ibm.com> Message-Id: <20181011203126.15338-1-ndesaulniers@google.com> Mime-Version: 1.0 References: <1539274203.2623.56.camel@linux.vnet.ibm.com> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog Subject: [PATCH] KEYS: trusted: fix -Wvarags warning From: ndesaulniers@google.com To: jejb@linux.vnet.ibm.com, dhowells@redhat.com Cc: natechancellor@gmail.com, ebiggers@google.com, Nick Desaulniers , Mimi Zohar , James Morris , "Serge E. Hallyn" , linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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: https://github.com/ClangBuiltLinux/linux/issues/41 Suggested-by: James Bottomley Signed-off-by: Nick Desaulniers --- security/keys/trusted.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/security/keys/trusted.c b/security/keys/trusted.c index b69d3b1777c2..d425b2b839af 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, */ static 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 char *h3, ...) { unsigned char paramdigest[SHA1_DIGEST_SIZE]; struct sdesc *sdesc; @@ -139,7 +139,7 @@ static int TSS_authhmac(unsigned char *digest, const unsigned char *key, return PTR_ERR(sdesc); } - c = h3; + c = h2; ret = crypto_shash_init(&sdesc->shash); if (ret < 0) goto out; @@ -163,7 +163,7 @@ static int TSS_authhmac(unsigned char *digest, const unsigned char *key, if (!ret) ret = TSS_rawhmac(digest, key, keylen, SHA1_DIGEST_SIZE, paramdigest, TPM_NONCE_SIZE, h1, - TPM_NONCE_SIZE, h2, 1, &c, 0, 0); + TPM_NONCE_SIZE, h3, 1, &c, 0, 0); out: kzfree(sdesc); return ret; @@ -508,7 +508,7 @@ static int tpm_seal(struct tpm_buf *tb, uint16_t keytype, if (pcrinfosize == 0) { /* no pcr info specified */ ret = TSS_authhmac(td->pubauth, sess.secret, SHA1_DIGEST_SIZE, - sess.enonce, td->nonceodd, cont, + sess.enonce, cont, td->nonceodd, sizeof(uint32_t), &ordinal, SHA1_DIGEST_SIZE, td->encauth, sizeof(uint32_t), &pcrsize, sizeof(uint32_t), &datsize, datalen, data, 0, @@ -516,7 +516,7 @@ static int tpm_seal(struct tpm_buf *tb, uint16_t keytype, } else { /* pcr info specified */ ret = TSS_authhmac(td->pubauth, sess.secret, SHA1_DIGEST_SIZE, - sess.enonce, td->nonceodd, cont, + sess.enonce, cont, td->nonceodd, sizeof(uint32_t), &ordinal, SHA1_DIGEST_SIZE, td->encauth, sizeof(uint32_t), &pcrsize, pcrinfosize, pcrinfo, sizeof(uint32_t), @@ -608,12 +608,12 @@ static int tpm_unseal(struct tpm_buf *tb, return ret; } ret = TSS_authhmac(authdata1, keyauth, TPM_NONCE_SIZE, - enonce1, nonceodd, cont, sizeof(uint32_t), + enonce1, cont, nonceodd, sizeof(uint32_t), &ordinal, bloblen, blob, 0, 0); if (ret < 0) return ret; ret = TSS_authhmac(authdata2, blobauth, TPM_NONCE_SIZE, - enonce2, nonceodd, cont, sizeof(uint32_t), + enonce2, cont, nonceodd, sizeof(uint32_t), &ordinal, bloblen, blob, 0, 0); if (ret < 0) return ret;