Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2245952ybt; Sun, 28 Jun 2020 12:47:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhd3CWo23OXmCAblrotpzkspptx/2AFErqvNOapxCl3mJs/OZCqZrj0wVKOVrtLddm6u70 X-Received: by 2002:a50:f9c9:: with SMTP id a9mr14883405edq.89.1593373637582; Sun, 28 Jun 2020 12:47:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593373637; cv=none; d=google.com; s=arc-20160816; b=iomY4zaGLDdYZHEBfXLB0bHwkOylxsY1Mm2G2mTmLN58vLM8MIfA0RhuTCX8HrF7O3 6Jf3yZbRaO18J8NKWZtEnH+XoEVORg4CAQNZeBWs978yNjGXl4ePHlo52gIo8QywaQAs vNAyu7UR19lT71RmQ5BW5aLIlpxN7YPBjUjLQMTZmSCNL78dyD4MKv8dR4Q/Apq76IHb 6DfJ3CGuk4Sl9nBG2m7pFdNR/f1SnH+X+tcK5cNpJDofND5/SHNaEjPE33DQRZjx8by5 CqkK6zQa6K6DTGMHB5nGdfNwORS+cYSqqR1OwZvgTKdwYHW48rPmxWnRDWjTOpGBxSZv 2ZsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=+WTGTKkxwbOKejRC5Wdil0qieeCCScCJQ0BFAYHpaCo=; b=rbmOUwJcYrRTDHTu3i2EWuD/k9ESK3ubsxpAPucBxktxRa7lAx190fhPk7TaHrOc23 rGctNxT5B0ryQANTZkj9iz15d3+FGloZboLRijMvd15miFzy0dV4wvUW/4ulg+E/3l+i bNTZGEMwBBrrCnlXSVsXCZWMUqg76C1STkLnVh9xr5trETIXL/lk1tfRqml+U7VRrETm WvQU5JiNuM94A0Wwj3/dwf9JOibaYJOcTANp4yjAZoju9Oh6O50st5vD396hbmHYG0ao KN2gy51ttuRC0ZlZNUNkTLmcw72aYe7Sr1fZNCJKXn+MrhI49f5fXNmGfsfz78wIsIi6 iOvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GqdbIERt; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u8si8819345ejx.92.2020.06.28.12.46.45; Sun, 28 Jun 2020 12:47:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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=@kernel.org header.s=default header.b=GqdbIERt; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726695AbgF1Tqm (ORCPT + 99 others); Sun, 28 Jun 2020 15:46:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:45820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726675AbgF1Tql (ORCPT ); Sun, 28 Jun 2020 15:46:41 -0400 Received: from sol.localdomain (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 966E620578; Sun, 28 Jun 2020 19:46:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593373600; bh=Ezo07td5DwwHp76rybCIqbuSLH9bu67PkKqFw8Mpmzk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GqdbIERtsL/GPnLBRdl97fpH9pOHvdOYskVrXWx/vDagKGMJlGHDea/RKrpsfLbOk iSplVvWXCk/yyifC3aPVnlUSiIl6gNXN3+LJhsZkgKbnhNYW6o2IE0l5mOG0QpIYk5 C+Kbokri1y/jvcupQY9aw63t5mhA0QVN5Q3fE1As= Date: Sun, 28 Jun 2020 12:46:39 -0700 From: Eric Biggers To: Mikulas Patocka 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: Re: [PATCH 1/3 v2] crypto: introduce the flag CRYPTO_ALG_ALLOCATES_MEMORY Message-ID: <20200628194639.GC11197@sol.localdomain> References: <20200616173620.GA207319@gmail.com> <20200626044534.GA2870@gondor.apana.org.au> <20200626164617.GA211634@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Sun, Jun 28, 2020 at 03:04:22PM -0400, Mikulas Patocka wrote: > > > Index: linux-2.6/crypto/authenc.c > > > =================================================================== > > > --- linux-2.6.orig/crypto/authenc.c 2020-06-26 17:24:03.566417000 +0200 > > > +++ linux-2.6/crypto/authenc.c 2020-06-26 17:24:03.566417000 +0200 > > > @@ -388,7 +388,8 @@ static int crypto_authenc_create(struct > > > if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask) > > > return -EINVAL; > > > > > > - mask = crypto_requires_sync(algt->type, algt->mask); > > > + mask = crypto_requires_sync(algt->type, algt->mask) | > > > + crypto_requires_nomem(algt->type, algt->mask); > > > > As I suggested earlier, shouldn't there be a function that returns the mask for > > all inherited flags, rather than handling each flag individually? > > Yes - I've created crypto_requires_inherited for this purpose. Since all callers pass in 'struct crypto_attr_type', a better helper might be: static inline int crypto_algt_inherited_mask(struct crypto_attr_type *algt) { return crypto_requires_off(algt->type, algt->mask, CRYPTO_ALG_INHERITED_FLAGS); } > > > @@ -424,7 +425,7 @@ static int crypto_authenc_create(struct > > > goto err_free_inst; > > > > > > inst->alg.base.cra_flags = (auth_base->cra_flags | > > > - enc->base.cra_flags) & CRYPTO_ALG_ASYNC; > > > + enc->base.cra_flags) & CRYPTO_ALG_INHERITED_FLAGS; > > > > Strange indentation here. Likewise in most of the other files. > > I was told that the code should be 80-characters wide. You could use: inst->alg.base.cra_flags = (auth_base->cra_flags | enc->base.cra_flags) & CRYPTO_ALG_INHERITED_FLAGS; Just a suggestion, it's not a big deal... Your indentation of the continuation line just seems weird. > > > --- 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. > > I don't know what do you mean. I mean that the CRYPTO_ALG_ALLOCATES_MEMORY flag is not handled when the 'mask' variable is assigned to earlier in this function. It should use your new helper function, like all the other places in this patch. - Eric