From patchwork Wed Jul 12 21:00:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 787431 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3x7BHB4fF5z9s0g for ; Thu, 13 Jul 2017 07:02:46 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="j2Sqa35i"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gETcKBzq"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=tHXzVGWbg2ZTtw12fDMxxLr1In0gZFXYGfYFwjb8JAo=; b=j2Sqa35i0a83Nhjwi5Dk/55ued AfVFsizG10I1GdnvROd6Kuh6+fti0q+1UR6cIpg6h6+mRLhG/P8taZzBV42L30w6vtNKWO3XXXnl5 g06UFKCRmemhWNw9+CSKfN8UCU7j2F7IAiRddvjU/91eYfSegePVBFLRbDIkVo+l1zsY/0P48WBv3 mvj7s/3WNjp6gMR6NleU1DvrHt0sKCeNfUYh9YIG5e9efwb7BBMkXBPlfHnJNPfOwOD9rNvZ5H+XZ G/F3n21eX5G/jTUeRWNhDCmKvgeR5EApWH52wCC669QSu6RV76WuWOf2bW14yCAZEDCujLML4rxbE 6T/6fq1w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dVOmN-0005Eb-K6; Wed, 12 Jul 2017 21:02:39 +0000 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dVOmA-0004zL-K2 for linux-mtd@lists.infradead.org; Wed, 12 Jul 2017 21:02:30 +0000 Received: by mail-pg0-x242.google.com with SMTP id d193so4336649pgc.2 for ; Wed, 12 Jul 2017 14:02:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6E+m1fa+yAG9Si11faOWIN0NzOOtvOiCqXVGa8KMD10=; b=gETcKBzq9Apxo+vX6gpvMAiqJvBo720eEkTYk/wmQ/t4+AkwrjhJ733xPb+YURndz0 ge0iqDi6Zbr0j1T0Vlyb15sxAnf1zCublxznhmPU9zVAncTZYy2qz9PgR7bZe3WSOX/m aTxwKAVMPNfc/PHBX7YDl79MVEHqt9H1giKR1hZc7X5lL2rRlb1eGWydNh37JM9KYap1 8Oc8UEIhiYEw/CmjYUiBy35r+s5CvAydHezUYP9VXcMcJ6sDqB7nTmx8bIst9usEg45P 4YlZJkat8G9ckniyjh/nE+dlLq/9yHm666maXuv3Uw1iqzw2Q0SGsyZCkb3uqjm43TNy qmLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6E+m1fa+yAG9Si11faOWIN0NzOOtvOiCqXVGa8KMD10=; b=cXX7VXXZ7JQ3LZG7N6M6/0mjS3E7i1sPEtW/5UBPGHPfTiOMe9R6QTDI8wd8ZS+e0X 36NeA6yWqxpbyQPPgeT/6ocqt2deSARhZCL8gL1DBsoC/2JS1aSNBGYGEkf3fVReZOS7 I/IbkmOxBjC9MFzHivQ1Gohs0aw8Pml6+NUX4n7HBXuhj14bUHjcNSWWct89o250oRId o/SGDfz4WA3+m76l7VE/GFe6M17mGEX6yFlCdUpa3KAFo49VqQF/tVEOzFEoF0YmYdAR RMZBxYMoyc3sxftyEF8rQpjNJy6IS/gQ0lE7wQ7Hpqkxnqup4Q8evkszb9PTSzc2rQmI glSQ== X-Gm-Message-State: AIVw111Tq2KLA08fHFfl4KUqyN8luxdZawMf2HQ55iOlchiHnCve2QT9 qj1aUnKanhAKzQ== X-Received: by 10.99.108.134 with SMTP id h128mr5859466pgc.29.1499893326814; Wed, 12 Jul 2017 14:02:06 -0700 (PDT) Received: from ebiggers-linuxstation.kir.corp.google.com ([100.66.174.81]) by smtp.gmail.com with ESMTPSA id m16sm8002488pfj.130.2017.07.12.14.02.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Jul 2017 14:02:06 -0700 (PDT) From: Eric Biggers To: linux-fscrypt@vger.kernel.org Subject: [PATCH 2/6] fscrypt: rename ->ci_master_key to ->ci_master_key_descriptor Date: Wed, 12 Jul 2017 14:00:31 -0700 Message-Id: <20170712210035.51534-3-ebiggers3@gmail.com> X-Mailer: git-send-email 2.13.2.932.g7449e964c-goog In-Reply-To: <20170712210035.51534-1-ebiggers3@gmail.com> References: <20170712210035.51534-1-ebiggers3@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170712_140226_850646_DED74A78 X-CRM114-Status: GOOD ( 10.04 ) X-Spam-Score: -1.8 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:400e:c05:0:0:0:242 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (ebiggers3[at]gmail.com) 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ebiggers3[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Theodore Y . Ts'o" , Eric Biggers , Alex Cope , linux-f2fs-devel@lists.sourceforge.net, linux-mtd@lists.infradead.org, linux-crypto@vger.kernel.org, linux-fsdevel@vger.kernel.org, Jaegeuk Kim , linux-ext4@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Eric Biggers In struct fscrypt_info, ->ci_master_key is the master key descriptor, not the master key itself. In preparation for introducing a struct fscrypt_master_key and making ->ci_master_key point to it, rename the existing ->ci_master_key to ->ci_master_key_descriptor. Signed-off-by: Eric Biggers Acked-by: Michael Halcrow --- fs/crypto/fscrypt_private.h | 2 +- fs/crypto/keyinfo.c | 4 ++-- fs/crypto/policy.c | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/crypto/fscrypt_private.h b/fs/crypto/fscrypt_private.h index ef6909035823..5470aac82cab 100644 --- a/fs/crypto/fscrypt_private.h +++ b/fs/crypto/fscrypt_private.h @@ -107,7 +107,7 @@ struct fscrypt_info { u8 ci_data_mode; u8 ci_filename_mode; u8 ci_flags; - u8 ci_master_key[FS_KEY_DESCRIPTOR_SIZE]; + u8 ci_master_key_descriptor[FS_KEY_DESCRIPTOR_SIZE]; }; typedef enum { diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c index 7e664a11340a..5591fd24e4b2 100644 --- a/fs/crypto/keyinfo.c +++ b/fs/crypto/keyinfo.c @@ -293,8 +293,8 @@ int fscrypt_get_encryption_info(struct inode *inode) crypt_info->ci_data_mode = ctx.contents_encryption_mode; crypt_info->ci_filename_mode = ctx.filenames_encryption_mode; crypt_info->ci_flags = ctx.flags; - memcpy(crypt_info->ci_master_key, ctx.master_key_descriptor, - sizeof(crypt_info->ci_master_key)); + memcpy(crypt_info->ci_master_key_descriptor, ctx.master_key_descriptor, + FS_KEY_DESCRIPTOR_SIZE); res = determine_cipher_type(crypt_info, inode, &cipher_str, &keysize); if (res) diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index 044f23fadb5a..81c59f8e45c0 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -224,7 +224,8 @@ int fscrypt_has_permitted_context(struct inode *parent, struct inode *child) child_ci = child->i_crypt_info; if (parent_ci && child_ci) { - return memcmp(parent_ci->ci_master_key, child_ci->ci_master_key, + return memcmp(parent_ci->ci_master_key_descriptor, + child_ci->ci_master_key_descriptor, FS_KEY_DESCRIPTOR_SIZE) == 0 && (parent_ci->ci_context_version == child_ci->ci_context_version) && @@ -282,7 +283,7 @@ int fscrypt_inherit_context(struct inode *parent, struct inode *child, ctx.contents_encryption_mode = ci->ci_data_mode; ctx.filenames_encryption_mode = ci->ci_filename_mode; ctx.flags = ci->ci_flags; - memcpy(ctx.master_key_descriptor, ci->ci_master_key, + memcpy(ctx.master_key_descriptor, ci->ci_master_key_descriptor, FS_KEY_DESCRIPTOR_SIZE); get_random_bytes(ctx.nonce, FS_KEY_DERIVATION_NONCE_SIZE); if (ctx.version != FSCRYPT_CONTEXT_V1)