From: "Verma, Vishal L" <vishal.l.verma@intel.com>
To: "Williams, Dan J" <dan.j.williams@intel.com>,
"Jiang, Dave" <dave.jiang@intel.com>,
"Verma, Vishal L" <vishal.l.verma@intel.com>
Cc: "linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>
Subject: Re: [PATCH v6 07/12] ndctl: setup modprobe rules
Date: Sat, 5 Jan 2019 01:40:46 +0000 [thread overview]
Message-ID: <618d74799f70c15a72cdba1e35f1c6a75afbcca5.camel@intel.com> (raw)
In-Reply-To: <154482178124.65434.1988469520850504955.stgit@djiang5-desk3.ch.intel.com>
On Fri, 2018-12-14 at 14:09 -0700, Dave Jiang wrote:
> Adding reference config file for modprobe.d in order to trigger the
> reference script that will inject keys associated with the nvdimms into
> the kernel user ring for unlock.
>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
> Makefile.am | 10 ++++++++++
> contrib/ndctl-loadkeys.sh | 24 ++++++++++++++++++++++++
> contrib/nvdimm_modprobe.conf | 1 +
> 3 files changed, 35 insertions(+)
> create mode 100755 contrib/ndctl-loadkeys.sh
> create mode 100644 contrib/nvdimm_modprobe.conf
>
> diff --git a/Makefile.am b/Makefile.am
> index e0c463a3..5a3f03aa 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -42,6 +42,16 @@ bashcompletiondir = $(BASH_COMPLETION_DIR)
> dist_bashcompletion_DATA = contrib/ndctl
> endif
>
> +load_key_file = contrib/ndctl-loadkeys.sh
> +load_keydir = $(sysconfdir)/ndctl/
> +load_key_DATA = $(load_key_file)
> +EXTRA_DIST += $(load_key_file)
> +
> +modprobe_file = contrib/nvdimm_modprobe.conf
> +modprobedir = $(sysconfdir)/modprobe.d/
> +modprobe_DATA = $(modprobe_file)
> +EXTRA_DIST += $(modprobe_file)
> +
> noinst_LIBRARIES = libccan.a
> libccan_a_SOURCES = \
> ccan/str/str.h \
> diff --git a/contrib/ndctl-loadkeys.sh b/contrib/ndctl-loadkeys.sh
> new file mode 100755
> index 00000000..dae0a88a
> --- /dev/null
> +++ b/contrib/ndctl-loadkeys.sh
> @@ -0,0 +1,24 @@
> +#!/bin/bash -Ex
> +
> +# This script assumes a single master key for all DIMMs
> +
> +KEY_PATH=/etc/ndctl/keys
> +TPMH_PATH=$KEY_PATH/tpm.handle
> +KEYTPE=""
> +TPM_HANDLE=""
> +id=""
> +
> +if [ -f $TPMH_PATH ]; then
> + KEYTYPE=trusted
> + TPM_HANDLE="keyhandle=`cat $TPMH_PATH`"
> +else
> + KEYTYPE=user
> +fi
Same comments as the previous script about uppercase variables,
backticks, and quoting.
> +
> +keyctl show | grep -q nvdimm-master || keyctl add $KEYTYPE nvdimm-master "load `cat $KEY_PATH/nvdimm-master.blob` $TPM_HANDLE" @u > /dev/null
Prefer:
if ! grep -q "nvdimm-master" <<< "$(keyctl show)"; then
keyctl add ...
fi
In fact is it not possible to directly query keyctl for 'nvdimm-master'
instead of show everything + grep?
> +
> +for i in `ls -1 $KEY_PATH/nvdimm_*.blob`;
/never/ loop through files using ls - it is fragile and broken..
http://mywiki.wooledge.org/ParsingLs
Use globbing instead - see below.
> +do
> + id=`echo $i | cut -d'_' -f2`
Useless use of echo :)
id="$(cut -d'_' -f2 <<< $i)"
> + keyctl add encrypted nvdimm:$id "load `cat $i`" @u
> +done
The whole thing then becomes:
for file in "$key_path"/nvdimm_*; do
id="$(cut -d'_' -f2 <<< "${file##*/}")"
keyctl add encrypted nvdimm:"$id" "load $(cat $i)" @u
done
> diff --git a/contrib/nvdimm_modprobe.conf b/contrib/nvdimm_modprobe.conf
> new file mode 100644
> index 00000000..b113d8d7
> --- /dev/null
> +++ b/contrib/nvdimm_modprobe.conf
> @@ -0,0 +1 @@
> +install libnvdimm /usr/sbin/ndctl-loadkeys.sh ; /sbin/modprobe --ignore-install libnvdimm $CMDLINE_OPTS
>
> _______________________________________________
> Linux-nvdimm mailing list
> Linux-nvdimm@lists.01.org
> https://lists.01.org/mailman/listinfo/linux-nvdimm
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
next prev parent reply other threads:[~2019-01-05 1:40 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-14 21:09 [PATCH v6 00/12] ndctl: add security support Dave Jiang
2018-12-14 21:09 ` [PATCH v6 01/12] ndctl: add support for display security state Dave Jiang
2018-12-14 21:09 ` [PATCH v6 02/12] ndctl: add passphrase update to ndctl Dave Jiang
2019-01-05 0:07 ` Verma, Vishal L
2018-12-14 21:09 ` [PATCH v6 03/12] ndctl: add disable security support Dave Jiang
2018-12-14 21:09 ` [PATCH v6 04/12] ndctl: add support for freeze security Dave Jiang
2018-12-14 21:09 ` [PATCH v6 05/12] ndctl: add support for sanitize dimm Dave Jiang
2018-12-14 21:09 ` [PATCH v6 06/12] ndctl: add unit test for security ops (minus overwrite) Dave Jiang
2019-01-05 1:21 ` Verma, Vishal L
2018-12-14 21:09 ` [PATCH v6 07/12] ndctl: setup modprobe rules Dave Jiang
2019-01-05 1:40 ` Verma, Vishal L [this message]
2018-12-14 21:09 ` [PATCH v6 08/12] ndctl: add overwrite operation support Dave Jiang
2018-12-14 21:09 ` [PATCH v6 09/12] ndctl: add overwrite-wait support Dave Jiang
2019-01-05 1:54 ` Verma, Vishal L
2018-12-14 21:09 ` [PATCH v6 10/12] ndctl: master phassphrase management support Dave Jiang
2019-01-05 2:01 ` Verma, Vishal L
2018-12-14 21:10 ` [PATCH v6 11/12] ndctl: add master secure erase support Dave Jiang
2018-12-14 21:10 ` [PATCH v6 12/12] ndctl: documentation for security and key management Dave Jiang
2019-01-05 2:31 ` Verma, Vishal L
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=618d74799f70c15a72cdba1e35f1c6a75afbcca5.camel@intel.com \
--to=vishal.l.verma@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=linux-nvdimm@lists.01.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.