Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp140262ybg; Tue, 2 Jun 2020 19:08:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydb4qZHfOwHBy+zp645mjro2y6WydKjR/hn9rwfH78J48TuAtPmmnslHYg95UFWmqVnm35 X-Received: by 2002:aa7:d48f:: with SMTP id b15mr13805140edr.8.1591150102163; Tue, 02 Jun 2020 19:08:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591150102; cv=none; d=google.com; s=arc-20160816; b=Rs9lDbwLdUqIctfGi4SPJU8H+7JPTt5//qTUQdtU+rwDfeXRyeeL14M+9M8ekgl85v ousq4svNNHsH6xbydMnzxuiVhxARCpPQhJb2SW3CIlBiK1JboDebZbsbCO9WyDeoRQg7 9ixhIsGOfyhLt7GMh7RIbnpGzSsRwidKQHoj4JWbF/lqR1lPMRNXOflwvoTn+ncDrhTR E2XbYd3pidzj3f6xlqxWIfX4KeShtX4CuQhjnIBUfB2sgry/lxuTvNl8yQX7quMdmR9i K81y+QW4gwGdytSE5HuNO3SXTMAy4mKxZlv0Pqgi0fN2co8ZS888Gu2z/aFVhe4BA4jG MLIQ== 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=tEFdXShQJ0up1pN37XQdL2Osut/PFZARmSLjyY6TQgA=; b=nG/zQFvpY+i6ARyIsTladCH/CQA3sLEILFC8AWMWWMUNRtXUyY86KjuztBsqoeflQH M3Sy4ECPsk9r91v3ZZJQqdHFj462fSA8M8PUsuAuRLKiDeplK01AD3E9BHIUt+J8EjPZ go67NiZQ+BlbmnIRn3JVUm7RmR6Uz9xiMSXVK6Fcj7BE863gREQ/6ZrptpPkRPGqAtDA gSfTRc2JO0N+ZKgOcmpZSHn/FUgJGEnluplmHoD+sOtBNogrlEMCz+FCDr/Tp4kyJw8X CmZtCFmzMPypV6FdYFghTjSB5NnS1+t6WVataJhIE3hR0y2zdkVIuFnAHWPww92DHQpN lpDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aq1ZrZwQ; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-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 30si318280edr.262.2020.06.02.19.07.53; Tue, 02 Jun 2020 19:08:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=aq1ZrZwQ; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-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 S1725794AbgFCCHp (ORCPT + 99 others); Tue, 2 Jun 2020 22:07:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:46960 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725789AbgFCCHp (ORCPT ); Tue, 2 Jun 2020 22:07:45 -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 32A502072F; Wed, 3 Jun 2020 02:07:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591150064; bh=qLcUIqg4MkGQXm/ALUeDTBM4qZrROCTmpgT+XERn3Wo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aq1ZrZwQU3kRCrtJOZAwJUWVfYq2+bOd3t19aKhFjRpZJjQ7d+Ws0QDXHtHTp4POk R8bz/dDLIX+5ng8Qi7HF7HQhyQniQJZPjcc7IzSHpZ0zGN5s5i/2EhPAsNVyErNBhD imgt4H8pvVTVYE1AU9KFtJHzqyXDQxsAq7RLeOCY= Date: Tue, 2 Jun 2020 19:07:42 -0700 From: Eric Biggers To: Satya Tangirala Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, linux-fscrypt@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-ext4@vger.kernel.org, Barani Muthukumaran , Kuohong Wang , Kim Boojin Subject: Re: [PATCH v13 10/12] fscrypt: add inline encryption support Message-ID: <20200603020742.GA50072@sol.localdomain> References: <20200514003727.69001-1-satyat@google.com> <20200514003727.69001-11-satyat@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200514003727.69001-11-satyat@google.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org One more thing: On Thu, May 14, 2020 at 12:37:25AM +0000, Satya Tangirala wrote: > +/* Enable inline encryption for this file if supported. */ > +void fscrypt_select_encryption_impl(struct fscrypt_info *ci) > +{ > + const struct inode *inode = ci->ci_inode; > + struct super_block *sb = inode->i_sb; > + struct blk_crypto_config crypto_cfg; > + int num_devs; > + struct request_queue **devs; > + int i; > + > + /* The file must need contents encryption, not filenames encryption */ > + if (!fscrypt_needs_contents_encryption(inode)) > + return; > + > + /* The crypto mode must be valid */ > + if (ci->ci_mode->blk_crypto_mode == BLK_ENCRYPTION_MODE_INVALID) > + return; > + > + /* The filesystem must be mounted with -o inlinecrypt */ > + if (!(sb->s_flags & SB_INLINECRYPT)) > + return; > + > + /* > + * blk-crypto must support the crypto configuration we'll use for the > + * inode on all devices in the sb > + */ > + crypto_cfg.crypto_mode = ci->ci_mode->blk_crypto_mode; > + crypto_cfg.data_unit_size = sb->s_blocksize; > + crypto_cfg.dun_bytes = fscrypt_get_dun_bytes(ci); > + num_devs = fscrypt_get_num_devices(sb); > + devs = kmalloc_array(num_devs, sizeof(*devs), GFP_NOFS); > + if (!devs) > + return; This function needs to return an error code, so that if this memory allocation fails, the error is not ignored. - Eric