Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp565098ybt; Wed, 17 Jun 2020 08:14:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEKAZf7PLKBAySLIWQ+pW1Zy1H4PCbKoPK+6gZuUnemJGNW9a+tLcw22fVUWE6TFQ9uJod X-Received: by 2002:a17:906:7c57:: with SMTP id g23mr7430660ejp.299.1592406867323; Wed, 17 Jun 2020 08:14:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592406867; cv=none; d=google.com; s=arc-20160816; b=TEs2FD35hBvhA0gcPeHy4rVRQNuyCiBG8m1ew0JBVn2IdsdoWnFcxiZD2BidFC40Xc 7Q6sofhek+1pgxfDscRY2Xr2VXjeQAXtpsq5GdOkeShsjWFzrusD6m22W4mE4V3SyQ/I AGLyKQax6C50XneKK//5GpKeccr+3nZtmQ94Fn+Or2DO3Rwv9mcXoM3BG1cXT9tJh9Oi d5H2Nm3mVhNBzHDmIF1q9C4deKOyrhA4VEW1aUbgMfSJT0xZIfbfIADSLauJh+h6gbj+ YxwW7bUpzTKgL7yRnKuGM4ZVp0owW2HRQOJYTLA8zBAq94ysZGHnoSnFnz+ha7FUguwx Pydw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=kAhDrMvU6clWQTo7oSKR54eeGeEEWBU/2DQIntg4cUE=; b=kPJYmlOItRXWe7WAx4/yJ2l1nQDWqp3klZDZoO313FnXwp1c1SHR5EK3K7MIgY2p8O N1EHXxV87rBi/AAlusL0bXj2bJE4CxwAZ4K49peAs5PIxdJzM1Ogi6fZgn6MNLm6pQe+ Ew8A9Gmjizn6WwCvJx3IxKjPDe8d8wA94voF+lToqQans5yJIzegcuZiDkGhro5GXbKO 0b7OGAsDNwZFdAhE1yELbTCeHniG7VjbSrbyGLZyZsIZdx0UK/yzH1fwmlbT4kCad9m3 aWqFUtPbHiERVMEaFDdCvITAnc5W2mYbYCwERO1OW9liTPX5g6p7TtR5FYJH0CdHYK8R shZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AM1E9sG1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bz6si67599ejc.515.2020.06.17.08.14.04; Wed, 17 Jun 2020 08:14:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AM1E9sG1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726867AbgFQPLV (ORCPT + 99 others); Wed, 17 Jun 2020 11:11:21 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:36756 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726496AbgFQPLU (ORCPT ); Wed, 17 Jun 2020 11:11:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592406679; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=kAhDrMvU6clWQTo7oSKR54eeGeEEWBU/2DQIntg4cUE=; b=AM1E9sG1hwdat9cYJwvA4yKYiN4TnbG+6kW9ry8/yBZAEtexT4Yc/rxT2Uas8qWYzqJUVP 0NBlfU0BrLXe5l0+T9KWo74i8l+nSB5kwipMe2/y6MJPtw8VV+JlcK79gpljAwdtHv1Asq XAgGwJVlU6KenKQaxbvLIcFVgUaEp/M= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-140-jP_8C3t7PhyYQDR-j_UjWA-1; Wed, 17 Jun 2020 11:11:16 -0400 X-MC-Unique: jP_8C3t7PhyYQDR-j_UjWA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 530631100F67; Wed, 17 Jun 2020 15:11:15 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A749A60BF4; Wed, 17 Jun 2020 15:11:08 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id 05HFB8tP029064; Wed, 17 Jun 2020 11:11:08 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id 05HFB8dA029060; Wed, 17 Jun 2020 11:11:08 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Wed, 17 Jun 2020 11:11:07 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Eric Biggers cc: Herbert Xu , Mike Snitzer , linux-kernel@vger.kernel.org, dm-devel@redhat.com, linux-crypto@vger.kernel.org, "David S. Miller" , Milan Broz , Jonathan Cameron , George Cherian , Wei Xu , Zaibo Xu Subject: [PATCH 3/3] dm-crypt: don't use drivers that have CRYPTO_ALG_ALLOCATES_MEMORY In-Reply-To: Message-ID: References: <20200610010450.GA6449@gondor.apana.org.au> <20200610121106.GA23137@gondor.apana.org.au> <20200616173620.GA207319@gmail.com> User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Don't use crypto drivers that have the flag CRYPTO_ALG_ALLOCATES_MEMORY set. These drivers allocate memory and thus they are unsuitable for block I/O processing. Signed-off-by: Mikulas Patocka --- drivers/md/dm-crypt.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) Index: linux-2.6/drivers/md/dm-crypt.c =================================================================== --- linux-2.6.orig/drivers/md/dm-crypt.c +++ linux-2.6/drivers/md/dm-crypt.c @@ -419,7 +419,8 @@ static int crypt_iv_lmk_ctr(struct crypt return -EINVAL; } - lmk->hash_tfm = crypto_alloc_shash("md5", 0, 0); + lmk->hash_tfm = crypto_alloc_shash("md5", 0, + CRYPTO_ALG_ALLOCATES_MEMORY); if (IS_ERR(lmk->hash_tfm)) { ti->error = "Error initializing LMK hash"; return PTR_ERR(lmk->hash_tfm); @@ -581,7 +582,8 @@ static int crypt_iv_tcw_ctr(struct crypt return -EINVAL; } - tcw->crc32_tfm = crypto_alloc_shash("crc32", 0, 0); + tcw->crc32_tfm = crypto_alloc_shash("crc32", 0, + CRYPTO_ALG_ALLOCATES_MEMORY); if (IS_ERR(tcw->crc32_tfm)) { ti->error = "Error initializing CRC32 in TCW"; return PTR_ERR(tcw->crc32_tfm); @@ -768,7 +770,8 @@ static int crypt_iv_elephant_ctr(struct struct iv_elephant_private *elephant = &cc->iv_gen_private.elephant; int r; - elephant->tfm = crypto_alloc_skcipher("ecb(aes)", 0, 0); + elephant->tfm = crypto_alloc_skcipher("ecb(aes)", 0, + CRYPTO_ALG_ALLOCATES_MEMORY); if (IS_ERR(elephant->tfm)) { r = PTR_ERR(elephant->tfm); elephant->tfm = NULL; @@ -2088,7 +2091,8 @@ static int crypt_alloc_tfms_skcipher(str return -ENOMEM; for (i = 0; i < cc->tfms_count; i++) { - cc->cipher_tfm.tfms[i] = crypto_alloc_skcipher(ciphermode, 0, 0); + cc->cipher_tfm.tfms[i] = crypto_alloc_skcipher(ciphermode, 0, + CRYPTO_ALG_ALLOCATES_MEMORY); if (IS_ERR(cc->cipher_tfm.tfms[i])) { err = PTR_ERR(cc->cipher_tfm.tfms[i]); crypt_free_tfms(cc); @@ -2114,7 +2118,8 @@ static int crypt_alloc_tfms_aead(struct if (!cc->cipher_tfm.tfms) return -ENOMEM; - cc->cipher_tfm.tfms_aead[0] = crypto_alloc_aead(ciphermode, 0, 0); + cc->cipher_tfm.tfms_aead[0] = crypto_alloc_aead(ciphermode, 0, + CRYPTO_ALG_ALLOCATES_MEMORY); if (IS_ERR(cc->cipher_tfm.tfms_aead[0])) { err = PTR_ERR(cc->cipher_tfm.tfms_aead[0]); crypt_free_tfms(cc); @@ -2565,7 +2570,7 @@ static int crypt_ctr_auth_cipher(struct return -ENOMEM; strncpy(mac_alg, start, end - start); - mac = crypto_alloc_ahash(mac_alg, 0, 0); + mac = crypto_alloc_ahash(mac_alg, 0, CRYPTO_ALG_ALLOCATES_MEMORY); kfree(mac_alg); if (IS_ERR(mac))