From patchwork Mon Jan 18 15:40:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 8055571 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9443B9F859 for ; Mon, 18 Jan 2016 15:41:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9C24C20495 for ; Mon, 18 Jan 2016 15:41:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A80BA2045A for ; Mon, 18 Jan 2016 15:41:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755612AbcARPkl (ORCPT ); Mon, 18 Jan 2016 10:40:41 -0500 Received: from mout.kundenserver.de ([212.227.17.10]:59807 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755533AbcARPkh (ORCPT ); Mon, 18 Jan 2016 10:40:37 -0500 Received: from wuerfel.localnet ([134.3.118.24]) by mrelayeu.kundenserver.de (mreue102) with ESMTPSA (Nemesis) id 0Lu5Kw-1aC4mU0CRi-011UOa; Mon, 18 Jan 2016 16:40:24 +0100 From: Arnd Bergmann To: Herbert Xu Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, davem@davemloft.net, Krzysztof =?utf-8?B?SGHFgmFzYQ==?= Subject: [PATCH] crypto: ixp4xx: avoid uninitialized variable use Date: Mon, 18 Jan 2016 16:40:15 +0100 Message-ID: <4569235.PkyVAB6DSj@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) MIME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ernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The move to the new AEAD interface introduced a path through the aead_perform() function in the ixp4xx_crypto driver that leaves lastlen uninitialized, as gcc warns: crypto/ixp4xx_crypto.c:1072:5: error: 'lastlen' may be used uninitialized in this function [-Werror=maybe-uninitialized] crypto/ixp4xx_crypto.c: In function 'aead_perform': if (unlikely(lastlen < authsize)) { I don't really understand what the code does, but the warning appears to be correct, and this is my best guess at how it should behave instead: I'm introducing a temporary variable that indicates whether we need to allocate an extra buffer or not, and defaults that variable to 'false', so we only allocate the buffer if one of the cases happen where we know that "lastlen < authsize". Signed-off-by: Arnd Bergmann Fixes: d7295a8dc965 ("crypto: ixp4xx - Convert to new AEAD interface") --- Hi Herbert, It was one of your patches that introduced the warning, so you may be able to come up with a better fix than I did. Please see this as a bug report. I have applied it in my ARM randconfig test tree to shut up the warning for now. -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c index e52496a172d0..00c39a5aa4c7 100644 --- a/drivers/crypto/ixp4xx_crypto.c +++ b/drivers/crypto/ixp4xx_crypto.c @@ -999,6 +999,7 @@ static int aead_perform(struct aead_request *req, int encrypt, GFP_KERNEL : GFP_ATOMIC; enum dma_data_direction src_direction = DMA_BIDIRECTIONAL; unsigned int lastlen; + bool shortbuf = false; if (qmgr_stat_full(SEND_QID)) return -EAGAIN; @@ -1052,6 +1053,8 @@ static int aead_perform(struct aead_request *req, int encrypt, if (lastlen >= authsize) crypt->icv_rev_aes = buf->phys_addr + buf->buf_len - authsize; + else + shortbuf = true; } } @@ -1067,9 +1070,11 @@ static int aead_perform(struct aead_request *req, int encrypt, if (lastlen >= authsize) crypt->icv_rev_aes = buf->phys_addr + buf->buf_len - authsize; + else + shortbuf = true; } - if (unlikely(lastlen < authsize)) { + if (unlikely(shortbuf)) { /* The 12 hmac bytes are scattered, * we need to copy them into a safe buffer */ req_ctx->hmac_virt = dma_pool_alloc(buffer_pool, flags,