public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers3@gmail.com>
To: "Theodore Y . Ts'o" <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org, fstests@vger.kernel.org,
	Eric Biggers <ebiggers@google.com>
Subject: [PATCH] xfstests-bld: populate keyring with default key for test_dummy_encryption
Date: Mon, 12 Dec 2016 22:54:47 -0800	[thread overview]
Message-ID: <1481612087-65325-1-git-send-email-ebiggers3@gmail.com> (raw)

From: Eric Biggers <ebiggers@google.com>

We can improve test coverage and simplify the test_dummy_encryption
kernel logic by requiring userspace to add a default master key to the
keyring.  Update xfstests-bld to do this.  This allows xfstests-bld to
test kernels with the corresponding kernel patch applied ("fscrypt /
ext4: make test_dummy_encryption require a keyring key").  It can still
test older kernels too; the key just doesn't get used in that case.

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 kvm-xfstests/test-appliance/files/root/fs/ext4/config | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/kvm-xfstests/test-appliance/files/root/fs/ext4/config b/kvm-xfstests/test-appliance/files/root/fs/ext4/config
index 66d2633..1ae017d 100644
--- a/kvm-xfstests/test-appliance/files/root/fs/ext4/config
+++ b/kvm-xfstests/test-appliance/files/root/fs/ext4/config
@@ -36,6 +36,18 @@ function setup_mount_opts()
     if test -n "$MNTOPTS" ; then
 	EXT_MOUNT_OPTIONS="$EXT_MOUNT_OPTIONS,$MNTOPTS"
     fi
+    if echo "$EXT_MOUNT_OPTIONS" | grep -q test_dummy_encryption; then
+	# Create a new session keyring and add a default master key to it.
+	local raw=""
+	for ((i = 0; i < 64; i++)); do
+	    raw="${raw}\\x$(printf "%02x" $(( $RANDOM % 256 )))"
+	done
+	local mode='\x00\x00\x00\x00'
+	local size='\x40\x00\x00\x00' # assuming little endian
+	keyctl new_session > /dev/null
+	echo -n -e "${mode}${raw}${size}" | \
+		keyctl padd logon fscrypt:4242424242424242 @s > /dev/null
+    fi
 }
 
 function get_mkfs_opts()
-- 
2.8.0.rc3.226.g39d4020


                 reply	other threads:[~2016-12-13  6:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1481612087-65325-1-git-send-email-ebiggers3@gmail.com \
    --to=ebiggers3@gmail.com \
    --cc=ebiggers@google.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox