Received: by 10.223.164.202 with SMTP id h10csp6182525wrb; Wed, 22 Nov 2017 00:10:04 -0800 (PST) X-Google-Smtp-Source: AGs4zMZhFYPu4ACf5mJxfztckwocgXFwtFBIg3GOJmoC1baVksr9faQXBnRzsi1KH+7EYvNwDOnB X-Received: by 10.101.67.197 with SMTP id n5mr17407632pgp.392.1511338204329; Wed, 22 Nov 2017 00:10:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511338204; cv=none; d=google.com; s=arc-20160816; b=fIn4gejKMjododiTm/P2fw5+2oSI9XXYxsE1xt93qpCA1wlsZDw4HHrHfqkDOMZcXn A/OFI8nFZg1XS13Zyts2IBdmVkR2LLKh7dmnCNGqNJlg/68fnoo/YtEIF5GmBeOfX9tp r53//IehhWiKBq9Zagejk4/8rrlCxViwiw5iGGN6WRU6mSEjRlBprMsb8XwAZBIPg5bg s4W540xfF8MR4XVnrHLmG8kdTZCLj6Tcpp1yb2pdfhIIFWT7Zy43/Q2hoFZa3ZepviDm EzUZlx172qEStGTrPVZRdNV8nLXMvTnJgXV/mTHomKnWcU3ksSR5OrYVagrPNs7bDvLT d/cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=aDvp4raXRqBUxMlDqi/pUU/yPygJOnR2GK9MsJvPRUA=; b=YOaGT+cjCiWRd/cHJTrpZOxSsOOY2IvhWJVkHti7nUAmGKbT6PJN4fGIj9iA+Y2i5P xFFwOOwOk3yBwDD2FoOzlkn8NjFwEXoBEP1VcQTFU47Pu+pt4at+BRrS+pZJ9t5b7vow nxEw1HJvWZ4un8qjaw+TeuXPbmh71zUpZK5MNath5CgCn7sQhwa4zR7DE+oVqT1/gfky WwlIus4rtLL/RsF2dCBZtHUhef5aINtVYpR8lGhU6+OJl1i3LEoxmHb7rypMgEgY1kX/ VkG19OXq36B7GnEvqaUop689H/X0KgAyQx18QCrkMnO80VjKg3LCqfAnCiW9roc8uZ0Y YyNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=OQrLOqQ0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w10si1307079pgr.259.2017.11.22.00.09.53; Wed, 22 Nov 2017 00:10:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=OQrLOqQ0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751734AbdKVIIu (ORCPT + 76 others); Wed, 22 Nov 2017 03:08:50 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:41971 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751688AbdKVIIs (ORCPT ); Wed, 22 Nov 2017 03:08:48 -0500 Received: by mail-wr0-f194.google.com with SMTP id z14so13679835wrb.8 for ; Wed, 22 Nov 2017 00:08:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=aDvp4raXRqBUxMlDqi/pUU/yPygJOnR2GK9MsJvPRUA=; b=OQrLOqQ0Fc7vZBWRPMLV6Uf15jOL0oF5qvTQTSw6ZsN1j2cWfidURnO7NXdlYJYKoF kZqHr72XUEMqnOmqkbbZMSgCrDXfm0y2EzOYkI6iZMsMetDYIANHnG4vkp+DeV69RBPU yNCgz3UiFhK9bEvWvU9f6hgINUgHwy3FxL3c5JMfN1bwC7WxK71gnHfRwkAFi1UdC4Wq iwo+kG22FPk+/4XcCmE91wzpJT9xU3rq42xRf7D7WSzgekDeNBDeJsDJ7gYNJ6vd44gW Zgry2W3ZT7XacwO1u6bi1k/mX3+2tydUjs+nCbNivWFqkkG/DvurPazadDH6+mHpaOeY r0Cw== 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; bh=aDvp4raXRqBUxMlDqi/pUU/yPygJOnR2GK9MsJvPRUA=; b=KFOm//6W5943rMU6j84T/aPuoudF5XLe34AJrDx7sK+MZHBReF1SeTL2Xe9efum952 3qk0yItH+2nP+iHGfxgaDO/CcgMgi1z72RG4srVTVjAn0aN53MvtumDKT2JuiQlYWci7 Vqu7owM1s+IS8cvXhH4E5ZgOqNe6hTwDvpZ/xGO4/afKXfInVYz97PE2hli4PEFbcAmr fTb0g64n7XnazYz49QpFdlEQI8CTjq1moQEjvHwcdd4G026Xz0gU/OYBgZVq/etLdBAi X2yxtENquS0DQpiXj8spuCuTo6NWmSpGxLi6qKjJS1XdGpY3AEaM+A67OA5+WxiOeWT6 Pvlg== X-Gm-Message-State: AJaThX74Oyll50T2SsiT8Mk6DblWWotipm7WOH9Ful8/MQkY1OIL7eOi SRMkCuYKtgenBLiNFzlaG/fs2Q== X-Received: by 10.223.139.140 with SMTP id o12mr15830441wra.78.1511338127076; Wed, 22 Nov 2017 00:08:47 -0800 (PST) Received: from localhost.localdomain ([51.15.160.169]) by smtp.googlemail.com with ESMTPSA id g65sm3958849wmd.16.2017.11.22.00.08.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Nov 2017 00:08:46 -0800 (PST) From: Corentin Labbe To: herbert@gondor.apana.org.au, davem@davemloft.net, catalin.marinas@arm.com, will.deacon@arm.com Cc: linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Corentin Labbe Subject: [PATCH] crypto: arm64/aes - do not call crypto_unregister_skcipher twice on error Date: Wed, 22 Nov 2017 08:08:34 +0000 Message-Id: <1511338114-39583-1-git-send-email-clabbe@baylibre.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a cipher fail to register in aes_init(), the error path go thought aes_exit() then crypto_unregister_skciphers(). Since aes_exit calls also crypto_unregister_skcipher, this trigger a refcount_t: underflow; use-after-free. Signed-off-by: Corentin Labbe --- arch/arm64/crypto/aes-glue.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm64/crypto/aes-glue.c b/arch/arm64/crypto/aes-glue.c index 998ba519a026..9e42ec96243e 100644 --- a/arch/arm64/crypto/aes-glue.c +++ b/arch/arm64/crypto/aes-glue.c @@ -664,7 +664,10 @@ static int __init aes_init(void) return 0; unregister_simds: - aes_exit(); + for (i = 0; i < ARRAY_SIZE(aes_simd_algs); i++) + if (aes_simd_algs[i]) + simd_skcipher_free(aes_simd_algs[i]); + crypto_unregister_shashes(mac_algs, ARRAY_SIZE(mac_algs)); unregister_ciphers: crypto_unregister_skciphers(aes_algs, ARRAY_SIZE(aes_algs)); return err; -- 2.13.6 From 1584223560583123402@xxx Thu Nov 16 11:55:21 +0000 2017 X-GM-THRID: 1583956280156846181 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread