Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2227211ybt; Sun, 28 Jun 2020 12:08:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwPMmEv2ks1S2IklITnzZM40UYTILcKtjo/D4I9LXT9YCZarGrbVj36bK9EMBJIA8RUZG3 X-Received: by 2002:a17:906:3d41:: with SMTP id q1mr11463116ejf.12.1593371334610; Sun, 28 Jun 2020 12:08:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593371334; cv=none; d=google.com; s=arc-20160816; b=dVh1KTll2ppvuPJqPXyXfGz576k2HePfzV9EnLtZrNmHdSlVH1Fvm+dPSS6/ZbyOIA tmmJ50CNwgKt9m+wQo5x4iKM2XcutBAGWLY8NrX/rPr+BTGWs0/7sUGOxPWun7CAkM06 QWTolwfdBwemDq1yMpfT+J1d4bWgGYJpaW2E61Y0l5Y/M4rzOZZL58YYNl2CYEYp0fRs 2lcnB9JyLrLhHEFAoiNi3Rj7UXXSIZM8sK2j/6BN7kx8SpGHNzBxByh/JxQTqUoMluut BN95FN6MXM/BcRa4Uuo96TyJJASppmrXkTkryVIPY0w5uxWcdFMOGty6h80VnzgWdB2A H6zw== 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=808YBhmAcPYX0BlfP0ReMxTnZzyESxUCQ1m9Cs1fVs0=; b=ce8ZE0a/6HRWo1avF+M5dktvcfE5ahQBS2dxWVasV1FmBXwSRH46L2x/xs9+sgdHGX tL5uvwtFkWfTcHkHZa9bEPL/uBT6vBIhRiqyBvng3Qo7+2WN/ZB4b6kUj7ZZB9smU8rh waoQFsrM7r5CPwmaz12IFji+5n8f5PFSEcwcn95W5IaqkQimYa6iWGkk4yFsm8Jd3Ruw YFxPOVznEPStpXvZtLqACPAxd9h15EZLk1OnYKHO6PC1mih0DpCvsIWDmeU26rhYdykJ 6ILJZx+Exal+POwyEWqtK0FLjoSNu6tg6ogwS0l9wJ/e4/lDTep6fhFPZxbxhDG1Om7J 3m6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ILzlmwOE; 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 oa24si3092964ejb.571.2020.06.28.12.08.30; Sun, 28 Jun 2020 12:08:54 -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=ILzlmwOE; 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 S1726751AbgF1TIE (ORCPT + 99 others); Sun, 28 Jun 2020 15:08:04 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:28391 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726740AbgF1TID (ORCPT ); Sun, 28 Jun 2020 15:08:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593371282; 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=808YBhmAcPYX0BlfP0ReMxTnZzyESxUCQ1m9Cs1fVs0=; b=ILzlmwOEVOMK4h8HpmM2RtGq3mxhNp/m/jzUVoDZ4xOGtT1KCNHsaV2ibYcddqfIlYCkM0 2Zl5l4enUUvJN9MrVkea8tgaddgfwML+nBz0a2PkB6EHmpe+LXJJhsQxhtG+27M/2QVuxh mrQ41rzy7nkjBdpN1HhzXNk13rCGp7g= 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-273-R1Xja-j8Ppe6RRr2BPxMEw-1; Sun, 28 Jun 2020 15:07:54 -0400 X-MC-Unique: R1Xja-j8Ppe6RRr2BPxMEw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CA5528010C4; Sun, 28 Jun 2020 19:07:52 +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 E50935C1D2; Sun, 28 Jun 2020 19:07:49 +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 05SJ7n1T003745; Sun, 28 Jun 2020 15:07:49 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id 05SJ7nbm003741; Sun, 28 Jun 2020 15:07:49 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Sun, 28 Jun 2020 15:07:49 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Eric Biggers cc: Mike Snitzer , Herbert Xu , Zaibo Xu , linux-kernel@vger.kernel.org, Wei Xu , dm-devel@redhat.com, George Cherian , linux-crypto@vger.kernel.org, Jonathan Cameron , "David S. Miller" , Milan Broz Subject: Re: [dm-devel] [PATCH 1/3 v2] crypto: introduce the flag CRYPTO_ALG_ALLOCATES_MEMORY In-Reply-To: <20200626170039.GB211634@gmail.com> Message-ID: References: <20200610121106.GA23137@gondor.apana.org.au> <20200616173620.GA207319@gmail.com> <20200626044534.GA2870@gondor.apana.org.au> <20200626164617.GA211634@gmail.com> <20200626170039.GB211634@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.16 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 26 Jun 2020, Eric Biggers wrote: > On Fri, Jun 26, 2020 at 09:46:17AM -0700, Eric Biggers wrote: > > On Fri, Jun 26, 2020 at 12:16:33PM -0400, Mikulas Patocka wrote: > > > +/* > > > + * Pass these flags down through the crypto API. > > > + */ > > > +#define CRYPTO_ALG_INHERITED_FLAGS (CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY) > > > > This comment is useless. How about: > > > > /* > > * When an algorithm uses another algorithm (e.g., if it's an instance of a > > * template), these are the flags that always get set on the "outer" algorithm > > * if any "inner" algorithm has them set. In some cases other flags are > > * inherited too; these are just the flags that are *always* inherited. > > */ > > #define CRYPTO_ALG_INHERITED_FLAGS (CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY) > > > > Also I wonder about the case where the inner algorithm is a fallback rather than > > part of a template instance. This patch only handles templates, not fallbacks. > > Is that intentional? Isn't that technically a bug? > > Also is CRYPTO_ALG_ALLOCATES_MEMORY meant to apply for algorithms of type > "cipher" and "shash"? The code doesn't handle those, so presumably not? > > What about "akcipher"? Yes - the patch should apply for these cases, but I don't know how to do it. Please, do it. > > > Index: linux-2.6/crypto/xts.c > > > =================================================================== > > > --- linux-2.6.orig/crypto/xts.c 2020-06-26 17:24:03.566417000 +0200 > > > +++ linux-2.6/crypto/xts.c 2020-06-26 17:24:03.566417000 +0200 > > > @@ -415,7 +415,7 @@ static int create(struct crypto_template > > > } else > > > goto err_free_inst; > > > > > > - inst->alg.base.cra_flags = alg->base.cra_flags & CRYPTO_ALG_ASYNC; > > > + inst->alg.base.cra_flags = alg->base.cra_flags & CRYPTO_ALG_INHERITED_FLAGS; > > > inst->alg.base.cra_priority = alg->base.cra_priority; > > > inst->alg.base.cra_blocksize = XTS_BLOCK_SIZE; > > > inst->alg.base.cra_alignmask = alg->base.cra_alignmask | > > > > Need to set the mask correctly in this file. > > cryptd_create_skcipher(), cryptd_create_hash(), cryptd_create_aead(), and > crypto_rfc4309_create() are also missing setting the mask. > > pcrypt_create_aead() is missing both setting the mask and inheriting the flags. I added CRYPTO_ALG_ALLOCATES_MEMORY there. > Also, "seqiv" instances can be created without CRYPTO_ALG_ALLOCATES_MEMORY set, > despite seqiv_aead_encrypt() allocating memory. > > - Eric Mikulas