From patchwork Tue May 12 18:59:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Theodore Ts'o X-Patchwork-Id: 471500 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 948971402C4 for ; Wed, 13 May 2015 05:03:01 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=thunk.org header.i=@thunk.org header.b=dCH3FR8+; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933538AbbELTBd (ORCPT ); Tue, 12 May 2015 15:01:33 -0400 Received: from imap.thunk.org ([74.207.234.97]:60060 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753565AbbELTAb (ORCPT ); Tue, 12 May 2015 15:00:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=thunk.org; s=ef5046eb; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=b0H6KJ7KwVzWKZQHaQUvLkec/2AAv/zF9YvmIBrQNJs=; b=dCH3FR8+Spo9iOzxPZJkTbmjZxANmQfDxkAywckqqX9n+rqghfsdw7q5Rf4JbyO29tuay/11wBQhhhQ3s1zl3Dps5gs3glKEKOv0hUx+cuowgT2/8zxCdvyF7En6WldarJ9UYDxE0KcG0EmT/gtNtZUWYdEI+PfaU9LgXpQgXkQ=; Received: from root (helo=closure.thunk.org) by imap.thunk.org with local-esmtp (Exim 4.80) (envelope-from ) id 1YsFPL-0001VX-Pw; Tue, 12 May 2015 18:59:59 +0000 Received: by closure.thunk.org (Postfix, from userid 15806) id 770D05806A7; Tue, 12 May 2015 14:59:59 -0400 (EDT) From: Theodore Ts'o To: Ext4 Developers List Cc: jaegeuk@kernel.org, Theodore Ts'o Subject: [PATCH 3/5] ext4 crypto: get rid of ci_mode from struct ext4_crypt_info Date: Tue, 12 May 2015 14:59:50 -0400 Message-Id: <1431457192-3432-3-git-send-email-tytso@mit.edu> X-Mailer: git-send-email 2.3.0 In-Reply-To: <1431457192-3432-1-git-send-email-tytso@mit.edu> References: <1431457192-3432-1-git-send-email-tytso@mit.edu> X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org The ci_mode field was superfluous, and getting rid of it gets rid of an unused hole in the structure. Signed-off-by: Theodore Ts'o --- fs/ext4/crypto.c | 11 +++++------ fs/ext4/crypto_fname.c | 4 ++-- fs/ext4/crypto_key.c | 11 +++++------ fs/ext4/ext4_crypto.h | 1 - 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/fs/ext4/crypto.c b/fs/ext4/crypto.c index 1c34f0e..9969d05 100644 --- a/fs/ext4/crypto.c +++ b/fs/ext4/crypto.c @@ -137,14 +137,13 @@ struct ext4_crypto_ctx *ext4_get_crypto_ctx(struct inode *inode) /* Allocate a new Crypto API context if we don't already have * one or if it isn't the right mode. */ - BUG_ON(ci->ci_mode == EXT4_ENCRYPTION_MODE_INVALID); - if (ctx->tfm && (ctx->mode != ci->ci_mode)) { + if (ctx->tfm && (ctx->mode != ci->ci_data_mode)) { crypto_free_tfm(ctx->tfm); ctx->tfm = NULL; ctx->mode = EXT4_ENCRYPTION_MODE_INVALID; } if (!ctx->tfm) { - switch (ci->ci_mode) { + switch (ci->ci_data_mode) { case EXT4_ENCRYPTION_MODE_AES_256_XTS: ctx->tfm = crypto_ablkcipher_tfm( crypto_alloc_ablkcipher("xts(aes)", 0, 0)); @@ -162,9 +161,9 @@ struct ext4_crypto_ctx *ext4_get_crypto_ctx(struct inode *inode) ctx->tfm = NULL; goto out; } - ctx->mode = ci->ci_mode; + ctx->mode = ci->ci_data_mode; } - BUG_ON(ci->ci_size != ext4_encryption_key_size(ci->ci_mode)); + BUG_ON(ci->ci_size != ext4_encryption_key_size(ci->ci_data_mode)); /* There shouldn't be a bounce page attached to the crypto * context at this point. */ @@ -321,7 +320,7 @@ static int ext4_page_crypto(struct ext4_crypto_ctx *ctx, int res = 0; BUG_ON(!ctx->tfm); - BUG_ON(ctx->mode != ei->i_crypt_info->ci_mode); + BUG_ON(ctx->mode != ei->i_crypt_info->ci_data_mode); if (ctx->mode != EXT4_ENCRYPTION_MODE_AES_256_XTS) { printk_ratelimited(KERN_ERR diff --git a/fs/ext4/crypto_fname.c b/fs/ext4/crypto_fname.c index 374d0e7..e63dd29 100644 --- a/fs/ext4/crypto_fname.c +++ b/fs/ext4/crypto_fname.c @@ -272,9 +272,9 @@ int ext4_setup_fname_crypto(struct inode *inode) if (!ci || ci->ci_ctfm) return 0; - if (ci->ci_mode != EXT4_ENCRYPTION_MODE_AES_256_CTS) { + if (ci->ci_filename_mode != EXT4_ENCRYPTION_MODE_AES_256_CTS) { printk_once(KERN_WARNING "ext4: unsupported key mode %d\n", - ci->ci_mode); + ci->ci_filename_mode); return -ENOKEY; } diff --git a/fs/ext4/crypto_key.c b/fs/ext4/crypto_key.c index d6abe46..858d7d6 100644 --- a/fs/ext4/crypto_key.c +++ b/fs/ext4/crypto_key.c @@ -152,14 +152,13 @@ int _ext4_get_encryption_info(struct inode *inode) memcpy(crypt_info->ci_master_key, ctx.master_key_descriptor, sizeof(crypt_info->ci_master_key)); if (S_ISREG(inode->i_mode)) - crypt_info->ci_mode = ctx.contents_encryption_mode; + crypt_info->ci_size = + ext4_encryption_key_size(crypt_info->ci_data_mode); else if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) - crypt_info->ci_mode = ctx.filenames_encryption_mode; - else { - printk(KERN_ERR "ext4 crypto: Unsupported inode type.\n"); + crypt_info->ci_size = + ext4_encryption_key_size(crypt_info->ci_filename_mode); + else BUG(); - } - crypt_info->ci_size = ext4_encryption_key_size(crypt_info->ci_mode); BUG_ON(!crypt_info->ci_size); if (DUMMY_ENCRYPTION_ENABLED(sbi)) { memset(crypt_info->ci_raw, 0x42, EXT4_AES_256_XTS_KEY_SIZE); diff --git a/fs/ext4/ext4_crypto.h b/fs/ext4/ext4_crypto.h index d29687c..69faf0e 100644 --- a/fs/ext4/ext4_crypto.h +++ b/fs/ext4/ext4_crypto.h @@ -74,7 +74,6 @@ struct ext4_encryption_key { } __attribute__((__packed__)); struct ext4_crypt_info { - unsigned char ci_mode; unsigned char ci_size; char ci_data_mode; char ci_filename_mode;