From patchwork Sat Jun 23 02:07:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 10483395 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B17EB6023A for ; Sat, 23 Jun 2018 02:08:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D35D20950 for ; Sat, 23 Jun 2018 02:08:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41E5E27D16; Sat, 23 Jun 2018 02:08:52 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable 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 E654520950 for ; Sat, 23 Jun 2018 02:08:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934606AbeFWCIZ (ORCPT ); Fri, 22 Jun 2018 22:08:25 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:37158 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934307AbeFWCIX (ORCPT ); Fri, 22 Jun 2018 22:08:23 -0400 Received: by mail-pl0-f66.google.com with SMTP id 31-v6so4266528plc.4; Fri, 22 Jun 2018 19:08:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Fqn2rQQxHfn+5uvFZawePFNkUxNVmG8vEiH2xK/JkQg=; b=n8NVHaepLmMEIoIxzGnPiEmqYMsccFPZ5Vae5hHe58aJPDYcwIR7Aq528wWAiF6LHu Yvjoc2nr8YDoeaXgRj8ING9NdXd7OziaBPxszXg0RuN6At09J/Qzh00xFeNDdrEnW7Pm 4HdtgU0SqbrjRfbxvQBNtRXRWTO0G5cf62C5vZXwnfBFFwwOhTk9QbawDulblb1in3Qt Qe1njd/6+3uL04bEreraEJqMC3ulQAWutsDwpOjqIS0xr042CgYhecxjD1pI5/wrM+Gt oA5+NJ/FXWSV19DeBB3FiBMI7aRwk+Zoi8RJIOjZcpU+oqNcQa9Qljs3F1NkLNFq8U8G IV/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Fqn2rQQxHfn+5uvFZawePFNkUxNVmG8vEiH2xK/JkQg=; b=X8v+PubAlNz3SP3ulw9yx1YldVj6zDLDyd7yhZoKGCzLgEE6bKklmqvXVUaqUvWAd/ sL9CDsTUxCQAL6Rg09DaOmdS/ryc2VbGv9vVZY/57ceFF+ZqyhWTpAjkElxm4OYh8gdP l05R83WMommcewycjBtDY+ydvG8Y2tNcWevobWtRllum6vzszB/vyKmyh8TrqgUO+Hum CXIPktEOYpah1iqIULaEi3wLdYtMH9Fcpw9h+Jv9Gcmu+EtLvzMej15YbMuuXlC9EiJy auIwNjIh9TSQ++8V0Zq1oaEzu3Eet6mttBmwV0XLXXVCyvy15UdXxfLRRnwe0XWxvvw/ ka3g== X-Gm-Message-State: APt69E0celhVbJO6Jwweou9/uRWThJqAPh7bGQWkCk0OyjhMIHNBKxO/ SSgO3rA1PZJPaamrzEcSVKU2uQBX X-Google-Smtp-Source: ADUXVKJ/7rBmn2rPkWdouDV4XHfXAjAaL2qLGHjarvrD4HMV/RW5yX3orClPnyIvCTKOivUP9juYKA== X-Received: by 2002:a17:902:bd95:: with SMTP id q21-v6mr3797708pls.237.1529719702336; Fri, 22 Jun 2018 19:08:22 -0700 (PDT) Received: from localhost (g134.124-44-9.ppp.wakwak.ne.jp. [124.44.9.134]) by smtp.gmail.com with ESMTPSA id j10-v6sm19730503pfj.158.2018.06.22.19.08.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Jun 2018 19:08:21 -0700 (PDT) From: Stafford Horne To: LKML Cc: Greg KH , arnd@arndb.de, linux-crypto@vger.kernel.org, Stafford Horne , Herbert Xu , "David S. Miller" Subject: [RFC PATCH 1/2] crypto: Fix -Wstringop-truncation warnings Date: Sat, 23 Jun 2018 11:07:52 +0900 Message-Id: <20180623020753.27266-2-shorne@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180623020753.27266-1-shorne@gmail.com> References: <20180623020753.27266-1-shorne@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As of GCC 9.0.0 the build is reporting warnings like: crypto/ablkcipher.c: In function ‘crypto_ablkcipher_report’: crypto/ablkcipher.c:374:2: warning: ‘strncpy’ specified bound 64 equals destination size [-Wstringop-truncation] strncpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sizeof(rblkcipher.geniv)); ~~~~~~~~~~~~~~~~~~~~~~~~~ This means the strnycpy might create a non null terminated string. Fix this by limiting the size of the string copy to include the null terminator. Cc: Greg Kroah-Hartman Cc: Arnd Bergmann Signed-off-by: Stafford Horne --- crypto/ablkcipher.c | 4 ++-- crypto/blkcipher.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c index d880a4897159..972cd7c879f6 100644 --- a/crypto/ablkcipher.c +++ b/crypto/ablkcipher.c @@ -372,7 +372,7 @@ static int crypto_ablkcipher_report(struct sk_buff *skb, struct crypto_alg *alg) strncpy(rblkcipher.type, "ablkcipher", sizeof(rblkcipher.type)); strncpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "", - sizeof(rblkcipher.geniv)); + sizeof(rblkcipher.geniv) - 1); rblkcipher.blocksize = alg->cra_blocksize; rblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize; @@ -446,7 +446,7 @@ static int crypto_givcipher_report(struct sk_buff *skb, struct crypto_alg *alg) strncpy(rblkcipher.type, "givcipher", sizeof(rblkcipher.type)); strncpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "", - sizeof(rblkcipher.geniv)); + sizeof(rblkcipher.geniv) - 1); rblkcipher.blocksize = alg->cra_blocksize; rblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize; diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c index 01c0d4aa2563..f1644b5cf68c 100644 --- a/crypto/blkcipher.c +++ b/crypto/blkcipher.c @@ -511,7 +511,7 @@ static int crypto_blkcipher_report(struct sk_buff *skb, struct crypto_alg *alg) strncpy(rblkcipher.type, "blkcipher", sizeof(rblkcipher.type)); strncpy(rblkcipher.geniv, alg->cra_blkcipher.geniv ?: "", - sizeof(rblkcipher.geniv)); + sizeof(rblkcipher.geniv) - 1); rblkcipher.blocksize = alg->cra_blocksize; rblkcipher.min_keysize = alg->cra_blkcipher.min_keysize;