Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34BE2C4360F for ; Wed, 20 Feb 2019 06:55:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 06FA72147A for ; Wed, 20 Feb 2019 06:55:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550645712; bh=5LYMT5g+CNbalpnPlcMdbfzsnzxCoHQt6lh+tMxW4tA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=H+MhDNNWf+ZEdq6rqdJYHVN2BXBfx2rjgVFuOc9PCgYhZ4N2A9+MiZFfXsg8nDR4k Myzg6LWC/dvaamT+H221VhtfbDrmty1wAeHTwc4p8dDTq+MIJXc7nzZYXOQGoF1rEd l+l6NSv17y1ymDZ1jaM9fBy3xowpuTPTE4k61IBk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730693AbfBTGyn (ORCPT ); Wed, 20 Feb 2019 01:54:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:54368 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730611AbfBTGyi (ORCPT ); Wed, 20 Feb 2019 01:54:38 -0500 Received: from sol.localdomain (c-107-3-167-184.hsd1.ca.comcast.net [107.3.167.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 02CC221908; Wed, 20 Feb 2019 06:54:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550645677; bh=5LYMT5g+CNbalpnPlcMdbfzsnzxCoHQt6lh+tMxW4tA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VSxHun0gzKcHVQORrZd+dgP77EP6qgQRoZmtFr2HdBLUOQCgKrHlWK0pf9e4DVCak NQYmB1D8EFk1Y52v0mC8UxN6nMNOrI4+4J9Na6B7+Z1s1/ZL0zm0IFsokJo2AzT7+g RjsUNQiHpgcx+Iq6LOAxMGHufHGOgQoqkM/UuLiw= From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: Satya Tangirala , linux-api@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, keyrings@vger.kernel.org, linux-mtd@lists.infradead.org, linux-crypto@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, Paul Crowley Subject: [RFC PATCH v3 05/18] fscrypt: add ->ci_inode to fscrypt_info Date: Tue, 19 Feb 2019 22:52:36 -0800 Message-Id: <20190220065249.32099-6-ebiggers@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190220065249.32099-1-ebiggers@kernel.org> References: <20190220065249.32099-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Add an inode back-pointer to 'struct fscrypt_info', such that inode->i_crypt_info->ci_inode == inode. This will be useful for: 1. Evicting the inodes when a fscrypt key is removed, since we'll track the inodes using a given key by linking their fscrypt_infos together, rather than the inodes directly. This avoids bloating 'struct inode' with a new list_head. 2. Simplifying the per-file key setup, since the inode pointer won't have to be passed around everywhere just in case something goes wrong and it's needed for fscrypt_warn(). Signed-off-by: Eric Biggers --- fs/crypto/fscrypt_private.h | 3 +++ fs/crypto/keyinfo.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/fs/crypto/fscrypt_private.h b/fs/crypto/fscrypt_private.h index 52e09ef40bfa..ac24edfc297f 100644 --- a/fs/crypto/fscrypt_private.h +++ b/fs/crypto/fscrypt_private.h @@ -73,6 +73,9 @@ struct fscrypt_info { */ struct fscrypt_mode *ci_mode; + /* Back-pointer to the inode */ + struct inode *ci_inode; + /* * If non-NULL, then this inode uses a master key directly rather than a * derived key, and ci_ctfm will equal ci_master_key->mk_ctfm. diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c index a8c1e886b0bc..6c1e675d4eef 100644 --- a/fs/crypto/keyinfo.c +++ b/fs/crypto/keyinfo.c @@ -542,6 +542,8 @@ int fscrypt_get_encryption_info(struct inode *inode) if (!crypt_info) return -ENOMEM; + crypt_info->ci_inode = inode; + crypt_info->ci_flags = ctx.flags; crypt_info->ci_data_mode = ctx.contents_encryption_mode; crypt_info->ci_filename_mode = ctx.filenames_encryption_mode; -- 2.20.1