Received: by 10.223.164.202 with SMTP id h10csp1739203wrb; Fri, 24 Nov 2017 00:23:03 -0800 (PST) X-Google-Smtp-Source: AGs4zMbXjxw4aBVErbciH94IEWOsdV2xPp0TuLqWd5DsEjVcNDFm+HsRF0KTOMx10q1Sz+CC7V0B X-Received: by 10.99.152.25 with SMTP id q25mr3954658pgd.245.1511511783868; Fri, 24 Nov 2017 00:23:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511511783; cv=none; d=google.com; s=arc-20160816; b=DCcHiyyGaCnffWec9Jas+YzdOvVuD1xqb1rgcQv7qszJHGBP01ymp5VjwjOOI+juZM ZR80DhtHyDJ/Y9qgEALm2tCA9JBTCKyDDnQoYNJGT6tXnUZs8PE3o7mWv7ZILAgXeuIP Ybg+eTUCstyVrAYdhOZyEZmOCi0DoypBHwatC2Aj1tU5XlsV9rDb4wXe8xdew5hhBn11 dvgpa+p+tGnhXX1DA5bqvvAe7T92Nl1gfefYTnH68TbOWOXNAjYqG7k8RB0Rh2XOP9I9 sEeSbA1dnUxnizy2Ci4dsnUXzii/vALi9JbGc3toDNtmluvIo7lmcRoIwXEudN3SCXVz xVxw== 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=kc1oEMrJEoHOmQgpuz7Ij/uxuM5ZZkrKgnH+dWjimj8=; b=EtEDnfxZ1r+XhXgeRUfm2e5PEo3veYaqkloyXwvEIkkR4x87ErGK9uZjnxAzWf+5S/ DQKC0XU4gUFD8zYT/DijUNVRI8q+byehMVFOZDxX3swu8M1JSNIJh/8WFdSMHDM+oFmM mwVznKAI9FmMW+6QWJp5Ta5mUThJvz2Oqg6JQbkdP+3NxPPYIKpo8S3umEAJk1YwokJm Mj3o7fNpepgGFlwLjoIjaC/68GFmU1Nu4i2/2LAKw8k02/PGEzN71Fd8YDxWhlB5i268 Ew71q02mEPrnAmnH2x9i1vjMbnhuoU5yLIdJl55OHMObwDV4mAxY3SA+8KNa3zgZugmh rzcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=1LI1h77u; 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 t76si13290345pgc.185.2017.11.24.00.22.52; Fri, 24 Nov 2017 00:23:03 -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=1LI1h77u; 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 S1752278AbdKXIWR (ORCPT + 76 others); Fri, 24 Nov 2017 03:22:17 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:37767 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751631AbdKXIWP (ORCPT ); Fri, 24 Nov 2017 03:22:15 -0500 Received: by mail-wr0-f195.google.com with SMTP id k61so19625286wrc.4 for ; Fri, 24 Nov 2017 00:22:15 -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=kc1oEMrJEoHOmQgpuz7Ij/uxuM5ZZkrKgnH+dWjimj8=; b=1LI1h77ucIdDAn6SM9NDxYc07gpTRHQ4DevoVcchAT2GKdM8voj2M3S93Olgac0Q75 NRuIi/ZUdsSE1UgWF/TFF6rdDzOMTR+ny3Hfu6SnGgORQ3JL8XF+J/OqRxbAOFU3lv+U RFrb867rLVFrT7LlJd+yg0GML6/gYoXlCq/lPjs3axylm47VfhtO0UBDjBgC8r2lzoFE U5ADnZVdzuxjjxi8oZ/rZ+cWy+WbeH+4mWORwb/eXIEtsbm9loXzrzy9jPfsqPKNhGt9 koGPT9PlkD3Y0c/dOgFEgAXeJofHGbM49s/+yqAClyHmKim8CXQyim0q5ReMZ5d07z8q tAYQ== 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=kc1oEMrJEoHOmQgpuz7Ij/uxuM5ZZkrKgnH+dWjimj8=; b=m7wc2bgRuohj3oFz5jp1Xd7Kb8GHeEBByo+rDbPlX4e3ynh40nxs+URmqGKVXI6O++ ots+8lxXaPEUBrHOoQng7sfd3XE6CK3X6hw1NQRjJQ0dH1nfsOCthmy6hhWbIlXwvbHq yj8SOuZ0h68bjGpLyCJI6WZhjFoABNyaSuVdgfg71G5o1eN32dF5yYF424klHmpLwsqi wzMbUms6/PMPYjPmsWUOKdEvJYhr4/MO8vQ8Npqi5d/cQ4WYHDT5hLZTDDa+iEVxsZFM iRvy2GJiuvFzw2zz09G4uPOO0m615uq1O8szmc9AfOTSgnbJrA4hx4aEWegpfH3wqXXz AriQ== X-Gm-Message-State: AJaThX4u7mFbG9Ifxox3f648cQ4T96b8vFeSp8/oDUjfyZwV447sqlmq eA/zEhaLnitUiLGRjEn+gFK0yQ== X-Received: by 10.223.153.162 with SMTP id y31mr22755015wrb.216.1511511734637; Fri, 24 Nov 2017 00:22:14 -0800 (PST) Received: from localhost.localdomain ([51.15.160.169]) by smtp.googlemail.com with ESMTPSA id u79sm721321wma.26.2017.11.24.00.22.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Nov 2017 00:22:13 -0800 (PST) From: Corentin Labbe To: herbert@gondor.apana.org.au, davem@davemloft.net, catalin.marinas@arm.com, will.deacon@arm.com, ard.biesheuvel@linaro.org Cc: linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Corentin Labbe Subject: [PATCH v2] ARM64: crypto: do not call crypto_unregister_skcipher twice on error Date: Fri, 24 Nov 2017 08:22:07 +0000 Message-Id: <1511511727-15385-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 fails to register in aes_init(), the error path goes thought aes_exit() then crypto_unregister_skciphers(). Since aes_exit calls also crypto_unregister_skcipher, this triggers a refcount_t: underflow; use-after-free. Signed-off-by: Corentin Labbe --- Changes since v1: - Instead of duplicate code from aes_exit() minus crypto_unregister_skciphers, simply use it and return after as suggested by Ard Biesheuvel arch/arm64/crypto/aes-glue.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/crypto/aes-glue.c b/arch/arm64/crypto/aes-glue.c index 998ba519a026..2fa850e86aa8 100644 --- a/arch/arm64/crypto/aes-glue.c +++ b/arch/arm64/crypto/aes-glue.c @@ -665,6 +665,7 @@ static int __init aes_init(void) unregister_simds: aes_exit(); + return err; unregister_ciphers: crypto_unregister_skciphers(aes_algs, ARRAY_SIZE(aes_algs)); return err; -- 2.13.6 From 1585415218624470536@xxx Wed Nov 29 15:36:14 +0000 2017 X-GM-THRID: 1585415218624470536 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread